Kubernetes部署通用手册 (支持版本1.19,1.18,1.17,1.16) (17)

# 重启服务

[root@k8s-node01 cfg]# systemctl restart kubelet [root@k8s-node01 cfg]# systemctl restart kube-proxy node2修改配置 [root@k8s-node02 ~]# cd /data/soft/kubernetes/cfg/ [root@k8s-node02 cfg]# ll total 32 -rw------- 1 root root 2169 Apr 18 17:49 bootstrap.kubeconfig -rw-r--r-- 1 root root 241 Apr 18 17:49 flanneld -rw-r--r-- 1 root root 413 Apr 18 17:55 kubelet -rw-r--r-- 1 root root 269 Apr 18 17:56 kubelet.config -rw------- 1 root root 2298 Apr 18 18:07 kubelet.kubeconfig -rw-r--r-- 1 root root 191 Apr 18 18:01 kube-proxy -rw------- 1 root root 6271 Apr 18 17:49 kube-proxy.kubeconfig [root@k8s-node02 cfg]# grep -irn 223 * bootstrap.kubeconfig:5: server: https://192.168.0.10:6443 flanneld:2:FLANNEL_OPTIONS="--etcd-endpoints=https://192.168.0.10:2379,https://192.168.0.12:2379,https://192.168.0.12:2379 -etcd-cafile=http://www.likecs.com/data/soft/etcd/ssl/ca.pem -etcd-certfile=http://www.likecs.com/data/soft/etcd/ssl/server.pem -etcd-keyfile=http://www.likecs.com/data/soft/etcd/ssl/server-key.pem"kubelet.kubeconfig:5: server: https://192.168.0.10:6443 kube-proxy.kubeconfig:5: server: https://192.168.0.10:6443 [root@k8s-node02 cfg]# vim bootstrap.kubeconfig +5 [root@k8s-node02 cfg]# vim kubelet.kubeconfig +5 [root@k8s-node02 cfg]# vim kube-proxy.kubeconfig +5 [root@k8s-node02 cfg]# grep -irn 200 * bootstrap.kubeconfig:5: server: https://192.168.0.200:6443 kubelet.kubeconfig:5: server: https://192.168.0.200:6443 kube-proxy.kubeconfig:5: server: https://192.168.0.200:6443

重启node2节点服务

[root@k8s-node02 cfg]# systemctl restart kubelet [root@k8s-node02 cfg]# systemctl restart kube-proxy

到此kubernetes 基础架构配置完成————————-

扩展配置 NODE节点执行kubectl命令

这一章节操作是为了生产kubeconfig文件,此文件主要用于在node节点上面执行kubectl 命令,同时也可以生成此文件给开发或者其他普通用户执行kubectl命令。具体步骤如下:

# 在master01上操作

cd k8s-cert vim kubectl.sh kubectl config set-cluster kubernetes \ --server=https://192.168.0.200:6443 \ --embed-certs=true \ --certificate-authority=ca.pem \ --kubeconfig=config kubectl config set-credentials cluster-admin \ --certificate-authority=ca.pem \ --embed-certs=true \ --client-key=admin-key.pem \ --client-certificate=admin.pem \ --kubeconfig=config kubectl config set-context default --cluster=kubernetes --user=cluster-admin --kubeconfig=config kubectl config use-context default --kubeconfig=config [root@k8s-master01 k8s-cert]# pwd /data/www/k8s-cert [root@k8s-master01 k8s-cert]# bash kubectl.sh Cluster "kubernetes" set. User "cluster-admin" set. Context "default" created. Switched to context "default". [root@k8s-master01 k8s-cert]# ls config config [root@k8s-master01 k8s-cert]# ls admin.csr bootstrap.kubeconfig ca-key.pem kubeconfig.sh kube-proxy-key.pem server-csr.json admin-csr.json ca-config.json ca.pem kubectl.sh kube-proxy.kubeconfig server-key.pem admin-key.pem ca.csr config kube-proxy.csr kube-proxy.pem server.pem admin.pem ca-csr.json k8s-cert.sh kube-proxy-csr.json server.csr

分发新生成的证书到node节点

192.168.0.7[root@k8s-master01 k8s-cert]# scp /usr/bin/kubectl root@192.168.0.7:/usr/bin/ root@192.168.0.7's password: kubectl 100% 37MB 68.2MB/s 00:00 [root@k8s-master01 k8s-cert]# scp config root@192.168.0.7:/root root@192.168.0.7's password: config 100% 6273 3.7MB/s 00:00

在node1上操作

[root@k8s-node01 ~]# pwd /root [root@k8s-node01 ~]# ls anaconda-ks.cfg config flannel.sh flannel-v0.10.0-linux-amd64.tar.gz kubelet.sh node.zip proxy.sh README.md [root@k8s-node01 ~]# kubectl --kubeconfig=./config get nodes NAME STATUS ROLES AGE VERSION 192.168.0.7 Ready <none> 3d18h v1.16.4 192.168.0.8 Ready <none> 3d17h v1.16.4 [root@k8s-node01 ~]# kubectl --kubeconfig=./config get nodes -o wide NAME STATUS ROLES AGE VERSION INTERNAL-IP EXTERNAL-IP OS-IMAGE KERNEL-VERSION CONTAINER-RUNTIME 192.168.0.7 Ready <none> 3d18h v1.16.4 192.168.0.7 <none> CentOS Linux 7 (Core) 3.10.0-957.el7.x86_64 docker://18.9.5 192.168.0.8 Ready <none> 3d17h v1.16.4 192.168.0.8 <none> CentOS Linux 7 (Core) 3.10.0-957.10.1.el7.x86_64 docker://18.9.5 常见问题 api启动不了报错(配置文件错误)

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wppjyp.html