5. Kubernetes 安装node加入集群
2019-06-27 本文已影响0人
飞跑的蛤蟆
1. 配置镜像加速支持
2. 添加kubernetes的阿里巴巴源
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
重新生成yum本地缓存
yum makecache fast
![](https://img.haomeiwen.com/i831248/ec726ad3d0ba7dd1.png)
![](https://img.haomeiwen.com/i831248/fc45ccc7882a6e62.png)
3. 安装kubeadm和相关工具
yum install kubelet-1.14.0 kubeadm-1.14.0 --disableexcludes=kubernetes
![](https://img.haomeiwen.com/i831248/566ac228b4926c7d.png)
![](https://img.haomeiwen.com/i831248/55c11e0de883b7b5.png)
启动kubelet和docker并将其设置为开机自启动
systemctl enable docker && systemctl start docker
systemctl enable kubelet && systemctl start kubelet
![](https://img.haomeiwen.com/i831248/b12f0d0f0236afde.png)
4.为kubeadm命令生成配置文件
kubeadm config print init-defaults > init.defaults.yaml
cp init.defaults.yaml join-config.yaml
# join-config.yaml
apiVerision: kubeadm.k8s.io.v1beta1
kind: JoinConfiguration
discovery:
bootstrapToken:
apiServerEndpoint: 192.168.32.138:6443
token: lpqedc.ur4t7ta4tj6oal1x
![](https://img.haomeiwen.com/i831248/8e0f5f3ae35f7dba.png)
![](https://img.haomeiwen.com/i831248/aa16612dad25749b.png)
5. 执行kubeadm join命令,将本node加入集群
![](https://img.haomeiwen.com/i831248/606967063de29d97.png)
[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.14" 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] Activating the kubelet service
[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.