Kubernets二进制安装(10)之部署主控节点部署调度器服务kube-scheduler

Kubernetes Scheduler是一个策略丰富、拓扑感知、工作负载特定的功能,调度器显著影响可用性、性能和容量。调度器需要考虑个人和集体的资源要求、服务质量要求、硬件/软件/政策约束、亲和力和反亲和力规范、数据局部性、负载间干扰、完成期限等。工作负载特定的要求必要时将通过 API 暴露。

kube-scheduler是Kube-Master相关的3个服务之一(ApiServer、Controller Manager、Scheduler),是有状态的服务,会修改集群的状态信息。

如果多个master节点上的相关服务同时生效,则会有同步与一致性问题,所以多master节点中的kube-scheduler服务只能是主备的关系,kukubernetes采用租赁锁(lease-lock)实现leader的选举,具体到kube-scheduler,设置启动参数"--leader-elect=true"。

集群规划

主机名 角色 IP地址
mfyxw30.mfyxw.com kube-scheduler 192.168.80.30
mfyxw40.mfyxw.com kube-scheduler 192.168.80.40

1.创建kube-scheduler启动脚本

在mfyxw30.mfyxw.com主机上创建kube-scheduler启动脚本

[root@mfyxw30 ~]# cat > /opt/kubernetes/server/bin/kube-scheduler.sh << EOF
#!/bin/sh
./kube-scheduler \\
  --leader-elect  \\
  --log-dir /data/logs/kubernetes/kube-scheduler \\
  --master http://127.0.0.1:8080 \\
  --v 2
EOF

1586014621134

在mfyxw40.mfyxw.com主机上创建kube-scheduler启动脚本

[root@mfyxw40 ~]# cat > /opt/kubernetes/server/bin/kube-scheduler.sh << EOF
#!/bin/sh
./kube-scheduler \\
  --leader-elect  \\
  --log-dir /data/logs/kubernetes/kube-scheduler \\
  --master http://127.0.0.1:8080 \\
  --v 2
EOF

1586014633292

2.调整文件权限,创建目录

在mfyxw30.mfyxw.com主机上调整kube-scheduler.sh文件权限,创建目录/data/logs/kubernetes/kube-scheduler

[root@mfyxw30 ~]# chmod +x /opt/kubernetes/server/bin/kube-scheduler.sh
[root@mfyxw30 ~]# mkdir -p /data/logs/kubernetes/kube-scheduler

1586014846485

在mfyxw40.mfyxw.com主机上调整kube-scheduler.sh文件权限,创建目录/data/logs/kubernetes/kube-scheduler

[root@mfyxw40 ~]# chmod +x /opt/kubernetes/server/bin/kube-scheduler.sh
[root@mfyxw40 ~]# mkdir -p /data/logs/kubernetes/kube-scheduler

1586014835373

3.为kube-scheduler创建supervisor配置文件

在mfyxw30.mfyxw.com主机上,为kube-scheduler创建supervisor配置文件

[root@mfyxw30 ~]# cat > /etc/supervisord.d/kube-scheduler.ini << EOF
[program:kube-scheduler-80-30]
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=false                                                    ; redirect proc stderr to stdout (default false)
stdout_logfile=/data/logs/kubernetes/kube-scheduler/scheduler.stdout.log ; stdout 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)
stderr_logfile=/data/logs/kubernetes/kube-scheduler/scheduler.stderr.log ; stderr log path, NONE for none; default AUTO
stderr_logfile_maxbytes=64MB                                             ; max # logfile bytes b4 rotation (default 50MB)
stderr_logfile_backups=4                                                 ; # of stderr logfile backups (default 10)
stderr_capture_maxbytes=1MB                                              ; number of bytes in 'capturemode' (default 0)
stderr_events_enabled=false                                              ; emit events on stderr writes (default false)
EOF

1586015075836

在mfyxw40.mfyxw.com主机上,为kube-scheduler创建supervisor配置文件

[root@mfyxw40 ~]# cat > /etc/supervisord.d/kube-scheduler.ini << EOF
[program:kube-scheduler-80-40]
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=false                                                    ; redirect proc stderr to stdout (default false)
stdout_logfile=/data/logs/kubernetes/kube-scheduler/scheduler.stdout.log ; stdout 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)
stderr_logfile=/data/logs/kubernetes/kube-scheduler/scheduler.stderr.log ; stderr log path, NONE for none; default AUTO
stderr_logfile_maxbytes=64MB                                             ; max # logfile bytes b4 rotation (default 50MB)
stderr_logfile_backups=4                                                 ; # of stderr logfile backups (default 10)
stderr_capture_maxbytes=1MB                                              ; number of bytes in 'capturemode' (default 0)
stderr_events_enabled=false                                              ; emit events on stderr writes (default false)
EOF

1586015097296

4.启动服务并检查

在mfyxw30.mfyxw.com主机上启动kube-scheduler服务并检查

[root@mfyxw30 ~]# supervisorctl update
[root@mfyxw30 ~]# supervisorctl status

1586015252765

在mfyxw40.mfyxw.com主机上启动kube-scheduler服务并检查

[root@mfyxw40 ~]# supervisorctl update
[root@mfyxw40 ~]# supervisorctl status

1586015244443

5.为kubectl创建链接并查看集群健康

在mfyxw30.mfyxw.com主机上为kubectl创建链接并查看集群健康

[root@mfyxw30 ~]# ln -s /opt/kubernetes/server/bin/kubectl /usr/bin/kubectl
[root@mfyxw30 ~]# kubectl get cs

1586015443090

在mfyxw40.mfyxw.com主机上为kubectl创建链接并查看集群健康

[root@mfyxw40 ~]# ln -s /opt/kubernetes/server/bin/kubectl /usr/bin/kubectl
[root@mfyxw40 ~]# kubectl get cs

1586015453400

posted on 2020-04-05 00:33  杨枫哥  阅读(356)  评论(0编辑  收藏  举报