架构图

1、本节架构 2、创建启动脚本 3、创建supervisor配置 4、启动服务并检查 5、检查master节点

1、本节架构

2、创建启动脚本

cat > /opt/kubernetes/server/bin/kube-controller-manager.sh <<'eof'
#!/bin/sh
./kube-controller-manager \
  --cluster-cidr 172.7.0.0/16 \
  --leader-elect \
  --log-dir /data/logs/kubernetes/kube-controller-manager \
  --master http://127.0.0.1:8080 \
  --service-account-private-key-file ./certs/ca-key.pem \
  --service-cluster-ip-range 192.168.0.0/16 \
  --root-ca-file ./certs/ca.pem \
  --v 2
eof
chmod +x /opt/kubernetes/server/bin/kube-controller-manager.sh 
mkdir -p /data/logs/kubernetes/kube-controller-manager

3、创建supervisor配置

cat > /etc/supervisord.d/kube-conntroller-manager.ini <<'eof'
[program:kube-controller-manager-7-21]
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                                                       ; emit events on stdout writes (default false)
eof

4、启动服务并检查

supervisorctl update
supervisorctl status
etcd-server-7-22                 RUNNING   pid 14199, uptime 0:10:55
kube-apiserver-7-22              RUNNING   pid 14198, uptime 0:10:55
kube-controller-manager-7-22     RUNNING   pid 14357, uptime 0:00:38
kube-scheduler-7-22              RUNNING   pid 14197, uptime 0:10:55
netstat -tulnp | grep kube-con
tcp6       0      0 :::10252                :::*                    LISTEN      14757/./kube-contro 
tcp6       0      0 :::10257                :::*                    LISTEN      14757/./kube-contro 

5、检查master节点

ln -s /opt/kubernetes/server/bin/kubectl /usr/bin/kubectl
kubectl get cs
Warning: v1 ComponentStatus is deprecated in v1.19+
NAME                 STATUS    MESSAGE              ERROR
controller-manager   Healthy   ok                   
scheduler            Healthy   ok                   
etcd-0               Healthy   {"health": "true"}   
etcd-2               Healthy   {"health": "true"}   
etcd-1               Healthy   {"health": "true"}