Alternatively, if you are the root user, you can run:
export KUBECONFIG=/etc/kubernetes/admin.conf
You should now deploy a pod network to the cluster. Run "kubectl apply -f [podnetwork].yaml" with one of the options listed at: https://kubernetes.io/docs/concepts/cluster-administration/addons/
Then you can join any number of worker nodes by running the following on each as root:
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml #-------------------------↓↓↓↓↓↓------------------------- podsecuritypolicy.policy/psp.flannel.unprivileged created clusterrole.rbac.authorization.k8s.io/flannel created clusterrolebinding.rbac.authorization.k8s.io/flannel created serviceaccount/flannel created configmap/kube-flannel-cfg created daemonset.apps/kube-flannel-ds created #-------------------------↑↑↑↑↑↑-------------------------
查看节点状态
1 2 3 4 5
kubectl get nodes #-------------------------↓↓↓↓↓↓------------------------- NAME STATUS ROLES AGE VERSION k8s-master Ready control-plane,master 6m35s v1.20.5 #-------------------------↑↑↑↑↑↑-------------------------
kubectl get nodes #-------------------------↓↓↓↓↓↓------------------------- NAME STATUS ROLES AGE VERSION k8s-master Ready control-plane,master 24m v1.20.5 k8s-node-1 Ready <none> 8m24s v1.20.5 #-------------------------↑↑↑↑↑↑-------------------------
kubectl get deployment #-------------------------↓↓↓↓↓↓------------------------- NAME READY UP-TO-DATE AVAILABLE AGE nginx 1/1 1 1 32m #-------------------------↑↑↑↑↑↑-------------------------
kubectl get pods #-------------------------↓↓↓↓↓↓------------------------- NAME READY STATUS RESTARTS AGE nginx-59578f7988-chlch 1/1 Running 0 31m #-------------------------↑↑↑↑↑↑-------------------------
# 查看pod概要信息 kubectl get pod -n <namespace> kubectl get pod -n <namespace> <pod-name> kubectl get pod -n <namespace> <pod-name> -o wide kubectl get pod --all-namespaces
# 查看pod详细信息 kubectl describe pod -n <namespace> kubectl describe pod -n <namespace> <pod-name>
# 删除pod kubectl delete pod <pod-name> -n <namespace> kubectl delete pod <pod-name> --force --grace-period=0 -n <namespace>
cd /etc/kubernetes/pki mkdir backup cp -vrf *.crt *.key backup/
创建新的证书
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
kubeadm certs renew all
#-------------------------↓↓↓↓↓↓------------------------- [renew] Reading configuration from the cluster... [renew] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
certificate embedded in the kubeconfig file for the admin to use and for kubeadm itself renewed certificate for serving the Kubernetes API renewed certificate the apiserver uses to access etcd renewed certificate for the API server to connect to kubelet renewed certificate embedded in the kubeconfig file for the controller manager to use renewed certificate for liveness probes to healthcheck etcd renewed certificate for etcd nodes to communicate with each other renewed certificate for serving etcd renewed certificate for the front proxy client renewed certificate embedded in the kubeconfig file for the scheduler manager to use renewed
Done renewing certificates. You must restart the kube-apiserver, kube-controller-manager, kube-scheduler and etcd, so that they can use the new certificates. #-------------------------↑↑↑↑↑↑-------------------------
#-------------------------↓↓↓↓↓↓------------------------- [check-expiration] Reading configuration from the cluster... [check-expiration] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -o yaml'
CERTIFICATE EXPIRES RESIDUAL TIME CERTIFICATE AUTHORITY EXTERNALLY MANAGED admin.conf Apr 06, 2022 07:20 UTC 364d no apiserver Apr 06, 2022 07:20 UTC 364d ca no apiserver-etcd-client Apr 06, 2022 07:20 UTC 364d etcd-ca no apiserver-kubelet-client Apr 06, 2022 07:20 UTC 364d ca no controller-manager.conf Apr 06, 2022 07:20 UTC 364d no etcd-healthcheck-client Apr 06, 2022 07:20 UTC 364d etcd-ca no etcd-peer Apr 06, 2022 07:20 UTC 364d etcd-ca no etcd-server Apr 06, 2022 07:20 UTC 364d etcd-ca no front-proxy-client Apr 06, 2022 07:21 UTC 364d front-proxy-ca no scheduler.conf Apr 06, 2022 07:21 UTC 364d no
CERTIFICATE AUTHORITY EXPIRES RESIDUAL TIME EXTERNALLY MANAGED ca Mar 21, 2031 03:26 UTC 9y no etcd-ca Mar 21, 2031 03:26 UTC 9y no front-proxy-ca Mar 21, 2031 03:26 UTC 9y no #-------------------------↑↑↑↑↑↑-------------------------
4.4 加签api-server的地址
先备份原有证书
1 2 3
cd /etc/kubernetes/pki mkdir backup cp -vrf apiserver.* backup/