kubeadm装置k8s-1.18.18

资源筹备

角色主机名ip零碎
nodem8s-master01192.168.219.162CentOS 7.9.2009
nodem8s-node02192.168.219.165CentOS 7.9.2009

一、初始化资源

参考:https://segmentfault.com/a/11...

二、增加node节点

1、在master上生成新的token

[root@k8s-master01 ~]# kubeadm token create --print-join-command --ttl=0

阐明:
--ttl=0代表工夫永不过期,不加此参数默认24小时过期

输入如下:

W0611 03:08:31.246969   63170 configset.go:202] WARNING: kubeadm cannot validate component configs for API groups [kubelet.config.k8s.io kubeproxy.config.k8s.io]kubeadm join 192.168.219.160:6443 --token hkpvr9.bsfj9a6i7612vd59     --discovery-token-ca-cert-hash sha256:a8d537ee5d1a17e73ba94996744ccefd0d2f58f3871f29708e9c5642a28157b7

2、退出node节点

node节点操作:

[root@k8s-node02 ~]# kubeadm join 192.168.219.160:6443 --token hkpvr9.bsfj9a6i7612vd59     --discovery-token-ca-cert-hash sha256:a8d537ee5d1a17e73ba94996744ccefd0d2f58f3871f29708e9c5642a28157b7

输入如下:

W0611 03:11:48.274867    3087 join.go:346] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set.[preflight] Running pre-flight checks    [WARNING IsDockerSystemdCheck]: detected "cgroupfs" as the Docker cgroup driver. The recommended driver is "systemd". Please follow the guide at https://kubernetes.io/docs/setup/cri/[preflight] Reading configuration from the cluster...[preflight] FYI: You can look at this config file with 'kubectl -n kube-system get cm kubeadm-config -oyaml'[kubelet-start] Downloading configuration for the kubelet from the "kubelet-config-1.18" ConfigMap in the kube-system namespace[kubelet-start] Writing kubelet configuration to file "/var/lib/kubelet/config.yaml"[kubelet-start] Writing kubelet environment file with flags to file "/var/lib/kubelet/kubeadm-flags.env"[kubelet-start] Starting the kubelet[kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...This node has joined the cluster:* Certificate signing request was sent to apiserver and a response was received.* The Kubelet was informed of the new secure connection details.Run 'kubectl get nodes' on the control-plane to see this node join the cluster.

阐明:
kubernetes node节点退出容器 [ERROR FileContent--proc-sys-net-ipv4-ip_forward]: /proc/sys/net/ipv4/ip_forward contents are not set to 1

解决:

[root@k8s-node02 ~]# sysctl -w net.ipv4.ip_forward=1

3、验证

在master节点上执行

[root@k8s-master01 ~]# kubectl get node

输入如下:

NAME           STATUS   ROLES    AGE   VERSIONk8s-master01   Ready    master   28h   v1.18.18k8s-node01     Ready    <none>   28h   v1.18.18k8s-node02     Ready    <none>   27m   v1.18.18

三、增加master节点

1、在master上生成用于新master退出的证书

[root@k8s-master01 ~]# kubeadm init phase upload-certs --experimental-upload-certs