1. 程式人生 > >kubernetes Master部署之Scheduler 以及 HA部署(5)

kubernetes Master部署之Scheduler 以及 HA部署(5)

mit 節點 ext health 作用 fig heal color nod

Kubernetes Scheduler作用是將Controller Manager將要新建的Pod按照特定的調度算法和調度策略綁定到集群中某個合適的Node上,並將綁定信息寫入到etcd中。

一、部署Scheduler

下面生成kube-scheduler的kubeconfig文件,操作如下:

cd /etc/kubernetes
export KUBE_APISERVER="https://192.168.15.200:6443"

配置 cluster

kubectl config set-cluster kubernetes --certificate-authority=/etc/kubernetes/ssl/ca.pem 
--embed-certs=true --server=${KUBE_APISERVER} --kubeconfig=scheduler.conf

配置 credentials

kubectl config set-credentials system:kube-scheduler --client-certificate=/etc/kubernetes/ssl/scheduler.pem --embed-certs=true --client-key=/etc/kubernetes/ssl/scheduler-key.pem --kubeconfig=scheduler.conf

配置 context

kubectl config set-context system:kube-[email protected] --cluster=kubernetes --user=system:kube-scheduler --kubeconfig=scheduler.conf

配置 default context

kubectl config use-context system:[email protected] --kubeconfig=scheduler.conf

將生成的scheduler.conf文件分發到各個 Master 節點的 /etc/kubernetes 目錄下,如下:

scp scheduler.conf k8s-master02:/etc/kubernetes/                                      
scp scheduler.conf k8s-master03:/etc/kubernetes/

創建 kube-scheduler 的 systemd服務啟動文件,如下:

export KUBE_APISERVER="https://192.168.15.200:6443"
cat > /usr/lib/systemd/system/kube-scheduler.service <<EOF
[Unit]
Description=kube-scheduler
After=network.target
After=kube-apiserver.service
 
[Service]
EnvironmentFile=-/etc/kubernetes/scheduler
ExecStart=/usr/local/bin/kube-scheduler         --logtostderr=true         --v=0         --master=${KUBE_APISERVER}         --kubeconfig=/etc/kubernetes/scheduler.conf         --leader-elect=true
Restart=on-failure
Type=simple
LimitNOFILE=65536
 
[Install]
WantedBy=multi-user.target
EOF

分發到其他主機:

scp /usr/lib/systemd/system/kube-scheduler.service k8s-master02:/usr/lib/systemd/system/                                          
scp /usr/lib/systemd/system/kube-scheduler.service k8s-master03:/usr/lib/systemd/system/

在各節點啟動服務:

systemctl daemon-reload
systemctl enable kube-scheduler
systemctl start kube-scheduler
systemctl status kube-scheduler

三個 Master 節點上的 kube-schedule 部署完成,通過選舉出一個 leader 工作。

查看 Kubernetes Master 集群各個核心組件的狀態全部正常,如下所示:

[root@k8s-master01 kubernetes]# kubectl get cs
NAME                 STATUS    MESSAGE              ERROR
etcd-1               Healthy   {"health": "true"}   
scheduler            Healthy   ok                   
controller-manager   Healthy   ok                   
etcd-0               Healthy   {"health": "true"}   
etcd-2               Healthy   {"health": "true"}

kubernetes Master部署之Scheduler 以及 HA部署(5)