caas k8s主控节点如何查询_如何向k8s集群添加node节点

本文介绍了如何将新节点加入到Kubernetes(K8s)集群中。首先,需要在新节点的hosts文件中添加Master节点的域名和IP。然后,在Master节点上使用kubeadm生成加入命令,并在新节点上执行此命令。过程中可能会遇到权限和依赖项警告,通过sudo执行并安装必要工具可解决。最后,确认新节点已成功加入集群,可通过kubectl get nodes检查。
摘要由CSDN通过智能技术生成

1.首先在新节点的机器上配置好master节点的host

编辑/etc/host 文件添加master 节点的域名IP192.168.30.131   apiserver.cluster.local

2.在master节点上执行 kubeadm token create --print-join-command

执行上面命令后将会输出root@node1:~# kubeadm token create --print-join-command

kubeadm join apiserver.cluster.local:6443 --token 0nptjy.lvbyzgl0v8v7yl2l --discovery-token-ca-cert-hash  sha256:31bea31503ae327e2c416aa310b61601fd6ae81c3ca31eaaf5c2f491f4d103cc

3.接着在新节点机器上执行  master节点上面命令输出结果➜  ~ kubeadm join apiserver.cluster.local:6443 --token 0nptjy.lvbyzgl0v8v7yl2l     --discovery-token-ca-cert-hash sha256:31bea31503ae327e2c416aa310b61601fd6ae81c3ca31eaaf5c2f491f4d103cc

W1221 00:02:47.329071   15355 join.go:368] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set.

This is not a control plan

[preflight] Running pre-flight checks

error execution phase preflight: [preflight] Some fatal errors occurred:

[ERROR IsPrivilegedUser]: user is not running as root

[preflight] If you know what you are doing, you can make a check non-fatal with `--ignore-preflight-errors=...`

To see the stack trace of this error execute with --v=5 or higher

➜  ~ sudo kubeadm join apiserver.cluster.local:6443 --token 0nptjy.lvbyzgl0v8v7yl2l     --discovery-token-ca-cert-hash sha256:31bea31503ae327e2c416aa310b61601fd6ae81c3ca31eaaf5c2f491f4d103cc

W1221 00:03:13.463931   15552 join.go:368] [preflight] WARNING: JoinControlPane.controlPlane settings will be ignored when control-plane flag is not set.

This is not a control plan

[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/

[WARNING FileExisting-ebtables]: ebtables not found in system path

[WARNING FileExisting-ethtool]: ethtool not found in system path

[WARNING FileExisting-socat]: socat not found in system path

[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.17" 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.

在master节点上查看添加结果root@node1:~# kubectl get nodes

NAME        STATUS   ROLES    AGE     VERSION

node1       Ready    master   4d1h    v1.17.0

node2       Ready       4d1h    v1.17.0

xytschool   Ready       4m11s   v1.17.0

查看master节点信息root@node1:~# kubectl -n kube-system get cm kubeadm-config -oyaml

apiVersion: v1

data:

ClusterConfiguration: |

apiServer:

certSANs:

- 127.0.0.1

- apiserver.cluster.local

- 192.168.30.131

- 10.103.97.2

extraArgs:

authorization-mode: Node,RBAC

timeoutForControlPlane: 4m0s

apiVersion: kubeadm.k8s.io/v1beta2

certificatesDir: /etc/kubernetes/pki

clusterName: kubernetes

controlPlaneEndpoint: apiserver.cluster.local:6443

controllerManager: {}

dns:

type: CoreDNS

etcd:

local:

dataDir: /var/lib/etcd

imageRepository: k8s.gcr.io

kind: ClusterConfiguration

kubernetesVersion: v1.17.0

networking:

dnsDomain: cluster.local

podSubnet: 100.64.0.0/10

serviceSubnet: 10.96.0.0/12

scheduler: {}

ClusterStatus: |

apiEndpoints:

node1:

advertiseAddress: 192.168.30.131

bindPort: 6443

apiVersion: kubeadm.k8s.io/v1beta2

kind: ClusterStatus

kind: ConfigMap

metadata:

creationTimestamp: "2019-12-16T14:50:46Z"

name: kubeadm-config

namespace: kube-system

resourceVersion: "152"

selfLink: /api/v1/namespaces/kube-system/configmaps/kubeadm-config

uid: 038ce30d-8f9e-49bb-90e6-317c46f59d7e

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值