您现在的位置是: 网站首页 >Docker >Docker&Kubernetes技术全解 Docker

【K8s+Docker技术全解】10.Master主控节点服务-部署kube-scheduler、检查集群状态

admin2020年10月12日 09:34 Docker | Kubernetes | Linux 8人已围观

Docker&Kubernetes技术全解简介 Kubernetes 是一个可移植的、可扩展的开源平台,用于管理容器化的工作负载和服务,可促进声明式配置和自动化。Kubernetes 拥有一个庞大且快速增长的生态系统。Kubernetes 的服务、支持和工具广泛可用。 课程来自老男孩教育学习总结。

## 99.151/152部署kube-scheduler ### 什么是kube-scheduler? 调度器组件监视那些新创建的未指定运行节点的 Pod,并选择节点让 Pod 在上面运行。调度决策考虑的因素包括单个 Pod 和 Pod 集合的资源需求、硬件/软件/策略约束、亲和性和反亲和性规范、数据位置、工作负载间的干扰和最后时限。 当前各个Node节点资源会通过kubelet汇总到etcd中,当用户提交创建pod请求时,apiserver将请求交给controller manager处理,controller manager通知scheduler进行筛选合适的Node。此时scheduler通过etcd中存储的Node信息进行**预选**(predict),将符合要求的Node选出来。再根据**优选**(priorities)策略,选择最合适的Node用于创建pod。 这个也不需要签发证书 ### 99.151部署kube-scheduler #### 创建启动脚本kube-scheduler-startup.sh ```bash # 192.168.99.151 [root@k8s99-151 bin]# mkdir -p /var/log/kube-scheduler [root@k8s99-151 bin]# pwd /opt/kubernetes/server/bin [root@k8s99-151 bin]# vim kube-scheduler-startup.sh #!/bin/bash ./kube-scheduler \ --leader-elect \ --log-dir /var/log/kube-scheduler \ --master http://127.0.0.1:8080 \ --v 2 [root@k8s99-151 bin]# chmod +x kube-scheduler-startup.sh [root@k8s99-151 bin]# ./kube-scheduler-startup.sh ``` #### 使用supervisor启动kube-scheduler.ini ```bash [root@k8s99-151 bin]# vim /etc/supervisord.d/kube-scheduler.ini ``` 写入下面配置 ```ini [program:kube-scheduler-k8s99-151] command=/opt/kubernetes/server/bin/kube-scheduler-startup.sh numprocs=1 directory=/opt/kubernetes/server/bin/ autostart=true autorestart=true startsecs=30 startretries=3 exitcodes=0,2 stopsignal=QUIT stopwaitsecs=10 user=root redirect_stderr=true stdout_logfile=/var/log/kube-scheduler/scheduler.stdout.log stdout_logfile_maxbytes=64MB stdout_logfile_backups=4 stdout_capture_maxbytes=1MB stdout_events_enabled=false ``` ```bash [root@k8s99-151 bin]# supervisorctl update kube-scheduler-k8s99-151: added process group [root@k8s99-151 bin]# supervisorctl status etcd-server-k8s99-151 RUNNING pid 1307, uptime 0:25:38 kube-apiserver-k8s99-151 RUNNING pid 1306, uptime 0:25:38 kube-controller-manager-k8s99-151 RUNNING pid 1708, uptime 0:06:32 kube-scheduler-k8s99-151 RUNNING pid 1839, uptime 0:00:44 ``` #### 检查controller-manager端口监听 ```bash [root@k8s99-151 bin]# netstat -luntp | grep kube-schedul tcp6 0 0 :::10251 :::* LISTEN 1840/./kube-schedul tcp6 0 0 :::10259 :::* LISTEN 1840/./kube-schedul ``` #### 防火墙允许对外端口 ```bash [root@k8s99-151 bin]# firewall-cmd --zone=public --add-port=10251/tcp --permanent success [root@k8s99-151 bin]# firewall-cmd --zone=public --add-port=10259/tcp --permanent success [root@k8s99-151 bin]# firewall-cmd --reload success ``` ### 99.152部署kube-scheduler ```bash mkdir -p /var/log/kube-scheduler cd /opt/kubernetes/server/bin cat > kube-scheduler-startup.sh << EOF #!/bin/bash ./kube-scheduler \ --leader-elect \ --log-dir /var/log/kube-scheduler \ --master http://127.0.0.1:8080 \ --v 2 EOF chmod +x kube-scheduler-startup.sh ./kube-scheduler-startup.sh cat > /etc/supervisord.d/kube-scheduler.ini << EOF [program:kube-scheduler-k8s99-152] command=/opt/kubernetes/server/bin/kube-scheduler-startup.sh numprocs=1 directory=/opt/kubernetes/server/bin/ autostart=true autorestart=true startsecs=30 startretries=3 exitcodes=0,2 stopsignal=QUIT stopwaitsecs=10 user=root redirect_stderr=true stdout_logfile=/var/log/kube-scheduler/scheduler.stdout.log stdout_logfile_maxbytes=64MB stdout_logfile_backups=4 stdout_capture_maxbytes=1MB stdout_events_enabled=false EOF supervisorctl update supervisorctl status netstat -luntp | grep kube-schedul firewall-cmd --zone=public --add-port=10251/tcp --permanent firewall-cmd --zone=public --add-port=10259/tcp --permanent firewall-cmd --reload ``` ## 99.151/152检查kubernetes集群状态 99.151/152执行 ### 99.151使用kubectl检查集群状态 ```bash # 192.168.99.151 [root@k8s99-151 bin]# ln -s /opt/kubernetes/server/bin/kubectl /usr/bin/kubectl && which kubectl /usr/bin/kubectl # 检查集群状态,cs表示cluster status [root@k8s99-151 bin]# kubectl get cs error: no configuration has been provided, try setting KUBERNETES_MASTER environment variable ``` 参考 https://kubernetes.io/docs/setup/release/ ```bash [root@k8s99-151 bin]# vim /etc/profile # 在最后添加以下内容 export KUBERNETES_MASTER=http://localhost:8080 [root@k8s99-151 bin]# source /etc/profile ``` 再次执行`kubectl get cs`检查集群状态 ```bash [root@k8s99-151 bin]# kubectl get cs NAME STATUS MESSAGE ERROR controller-manager Healthy ok scheduler Healthy ok etcd-0 Healthy {"health":"true"} etcd-1 Healthy {"health":"true"} etcd-2 Healthy {"health":"true"} ``` ### 99.152使用kubectl检查集群状态 另一台做同样的操作 ```bash # 192.168.99.152 ln -s /opt/kubernetes/server/bin/kubectl /usr/bin/kubectl && which kubectl echo "export KUBERNETES_MASTER=http://localhost:8080" >> /etc/profile && source /etc/profile kubectl get cs # 可以得到下面内容 [root@k8s99-152 bin]# kubectl get cs NAME STATUS MESSAGE ERROR scheduler Healthy ok controller-manager Healthy ok etcd-0 Healthy {"health":"true"} etcd-1 Healthy {"health":"true"} etcd-2 Healthy {"health":"true"} ``` ### 查看其他集群信息 ```bash # 查看集群版本 [root@k8s99-151 ~]# kubectl version Client Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:56:40Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"18", GitVersion:"v1.18.2", GitCommit:"52c56ce7a8272c798dbc29846288d7cd9fbae032", GitTreeState:"clean", BuildDate:"2020-04-16T11:48:36Z", GoVersion:"go1.13.9", Compiler:"gc", Platform:"linux/amd64"} # 查看集群信息 [root@k8s99-151 ~]# kubectl cluster-info Kubernetes master is running at http://localhost:8080 CoreDNS is running at http://localhost:8080/api/v1/namespaces/kube-system/services/coredns:dns/proxy kubernetes-dashboard is running at http://localhost:8080/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'. ```

很赞哦! (0)

文章交流

  • emoji
0人参与,0条评论

当前用户

未登录,点击   登录

站点信息

  • 建站时间:网站已运行792天
  • 系统信息:Linux
  • 后台程序:Python: 3.6.6
  • 网站框架:Django: 2.2.12
  • 文章统计:250 篇
  • 文章评论:45 条
  • 腾讯分析网站概况-腾讯分析
  • 百度统计网站概况-百度统计
  • 公众号:微信扫描二维码,关注我们
  • QQ群:QQ加群,下载网站的学习源码
返回
顶部
标题 换行 登录
网站