本文主要是介绍suse 12 二进制部署 Kubernetets 1.19.7 - 第08章 - 部署kube-scheduler组件,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
文章目录
- 1.8、部署kube-scheduler
- 1.8.0、创建kube-scheduler请求证书
- 1.8.1、生成kube-scheduler证书和私钥
- 1.8.2、创建kube-scheduler的kubeconfig文件
- 1.8.3、配置kube-scheduler为systemctl启动
- 1.8.4、分发kube-scheduler证书和文件到其他节点
- 1.8.5、启动kube-scheduler服务
- 1.8.6、查看kube-scheduler端口
- 1.8.7、查看当前leader
- suse 12 二进制部署 Kubernetes 集群系列合集:
- suse 12 二进制部署 Kubernetets 1.19.7 - 第00章 - 环境准备
- suse 12 二进制部署 Kubernetets 1.19.7 - 第01章 - 创建CA证书和kubectl集群管理命令
- suse 12 二进制部署 Kubernetets 1.19.7 - 第02章 - 部署etcd集群
- suse 12 二进制部署 Kubernetets 1.19.7 - 第03章 - 部署flannel插件
- suse 12 二进制部署 Kubernetets 1.19.7 - 第04章 - 部署docker服务
- suse 12 二进制部署 Kubernetets 1.19.7 - 第05章 - 部署kube-nginx
- suse 12 二进制部署 Kubernetets 1.19.7 - 第06章 - 部署kube-apiserver组件
- suse 12 二进制部署 Kubernetets 1.19.7 - 第07章 - 部署kube-controller-manager组件
- suse 12 二进制部署 Kubernetets 1.19.7 - 第08章 - 部署kube-scheduler组件
- suse 12 二进制部署 Kubernetets 1.19.7 - 第09章 - 部署kubelet组件
- suse 12 二进制部署 Kubernetets 1.19.7 - 第10章 - 部署kube-proxy组件
- suse 12 二进制部署 Kubernetets 1.19.7 - 第11章 - 部署coredns组件
- suse 12 二进制部署 Kubernetets 1.19.7 - 第12章 - 部署dashboard插件
- suse 12 二进制部署 Kubernetets 1.19.7 - 第13章 - 部署metrics-server插件
- suse 12 编译部署Keepalived + nginx 为 kube-apiserver 提供高可用
- suse 12 二进制部署 Kubernetets 1.19.7 - 番外篇 - 增加node节点
1.8、部署kube-scheduler
1.8.0、创建kube-scheduler请求证书
k8s-01:~ # cd /opt/k8s/ssl/
k8s-01:/opt/k8s/ssl # cat > kube-scheduler-csr.json <<EOF
{"CN": "system:kube-scheduler","hosts": ["127.0.0.1","192.168.72.39","192.168.72.40","192.168.72.41"],"key": {"algo": "rsa","size": 2048},"names": [{"C": "CN","ST": "ShangHai","L": "ShangHai","O": "system:kube-scheduler","OU": "bandian"}]
}
EOF
1.8.1、生成kube-scheduler证书和私钥
k8s-01:/opt/k8s/ssl # cfssl gencert -ca=/opt/k8s/ssl/ca.pem \
-ca-key=/opt/k8s/ssl/ca-key.pem \
-config=/opt/k8s/ssl/ca-config.json \
-profile=kubernetes kube-scheduler-csr.json | cfssljson -bare kube-scheduler
1.8.2、创建kube-scheduler的kubeconfig文件
k8s-01:/opt/k8s/ssl # source /opt/k8s/bin/k8s-env.sh
"设置集群参数"
k8s-01:/opt/k8s/ssl # kubectl config set-cluster kubernetes \
--certificate-authority=/opt/k8s/ssl/ca.pem \
--embed-certs=true \
--server=${KUBE_APISERVER} \
--kubeconfig=kube-scheduler.kubeconfig
"设置客户端认证参数"
k8s-01:/opt/k8s/ssl # kubectl config set-credentials system:kube-scheduler \
--client-certificate=kube-scheduler.pem \
--client-key=kube-scheduler-key.pem \
--embed-certs=true \
--kubeconfig=kube-scheduler.kubeconfig
"设置上下文参数"
k8s-01:/opt/k8s/ssl # kubectl config set-context system:kube-scheduler \
--cluster=kubernetes \
--user=system:kube-scheduler \
--kubeconfig=kube-scheduler.kubeconfig
"设置默认上下文"
k8s-01:/opt/k8s/ssl # kubectl config use-context system:kube-scheduler --kubeconfig=kube-scheduler.kubeconfig
1.8.3、配置kube-scheduler为systemctl启动
k8s-01:~ # cd /opt/k8s/conf/
k8s-01:/opt/k8s/conf # source /opt/k8s/bin/k8s-env.sh
k8s-01:/opt/k8s/conf # cat > kube-scheduler.service.template <<EOF
[Unit]
Description=Kubernetes Scheduler
Documentation=https://github.com/GoogleCloudPlatform/kubernetes[Service]
WorkingDirectory=${K8S_DIR}/kube-scheduler
ExecStart=/opt/k8s/bin/kube-scheduler \\--bind-address=0.0.0.0 \\--leader-elect=true \\--kubeconfig=/etc/kubernetes/cert/kube-scheduler.kubeconfig \\--tls-cert-file=/etc/kubernetes/cert/kube-scheduler.pem \\--tls-private-key-file=/etc/kubernetes/cert/kube-scheduler-key.pem \\--authentication-kubeconfig=/etc/kubernetes/cert/kube-scheduler.kubeconfig \\--client-ca-file=/etc/kubernetes/cert/ca.pem \\--requestheader-allowed-names \\--requestheader-client-ca-file=/etc/kubernetes/cert/ca.pem \\--requestheader-extra-headers-prefix="X-Remote-Extra-" \\--requestheader-group-headers=X-Remote-Group \\--requestheader-username-headers=X-Remote-User \\--logtostderr=true \\--v=2
Restart=always
RestartSec=5
StartLimitInterval=0[Install]
WantedBy=multi-user.target
EOF
1.8.4、分发kube-scheduler证书和文件到其他节点
#!/usr/bin/env bash
source /opt/k8s/bin/k8s-env.shfor host in ${MASTER_IPS[@]}
doprintf "\e[1;34m${host}\e[0m\n"scp /opt/k8s/conf/kube-scheduler.service.template ${host}:/etc/systemd/system/kube-scheduler.servicescp /opt/k8s/ssl/{kube-scheduler*.pem,kube-scheduler.kubeconfig} ${host}:/etc/kubernetes/cert
done
1.8.5、启动kube-scheduler服务
#!/usr/bin/env bash
source /opt/k8s/bin/k8s-env.shfor host in ${MASTER_IPS[@]}
doprintf "\e[1;34m${host}\e[0m\n"ssh root@${host} "mkdir -p ${K8S_DIR}/kube-scheduler"ssh root@${host} "systemctl daemon-reload && \systemctl enable kube-scheduler --now && \systemctl status kube-scheduler | grep Active"
done
1.8.6、查看kube-scheduler端口
k8s-01:~ # ss -nltp | grep kube-scheduler
LISTEN 0 128 :::10251 :::* users:(("kube-scheduler",pid=67502,fd=8))
LISTEN 0 128 :::10259 :::* users:(("kube-scheduler",pid=67502,fd=9))
1.8.7、查看当前leader
k8s-01:~ # kubectl get endpoints kube-scheduler --namespace=kube-system -o yaml
apiVersion: v1
kind: Endpoints
metadata:annotations:control-plane.alpha.kubernetes.io/leader: '{"holderIdentity":"k8s-01_556718e1-338e-4e87-b2c8-c1ea2ccfa1c1","leaseDurationSeconds":15,"acquireTime":"2021-02-12T16:54:38Z","renewTime":"2021-02-12T16:54:49Z","leaderTransitions":0}'creationTimestamp: "2021-02-12T16:54:39Z"managedFields:- apiVersion: v1fieldsType: FieldsV1fieldsV1:f:metadata:f:annotations:.: {}f:control-plane.alpha.kubernetes.io/leader: {}manager: kube-scheduleroperation: Updatetime: "2021-02-12T16:54:39Z"name: kube-schedulernamespace: kube-systemresourceVersion: "557"selfLink: /api/v1/namespaces/kube-system/endpoints/kube-scheduleruid: 1e33fe40-0d13-4407-a7bb-f7a37f4a72a8
- 到此,
kubernetes master
节点已经部署完成,后面开始kubernetes node
节点的部署 - docker和flannel之前已经全节点部署了,因此,node节点只需要部署kubelet、kube-proxy、coredns以及dashboard
这篇关于suse 12 二进制部署 Kubernetets 1.19.7 - 第08章 - 部署kube-scheduler组件的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!