k8s二进制部署(四)
【摘要】 ##启动kube-apiserver.,kube-controller-manager,kube-schedulersystemctl daemon-reloadsystemctl start kube-apiserversystemctl enable kube-apiserversystemctl start kube-controller-managersystemctl enable...
##启动kube-apiserver.,kube-controller-manager,kube-scheduler
systemctl daemon-reload
systemctl start kube-apiserver
systemctl enable kube-apiserver
systemctl start kube-controller-manager
systemctl enable kube-controller-manager
systemctl start kube-scheduler
systemctl enable kube-scheduler
##检查启动情况
cp /root/kubernetes/server/bin/kubectl /usr/bin/
kubectl get cs
将kubelet-bootstrap用户绑定到集群
kubectl create clusterrolebinding kubelet-bootstrap \
--clusterrole=system:node-bootstrapper \
--user=kubelet-bootstrap
安装Node节点组件
##在node节点创建所需目录(node节点均指node01+node02)
mkdir /opt/kubernetes_node/{cfg,ssl,bin,log} -p
##切换回master节点
##切回cfssl证书目录
cd /opt/k8s/k8s-cert
##创建kube-proxy证书
cat > kube-proxy-csr.json << EOF
{
"CN": "system:kube-proxy",
"hosts": [],
"key": {
"algo": "rsa",
"size": 2048
},
"names": [
{
"C": "CN",
"L": "BeiJing",
"ST": "BeiJing",
"O": "k8s",
"OU": "System"
}
]
}
EOF
cfssl gencert -ca=ca.pem -ca-key=ca-key.pem -config=ca-config.json -profile=kubernetes kube-proxy-csr.json | cfssljson -bare kube-proxy
##创建kubeconfig脚本文件
cat > kubeconfig.sh<< EOF
KUBE_APISERVER="https://10.107.141.50:6443"
TOKEN="c47ffb939f5ca36231d9e3121a252940"
kubectl config set-cluster kubernetes \\
--certificate-authority=/opt/kubernetes_master/ssl/ca.pem \
--embed-certs=true \\
--server=\${KUBE_APISERVER} \\
--kubeconfig=bootstrap.kubeconfig
kubectl config set-credentials "kubelet-bootstrap" \\
--token=\${TOKEN} \\
--kubeconfig=bootstrap.kubeconfig
kubectl config set-context default \\
--cluster=kubernetes \\
--user="kubelet-bootstrap" \\
--kubeconfig=bootstrap.kubeconfig
kubectl config use-context default --kubeconfig=bootstrap.kubeconfig
#-----------
kubectl config set-cluster kubernetes \\
--certificate-authority=/opt/kubernetes_master/ssl/ca.pem \\
--embed-certs=true \\
--server=\${KUBE_APISERVER} \\
--kubeconfig=kube-proxy.kubeconfig
kubectl config set-credentials kube-proxy \\
--client-certificate=./kube-proxy.pem \\
--client-key=./kube-proxy-key.pem \\
--embed-certs=true \\
--kubeconfig=kube-proxy.kubeconfig
kubectl config set-context default \\
--cluster=kubernetes \\
--user=kube-proxy \\
--kubeconfig=kube-proxy.kubeconfig
kubectl config use-context default --kubeconfig=kube-proxy.kubeconfig
EOF
##执行脚本文件,生成bootstrap.kubeconfig ,kube-proxy.kubeconfig文件
bash kubeconfig.sh
##传输kubeconfig文件至node节点相应目录下
scp bootstrap.kubeconfig kube-proxy.kubeconfig root@10.107.141.51:/opt/kubernetes_node/cfg/
scp bootstrap.kubeconfig kube-proxy.kubeconfig root@10.107.141.52:/opt/kubernetes_node/cfg/
##传输ca文件至
##传输二进制文件至node节点相应目录
cd /root/kubernetes/server/bin
scp kubelet kube-proxy root@10.107.141.51:/opt/kubernetes_node/bin/
scp kubelet kube-proxy root@10.107.141.52:/opt/kubernetes_node/bin/
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)