k8s -- 部署主控節點控制器/排程器服務
阿新 • • 發佈:2021-02-11
技術標籤:K8Skuberneteslinux
安裝部署主控節點控制器/排程器服務
叢集規劃
主機名 角色 ip
hdss-1-21.host.com controller-manager 192.168.1.21
hdss-1-22.host.com controller-manager 192.168.1.22
注意:這裡部署文件以hdss-1-22.host.com主機為例,另外一臺運算節點安裝部署方法類似
編輯kube-controller-manager.sh執行指令碼
[[email protected] bin]# ls apiextensions-apiserver conf kube-apiserver kubectl kube-scheduler cert hyperkube kube-apiserver.sh kubelet mounter cloud-controller-manager kubeadm kube-controller-manager kube-proxy [
[email protected] bin]# vim kube-controller-manager.sh #!/bin/sh ./kube-controller-manager \ --cluster-cidr 172.7.0.0/16 \ --leader-elect true \ --log-dir /data/logs/kubernetes/kube-controller-manager \ --master http://127.0.0.1:8080 \ --service-account-private-key-file ./cert/ca-key.pem \ --service-cluster-ip-range 10.254.0.0/16 \ --root-ca-file ./cert/ca.pem \ --v 2
建立指令碼中的目錄
[[email protected] bin]# mkdir -p /data/logs/kubernetes/kube-controller-manager
[[email protected] bin]# chmod +x /opt/kubernetes/server/bin/kube-controller-manager.sh
編輯用於supervisord後臺啟動配置檔案 kube-conntroller-manager.ini
[[email protected] bin]# vi /etc/supervisord.d/kube-conntroller-manager.ini [program:kube-controller-manager-1-22] command=/opt/kubernetes/server/bin/kube-controller-manager.sh ; the program (relative uses PATH, can take args) numprocs=1 ; number of processes copies to start (def 1) directory=/opt/kubernetes/server/bin ; directory to cwd to before exec (def no cwd) autostart=true ; start at supervisord start (default: true) autorestart=true ; retstart at unexpected quit (default: true) startsecs=30 ; number of secs prog must stay running (def. 1) startretries=3 ; max # of serial start failures (default 3) exitcodes=0,2 ; 'expected' exit codes for process (default 0,2) stopsignal=QUIT ; signal used to kill process (default TERM) stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10) user=root ; setuid to this UNIX account to run the program redirect_stderr=true ; redirect proc stderr to stdout (default false) stdout_logfile=/data/logs/kubernetes/kube-controller-manager/controller.stdout.log ; stderr log path, NONE for none; default AUTO stdout_logfile_maxbytes=64MB ; max # logfile bytes b4 rotation (default 50MB) stdout_logfile_backups=4 ; # of stdout logfile backups (default 10) stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0) stdout_events_enabled=false
啟動並檢視程序資訊
[[email protected] bin]# supervisorctl update
kube-controller-manager-1-22: added process group
[[email protected] bin]# supervisorctl status
etcd-server-1-22 RUNNING pid 7483, uptime 3:41:15
kube-apiserver-1-22 RUNNING pid 6941, uptime 3:41:24
kube-controller-manager-1-22 RUNNING pid 10794, uptime 0:00:48
安裝kube-scheduler,編輯執行指令碼
[[email protected] bin]# vi /opt/kubernetes/server/bin/kube-scheduler.sh
#!/bin/sh
./kube-scheduler \
--leader-elect \
--log-dir /data/logs/kubernetes/kube-scheduler \
--master http://127.0.0.1:8080 \
--v 2
編輯supervisord後臺啟動配置檔案 kube-scheduler.ini
[[email protected] bin]# vi /etc/supervisord.d/kube-scheduler.ini
[program:kube-scheduler-1-22]
command=/opt/kubernetes/server/bin/kube-scheduler.sh ; the program (relative uses PATH, can take args)
numprocs=1 ; number of processes copies to start (def 1)
directory=/opt/kubernetes/server/bin ; directory to cwd to before exec (def no cwd)
autostart=true ; start at supervisord start (default: true)
autorestart=true ; retstart at unexpected quit (default: true)
startsecs=30 ; number of secs prog must stay running (def. 1)
startretries=3 ; max # of serial start failures (default 3)
exitcodes=0,2 ; 'expected' exit codes for process (default 0,2)
stopsignal=QUIT ; signal used to kill process (default TERM)
stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10)
user=root ; setuid to this UNIX account to run the program
redirect_stderr=true ; redirect proc stderr to stdout (default false)
stdout_logfile=/data/logs/kubernetes/kube-scheduler/scheduler.stdout.log ; stderr log path, NONE for none; default AUTO
stdout_logfile_maxbytes=64MB ; max # logfile bytes b4 rotation (default 50MB)
stdout_logfile_backups=4 ; # of stdout logfile backups (default 10)
stdout_capture_maxbytes=1MB ; number of bytes in 'capturemode' (default 0)
stdout_events_enabled=false ; emit events on stdout writes (default false)
建立目錄和賦予執行許可權
[[email protected] bin]# chmod +x /opt/kubernetes/server/bin/kube-scheduler.sh
[[email protected] bin]# mkdir -p /data/logs/kubernetes/kube-scheduler
[[email protected] bin]#
啟動並檢視狀態
[[email protected] bin]# supervisorctl update
kube-scheduler-1-22: added process group
[[email protected] bin]# supervisorctl status
etcd-server-1-22 RUNNING pid 7483, uptime 3:46:54
kube-apiserver-1-22 RUNNING pid 6941, uptime 3:47:03
kube-controller-manager-1-22 RUNNING pid 10794, uptime 0:06:27
kube-scheduler-1-22 RUNNING pid 10864, uptime 0:00:49
建立軟連結,檢視叢集的狀態
[[email protected] bin]# ln -s /opt/kubernetes/server/bin/kubectl /usr/bin/kubectl
[[email protected] bin]# which kubectl
/usr/bin/kubectl
[[email protected] bin]# kubectl get cs
NAME STATUS MESSAGE ERROR
scheduler Healthy ok
controller-manager Healthy ok
etcd-1 Healthy {"health": "true"}
etcd-2 Healthy {"health": "true"}
etcd-0 Healthy {"health": "true"}
[[email protected] bin]#