kubeadm增加master或node节点

Posted lxjian01

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了kubeadm增加master或node节点相关的知识,希望对你有一定的参考价值。

kubeadm安装k8s-1.18.18

资源准备

角色主机名ip系统
nodek8s-node3192.168.219.164CentOS 7.9.2009

一、初始化资源

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

二、添加node节点

1、在master上生成新的token

[root@k8s-master1 ~]# 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.161:6443 --token hkpvr9.bsfj9a6i7612vd59     --discovery-token-ca-cert-hash sha256:a8d537ee5d1a17e73ba94996744ccefd0d2f58f3871f29708e9c5642a28157b7

2、加入node节点

node节点操作:

[root@k8s-node3 ~]# kubeadm join 192.168.219.161: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-node3 ~]# sysctl -w net.ipv4.ip_forward=1

3、验证

在master节点上执行

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

输出如下:

NAME           STATUS   ROLES    AGE   VERSION
k8s-master1   Ready    master   28h   v1.18.18
k8s-node1     Ready    <none>   28h   v1.18.18
k8s-node2     Ready    <none>   28h   v1.18.18
k8s-node3     Ready    <none>   27m   v1.18.18

以上是关于kubeadm增加master或node节点的主要内容,如果未能解决你的问题,请参考以下文章

kubeadm部署K8S

快速搭建Kubernetes容器集群平台(kubeadm)

K8S kubeadm 部署出现的故障:kubectl get nodes 节点显示 NotReady

K8S kubeadm 部署出现的故障:kubectl get nodes 节点显示 NotReady

#yyds干货盘点# kubeadm添加新master或node

使用kubeadm快速部署一个k8s集群