kubeadm安装kubenetes1.15.4集群

基础环境

主机名 IP 系统版本  内核  docker版本  kubenetes版本
master 192.168.1.220 CentOS Linux release 7.6.1810 (Core)  5.5.4-1.el7.elrepo.x86_64 Docker version 18.06.3-ce, build d7080c1 v1.15.4
node01 192.168.1.221 CentOS Linux release 7.6.1810 (Core)  5.5.4-1.el7.elrepo.x86_64 Docker version 18.06.3-ce, build d7080c1 v1.15.4
node02 192.168.1.222 CentOS Linux release 7.6.1810 (Core)  5.5.4-1.el7.elrepo.x86_64 Docker version 18.06.3-ce, build d7080c1 v1.15.4

准备工作(所有主机)

[[email protected] ~]# hostname
master
[[email protected] ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.220   master
192.168.1.221   node01
192.168.1.222   node02
[[email protected] ~]# systemctl stop firewalld && systemctl disable firewalld
[[email protected] ~]# swapoff -a && sed -i ‘/ swap / s/^\(.*\)$/#\1/g‘ /etc/fstab

[[email protected] ~]# ntpdate cn.pool.ntp.org
19 Feb 18:06:14 ntpdate[43208]: adjust time server 182.92.12.11 offset -0.002174 sec[[email protected] ~]# crontab -l
*/3 * * * *     /usr/sbin/ntpdate cn.pool.ntp.org 

更换yum源(所有主机)

[[email protected] ~]# cd /etc/yum.repos.d/
[[email protected] yum.repos.d]# mv CentOS-Base.repo CentOS-Base.repo.bak
[[email protected] yum.repos.d]# wget http://mirrors.aliyun.com/repo/Centos-7.repo
[[email protected] yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
[[email protected] yum.repos.d]# ls -l
总用量 36
-rw-r--r--  1 root root 1572 12月  1 2016 CentOS7-Base-163.repo
-rw-r--r--  1 root root 2523 6月  16 2018 Centos-7.repo
-rw-r--r--. 1 root root 1664 8月  30 2017 CentOS-Base.repo.bak
-rw-r--r--. 1 root root 1309 8月  30 2017 CentOS-CR.repo
-rw-r--r--. 1 root root  649 8月  30 2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  314 8月  30 2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 8月  30 2017 CentOS-Media.repo
-rw-r--r--. 1 root root 1331 8月  30 2017 CentOS-Sources.repo
-rw-r--r--. 1 root root 3830 8月  30 2017 CentOS-Vault.repo
[[email protected] yum.repos.d]# yum clean all && yum makecache

创建/etc/sysctl.d/k8s.conf文件,添加如下内容(所有主机)

[[email protected] ~]# vi /etc/sysctl.d/k8s.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1
[[email protected] ~]# modprobe br_netfilter
[[email protected] ~]# sysctl -p /etc/sysctl.d/k8s.conf
net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-iptables = 1
net.bridge.bridge-nf-call-ip6tables = 1

配置阿里docker源(所有主机)

[[email protected] yum.repos.d]# yum install -y yum-utils device-mapper-persistent-data lvm2  安装必要的一些系统工具
[[email protected] yum.repos.d]# yum-config-manager --add-repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo  添加软件源信息
[[email protected] yum.repos.d]# yum makecache fast  更新
[[email protected] ~]# yum -y install docker-ce-18.06.3.ce-3.el7
[[email protected] yum.repos.d]# systemctl enable docker && systemctl start docker
[[email protected] yum.repos.d]# docker --version
Docker version 18.06.3-ce, build d7080c1

配置镜像加速(所有主机)

[[email protected] ~]# vi /etc/docker/daemon.json

{

"registry-mirrors": ["https://4ym6pzzt.mirror.aliyuncs.com"]

}
[[email protected] yum.repos.d]# systemctl restart docker

配置阿里k8s源(所有主机)

[[email protected] yum.repos.d]# 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

k8s版本查看(任意一台主机)

[[email protected] ~]# yum list kubelet --showduplicates | sort -r
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
已加载插件:fastestmirror
已安装的软件包
可安装的软件包
Loading mirror speeds from cached hostfile
kubelet.x86_64                       1.9.9-0                         kubernetes
kubelet.x86_64                       1.9.8-0                         kubernetes
kubelet.x86_64                       1.9.7-0                         kubernetes
kubelet.x86_64                       1.9.6-0                         kubernetes
kubelet.x86_64                       1.9.5-0                         kubernetes
kubelet.x86_64                       1.9.4-0                         kubernetes
kubelet.x86_64                       1.9.3-0                         kubernetes
kubelet.x86_64                       1.9.2-0                         kubernetes
kubelet.x86_64                       1.9.11-0                        kubernetes
kubelet.x86_64                       1.9.1-0                         kubernetes
kubelet.x86_64                       1.9.10-0                        kubernetes
kubelet.x86_64                       1.9.0-0                         kubernetes
kubelet.x86_64                       1.8.9-0                         kubernetes
kubelet.x86_64                       1.8.8-0                         kubernetes
kubelet.x86_64                       1.8.7-0                         kubernetes
kubelet.x86_64                       1.8.6-0                         kubernetes
kubelet.x86_64                       1.8.5-1                         kubernetes
kubelet.x86_64                       1.8.5-0                         kubernetes
kubelet.x86_64                       1.8.4-1                         kubernetes
kubelet.x86_64                       1.8.4-0                         kubernetes
kubelet.x86_64                       1.8.3-1                         kubernetes
kubelet.x86_64                       1.8.3-0                         kubernetes
kubelet.x86_64                       1.8.2-1                         kubernetes
kubelet.x86_64                       1.8.2-0                         kubernetes
kubelet.x86_64                       1.8.15-0                        kubernetes
kubelet.x86_64                       1.8.14-0                        kubernetes
kubelet.x86_64                       1.8.13-0                        kubernetes
kubelet.x86_64                       1.8.12-0                        kubernetes
kubelet.x86_64                       1.8.1-1                         kubernetes
kubelet.x86_64                       1.8.11-0                        kubernetes
kubelet.x86_64                       1.8.1-0                         kubernetes
kubelet.x86_64                       1.8.10-0                        kubernetes
kubelet.x86_64                       1.8.0-1                         kubernetes
kubelet.x86_64                       1.8.0-0                         kubernetes
kubelet.x86_64                       1.7.9-1                         kubernetes
kubelet.x86_64                       1.7.9-0                         kubernetes
kubelet.x86_64                       1.7.8-2                         kubernetes
kubelet.x86_64                       1.7.8-1                         kubernetes
kubelet.x86_64                       1.7.7-2                         kubernetes
kubelet.x86_64                       1.7.7-1                         kubernetes
kubelet.x86_64                       1.7.6-2                         kubernetes
kubelet.x86_64                       1.7.6-1                         kubernetes
kubelet.x86_64                       1.7.5-1                         kubernetes
kubelet.x86_64                       1.7.5-0                         kubernetes
kubelet.x86_64                       1.7.4-1                         kubernetes
kubelet.x86_64                       1.7.4-0                         kubernetes
kubelet.x86_64                       1.7.3-2                         kubernetes
kubelet.x86_64                       1.7.3-1                         kubernetes
kubelet.x86_64                       1.7.2-1                         kubernetes
kubelet.x86_64                       1.7.2-0                         kubernetes
kubelet.x86_64                       1.7.16-0                        kubernetes
kubelet.x86_64                       1.7.15-0                        kubernetes
kubelet.x86_64                       1.7.14-0                        kubernetes
kubelet.x86_64                       1.7.1-1                         kubernetes
kubelet.x86_64                       1.7.11-1                        kubernetes
kubelet.x86_64                       1.7.11-0                        kubernetes
kubelet.x86_64                       1.7.1-0                         kubernetes
kubelet.x86_64                       1.7.10-1                        kubernetes
kubelet.x86_64                       1.7.10-0                        kubernetes
kubelet.x86_64                       1.7.0-1                         kubernetes
kubelet.x86_64                       1.7.0-0                         kubernetes
kubelet.x86_64                       1.6.9-1                         kubernetes
kubelet.x86_64                       1.6.9-0                         kubernetes
kubelet.x86_64                       1.6.8-1                         kubernetes
kubelet.x86_64                       1.6.8-0                         kubernetes
kubelet.x86_64                       1.6.7-1                         kubernetes
kubelet.x86_64                       1.6.7-0                         kubernetes
kubelet.x86_64                       1.6.6-1                         kubernetes
kubelet.x86_64                       1.6.6-0                         kubernetes
kubelet.x86_64                       1.6.5-1                         kubernetes
kubelet.x86_64                       1.6.5-0                         kubernetes
kubelet.x86_64                       1.6.4-1                         kubernetes
kubelet.x86_64                       1.6.4-0                         kubernetes
kubelet.x86_64                       1.6.3-1                         kubernetes
kubelet.x86_64                       1.6.3-0                         kubernetes
kubelet.x86_64                       1.6.2-1                         kubernetes
kubelet.x86_64                       1.6.2-0                         kubernetes
kubelet.x86_64                       1.6.13-1                        kubernetes
kubelet.x86_64                       1.6.13-0                        kubernetes
kubelet.x86_64                       1.6.12-1                        kubernetes
kubelet.x86_64                       1.6.12-0                        kubernetes
kubelet.x86_64                       1.6.1-1                         kubernetes
kubelet.x86_64                       1.6.11-1                        kubernetes
kubelet.x86_64                       1.6.11-0                        kubernetes
kubelet.x86_64                       1.6.1-0                         kubernetes
kubelet.x86_64                       1.6.10-1                        kubernetes
kubelet.x86_64                       1.6.10-0                        kubernetes
kubelet.x86_64                       1.6.0-1                         kubernetes
kubelet.x86_64                       1.6.0-0                         kubernetes
kubelet.x86_64                       1.5.4-1                         kubernetes
kubelet.x86_64                       1.5.4-0                         kubernetes
kubelet.x86_64                       1.17.3-0                        kubernetes
kubelet.x86_64                       1.17.2-0                        kubernetes
kubelet.x86_64                       1.17.1-0                        kubernetes
kubelet.x86_64                       1.17.0-0                        kubernetes
kubelet.x86_64                       1.16.7-0                        kubernetes
kubelet.x86_64                       1.16.6-0                        kubernetes
kubelet.x86_64                       1.16.5-0                        kubernetes
kubelet.x86_64                       1.16.4-0                        kubernetes
kubelet.x86_64                       1.16.3-0                        kubernetes
kubelet.x86_64                       1.16.2-0                        kubernetes
kubelet.x86_64                       1.16.1-0                        kubernetes
kubelet.x86_64                       1.16.0-0                        kubernetes
kubelet.x86_64                       1.15.9-0                        kubernetes
kubelet.x86_64                       1.15.8-0                        kubernetes
kubelet.x86_64                       1.15.7-0                        kubernetes
kubelet.x86_64                       1.15.6-0                        kubernetes
kubelet.x86_64                       1.15.5-0                        kubernetes
kubelet.x86_64                       1.15.4-0                        kubernetes
kubelet.x86_64                       1.15.4-0                        @kubernetes
kubelet.x86_64                       1.15.3-0                        kubernetes
kubelet.x86_64                       1.15.2-0                        kubernetes
kubelet.x86_64                       1.15.1-0                        kubernetes
kubelet.x86_64                       1.15.10-0                       kubernetes
kubelet.x86_64                       1.15.0-0                        kubernetes
kubelet.x86_64                       1.14.9-0                        kubernetes
kubelet.x86_64                       1.14.8-0                        kubernetes
kubelet.x86_64                       1.14.7-0                        kubernetes
kubelet.x86_64                       1.14.6-0                        kubernetes
kubelet.x86_64                       1.14.5-0                        kubernetes
kubelet.x86_64                       1.14.4-0                        kubernetes
kubelet.x86_64                       1.14.3-0                        kubernetes
kubelet.x86_64                       1.14.2-0                        kubernetes
kubelet.x86_64                       1.14.1-0                        kubernetes
kubelet.x86_64                       1.14.10-0                       kubernetes
kubelet.x86_64                       1.14.0-0                        kubernetes
kubelet.x86_64                       1.13.9-0                        kubernetes
kubelet.x86_64                       1.13.8-0                        kubernetes
kubelet.x86_64                       1.13.7-0                        kubernetes
kubelet.x86_64                       1.13.6-0                        kubernetes
kubelet.x86_64                       1.13.5-0                        kubernetes
kubelet.x86_64                       1.13.4-0                        kubernetes
kubelet.x86_64                       1.13.3-0                        kubernetes
kubelet.x86_64                       1.13.2-0                        kubernetes
kubelet.x86_64                       1.13.12-0                       kubernetes
kubelet.x86_64                       1.13.11-0                       kubernetes
kubelet.x86_64                       1.13.1-0                        kubernetes
kubelet.x86_64                       1.13.10-0                       kubernetes
kubelet.x86_64                       1.13.0-0                        kubernetes
kubelet.x86_64                       1.12.9-0                        kubernetes
kubelet.x86_64                       1.12.8-0                        kubernetes
kubelet.x86_64                       1.12.7-0                        kubernetes
kubelet.x86_64                       1.12.6-0                        kubernetes
kubelet.x86_64                       1.12.5-0                        kubernetes
kubelet.x86_64                       1.12.4-0                        kubernetes
kubelet.x86_64                       1.12.3-0                        kubernetes
kubelet.x86_64                       1.12.2-0                        kubernetes
kubelet.x86_64                       1.12.1-0                        kubernetes
kubelet.x86_64                       1.12.10-0                       kubernetes
kubelet.x86_64                       1.12.0-0                        kubernetes
kubelet.x86_64                       1.11.9-0                        kubernetes
kubelet.x86_64                       1.11.8-0                        kubernetes
kubelet.x86_64                       1.11.7-0                        kubernetes
kubelet.x86_64                       1.11.6-0                        kubernetes
kubelet.x86_64                       1.11.5-0                        kubernetes
kubelet.x86_64                       1.11.4-0                        kubernetes
kubelet.x86_64                       1.11.3-0                        kubernetes
kubelet.x86_64                       1.11.2-0                        kubernetes
kubelet.x86_64                       1.11.1-0                        kubernetes
kubelet.x86_64                       1.11.10-0                       kubernetes
kubelet.x86_64                       1.11.0-0                        kubernetes
kubelet.x86_64                       1.10.9-0                        kubernetes
kubelet.x86_64                       1.10.8-0                        kubernetes
kubelet.x86_64                       1.10.7-0                        kubernetes
kubelet.x86_64                       1.10.6-0                        kubernetes
kubelet.x86_64                       1.10.5-0                        kubernetes
kubelet.x86_64                       1.10.4-0                        kubernetes
kubelet.x86_64                       1.10.3-0                        kubernetes
kubelet.x86_64                       1.10.2-0                        kubernetes
kubelet.x86_64                       1.10.13-0                       kubernetes
kubelet.x86_64                       1.10.12-0                       kubernetes
kubelet.x86_64                       1.10.11-0                       kubernetes
kubelet.x86_64                       1.10.1-0                        kubernetes
kubelet.x86_64                       1.10.10-0                       kubernetes
kubelet.x86_64                       1.10.0-0                        kubernetes
 * elrepo: mirrors.tuna.tsinghua.edu.cn

安装组件(所有主机),我安装的1.15.4版本的

[[email protected] ~]# yum install -y kubelet-1.15.4 kubeadm-1.15.4 kubectl-1.15.4
[[email protected] ~]# kubectl version
Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.4", GitCommit:"67d2fcf276fcd9cf743ad4be9a9ef5828adc082f", GitTreeState:"clean", BuildDate:"2019-09-18T14:51:13Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.4", GitCommit:"67d2fcf276fcd9cf743ad4be9a9ef5828adc082f", GitTreeState:"clean", BuildDate:"2019-09-18T14:41:55Z", GoVersion:"go1.12.9", Compiler:"gc", Platform:"linux/amd64"}
列出所需镜像。可以手动下载,也可以不用手动下载,master初始化时会自动下载。
[[email protected] ~]# kubeadm --kubernetes-version=v1.15.4 config images list
k8s.gcr.io/kube-apiserver:v1.15.4
k8s.gcr.io/kube-controller-manager:v1.15.4
k8s.gcr.io/kube-scheduler:v1.15.4
k8s.gcr.io/kube-proxy:v1.15.4
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.3.10
k8s.gcr.io/coredns:1.3.1

修改docker服务管理方式为systemd(所有主机)

[[email protected] yum.repos.d]# sed -i "s#^ExecStart=/usr/bin/dockerd.*#ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock --exec-opt native.cgroupdriver=systemd#g" /usr/lib/systemd/system/docker.service
这步可以不做,如果没有修改,集群在初始化和worker节点加入的时候会爆出警告信息

master初始化,仅在master节点操作

[[email protected] ~]# kubeadm init --apiserver-advertise-address=192.168.1.220 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.15.4 --service-cidr=10.1.0.0/16 --pod-network-cidr=10.244.0.0/16
[[email protected] ~]# mkdir -p $HOME/.kube
[[email protected] ~]# cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
[[email protected] ~]# chown $(id -u):$(id -g) $HOME/.kube/config

下载并安装flannel资源配置清单(所有主机)

# 手动拉取flannel的docker镜像
docker pull easzlab/flannel:v0.11.0-amd64
# 修改镜像名称
docker tag easzlab/flannel:v0.11.0-amd64 quay.io/coreos/flannel:v0.11.0-amd64
[[email protected] ~]# wget  https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
[[email protected] ~]# kubectl apply -f kube-flannel.yml 
[[email protected] ~]# kubectl get pod -n kube-system -o wide
NAME                             READY   STATUS    RESTARTS   AGE   IP              NODE     NOMINATED NODE   READINESS GATES
coredns-bccdc95cf-5ptzm          1/1     Running   0          66m   10.244.0.3      master   <none>           <none>
coredns-bccdc95cf-c7v9j          1/1     Running   0          66m   10.244.0.2      master   <none>           <none>
etcd-master                      1/1     Running   0          65m   192.168.1.220   master   <none>           <none>
kube-apiserver-master            1/1     Running   0          65m   192.168.1.220   master   <none>           <none>
kube-controller-manager-master   1/1     Running   0          66m   192.168.1.220   master   <none>           <none>
kube-flannel-ds-amd64-9fjhr      1/1     Running   1          59m   192.168.1.222   node02   <none>           <none>
kube-flannel-ds-amd64-g7vs7      1/1     Running   1          59m   192.168.1.221   node01   <none>           <none>
kube-flannel-ds-amd64-tg697      1/1     Running   0          60m   192.168.1.220   master   <none>           <none>
kube-proxy-bqd9j                 1/1     Running   0          59m   192.168.1.221   node01   <none>           <none>
kube-proxy-d8q7s                 1/1     Running   0          66m   192.168.1.220   master   <none>           <none>
kube-proxy-gz85g                 1/1     Running   0          59m   192.168.1.222   node02   <none>           <none>
kube-scheduler-master            1/1     Running   0          65m   192.168.1.220   master   <none>           <none>

node01加入集群

[[email protected] ~]# kubeadm join 192.168.1.220:6443 --token qa9y89.zmr3xgpk1429d0dw >     --discovery-token-ca-cert-hash sha256:2edda5757334f420c0b501aa4dc19072307d796a0ae09b3474824727a227d7ec

node02加入集群

[[email protected] ~]# kubeadm join 192.168.1.220:6443 --token qa9y89.zmr3xgpk1429d0dw     --discovery-token-ca-cert-hash sha256:2edda5757334f420c0b501aa4dc19072307d796a0ae09b3474824727a227d7ec
如果忘记加入命令,在master节点上行执行
kubeadm token create --print-join-command

master上查看各节点状态

[[email protected] ~]# kubectl get nodes -o wide
NAME     STATUS   ROLES    AGE   VERSION   INTERNAL-IP     EXTERNAL-IP   OS-IMAGE                KERNEL-VERSION              CONTAINER-RUNTIME
master   Ready    master   69m   v1.15.4   192.168.1.220   <none>        CentOS Linux 7 (Core)   5.5.4-1.el7.elrepo.x86_64   docker://18.6.3
node01   Ready    <none>   61m   v1.15.4   192.168.1.221   <none>        CentOS Linux 7 (Core)   5.5.4-1.el7.elrepo.x86_64   docker://18.6.3
node02   Ready    <none>   61m   v1.15.4   192.168.1.222   <none>        CentOS Linux 7 (Core)   5.5.4-1.el7.elrepo.x86_64   docker://18.6.3
[[email protected] ~]# kubectl get nodes
NAME     STATUS   ROLES    AGE   VERSION
master   Ready    master   69m   v1.15.4
node01   Ready    <none>   61m   v1.15.4
node02   Ready    <none>   61m   v1.15.4
如果集群初始化出错需要重新初始化的时候,首先要执行  kubeadm reset -f 

测试一下kubernetes集群(master上执行)

创建一个镜像为nginx的容器
[[email protected] ~]# kubectl create deployment nginx --image=nginx deployment.apps/nginx created
查看pod的详细信息,events部分可以看到创建过程
[[email protected] ~]# kubectl describe pod nginx Name: nginx-554b9c67f9-hkl8n Namespace: default Priority: 0 Node: node01/192.168.1.221 Start Time: Wed, 19 Feb 2020 17:56:23 +0800 Labels: app=nginx pod-template-hash=554b9c67f9 Annotations: <none> Status: Pending IP: Controlled By: ReplicaSet/nginx-554b9c67f9 Containers: nginx: Container ID: Image: nginx Image ID: Port: <none> Host Port: <none> State: Waiting Reason: ContainerCreating Ready: False Restart Count: 0 Environment: <none> Mounts: /var/run/secrets/kubernetes.io/serviceaccount from default-token-v8gp9 (ro) Conditions: Type Status Initialized True Ready False ContainersReady False PodScheduled True Volumes: default-token-v8gp9: Type: Secret (a volume populated by a Secret) SecretName: default-token-v8gp9 Optional: false QoS Class: BestEffort Node-Selectors: <none> Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s node.kubernetes.io/unreachable:NoExecute for 300s Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 17s default-scheduler Successfully assigned default/nginx-554b9c67f9-hkl8n to node01 Normal Pulling 11s kubelet, node01 Pulling image "nginx"

kubectl命令自动补全

##安装包
[[email protected] ~]# yum install -y bash-completion*
##手工执行
[[email protected] ~]# source <(kubectl completion bash)
##写入环境变量
[[email protected] ~]# echo "source <(kubectl completion bash)" >> ~/.bashrc
##需要手工执行一下,否则tab补全时会提示“-bash: _get_comp_words_by_ref: command not found ”
[[email protected] ~]# sh /usr/share/bash-completion/bash_completion
##加载环境变量
[[email protected] ~]# source /etc/profile
##再次使用kubectl命令进行tab补全就ok了

后续有nodes节点想加入集群的话,由于默认token的有效期为24小时,当过期之后,该token就不可用了,解决方法如下:

重新生成新的token ==> kubeadm token create
# 1.查看当前的token列表
[[email protected] ~]#  kubeadm token list
TOKEN                     TTL         EXPIRES                     USAGES                   DESCRIPTION                                                EXTRA GROUPS
l507qh.nqysbrdxjtcfx4c9   23h         2020-02-10T15:20:19+08:00   authentication,signing   <none>                                                     system:bootstrappers:kubeadm:default-node-token
v2yw0n.xaq2uu2oqqsk4wlv   23h         2020-02-10T15:14:53+08:00   authentication,signing   The default bootstrap token generated by ‘kubeadm init‘.   system:bootstrappers:kubeadm:default-node-token
重新生成新的token
[[email protected] ~]# kubeadm token create
W0209 15:44:21.172784   43064 validation.go:28] Cannot validate kube-proxy config - no validator is available
W0209 15:44:21.172852   43064 validation.go:28] Cannot validate kubelet config - no validator is available
0xpz5e.7fcygebnug44a3xm
再次查看当前的token列表
[[email protected] ~]# kubeadm token list
TOKEN                     TTL         EXPIRES                     USAGES                   DESCRIPTION                                                EXTRA GROUPS
0xpz5e.7fcygebnug44a3xm   23h         2020-02-10T15:44:21+08:00   authentication,signing   <none>                                                     system:bootstrappers:kubeadm:default-node-token
l507qh.nqysbrdxjtcfx4c9   23h         2020-02-10T15:20:19+08:00   authentication,signing   <none>                                                     system:bootstrappers:kubeadm:default-node-token
v2yw0n.xaq2uu2oqqsk4wlv   23h         2020-02-10T15:14:53+08:00   authentication,signing   The default bootstrap token generated by ‘kubeadm init‘.   system:bootstrappers:kubeadm:default-node-token
获取ca证书sha256编码hash值
[[email protected] ~]# openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2>/dev/null | openssl dgst -sha256 -hex | sed ‘s/^.* //‘
2773274565fa8f13ca7de2466ad98f5cb4f5815a20665f10d46399f318aa937c
节点加入集群
[email protected] ~]# kubeadm join --token 0xpz5e.7fcygebnug44a3xm(新的token) --discovery-token-ca-cert-hash 
如果忘记加入命令,在master节点上行执行
kubeadm token create --print-join-command

原文地址:https://www.cnblogs.com/liujunjun/p/12332400.html

时间: 2024-11-08 02:40:01

kubeadm安装kubenetes1.15.4集群的相关文章

kubeadm安装Kubernetes V1.10集群详细文档

1:服务器信息以及节点介绍 系统信息:centos1708 minimal    只修改IP地址 主机名称 IP 备注 node01 192.168.150.181 master and etcd rode02 192.168.150.182 master and etcd node03 192.168.150.183 master and etcd node04 192.168.150.184 node VIP 192.168.150.186 软件版本: docker17.03.2-ce so

使用kubeadm安装Kubernetes 1.16 集群

kubeadm是Kubernetes官方提供的用于快速安装Kubernetes集群的工具,伴随Kubernetes每个版本的发布都会同步更新,kubeadm会对集群配置方面的一些实践做调整,通过实验kubeadm可以学习到Kubernetes官方在集群配置上一些新的最佳实践. 操作系统Ubuntu 16.04+.Debian 9.CentOS 7.RHEL 7.Fedora 25/26 (best-effort).其他内存2GB + ,2核CPU +集群节点之间可以通信每个节点唯一主机名,MAC

安装、配置Redis集群

安装.配置Redis集群 目录 安装.配置Redis集群... 1 1.配置yum... 1 2.安装gcc. 1 3.下载软件包... 2 4.安装(主从都需要安装) 2 5.配置redis集群... 3 6.启动与关闭... 4 7.安装ruby rubygems. 4 8.初始化集群... 4 注:本例操作系统为Red Hat Enterprise Linux Server release 6.4 1.配置yum 未注册的Redhat不支持yum,调整步骤: cd /etc/yum.rep

使用kubeadm平滑地升级kubenetes集群(v1.10.2到v1.10.3)

写在前面 kubernetes是目前最炙手火热的容器管理.调度.编排平台,不仅拥有全面的生态系统,而且还开源.开放自治,谁贡献的多,谁的话语权就大,云提供商都有专门的工程师来从事kubernetes开源项目,其软件的升级迭代非常快,今天我们就来谈谈如何使用kubeadm平滑地升级kubenetes集群到v1.10.3. 备注:kubeadm是一个快速构建kubernetes集群的工具. 查看目前集群版本 从上面可以看到,master节点kubelete版本低于woker节点,kubernetes

Centos6下安装伪分布式Hadoop集群

Centos6下安装伪分布式hadoop集群,选取的hadoop版本是apache下的hadoop2.7.1,在一台linux服务器上安装hadoop后,同时拥有namenode,datanode和secondarynamenode等节点的功能,下面简单安装下. 前置准备 主要涉及防火墙关闭.jdk安装.主机名修改.ip映射.免密登录设置等. 关闭防火墙 有临时和永久,这里使用永久关闭的方式. # 临时关闭 [[email protected] ~]# service iptables stop

在CentOS下安装Ngix服务及集群PHP、Tomcat

资源下载地址:http://download.csdn.net/detail/attagain/7570597 一. Ngix依赖模块安装 Ngix依赖模块有:pcre.zlib.openssl.md5 /sha1(如果系统中没有安装相应模块,需要按照下列方式安装) 1. 安装pcre模块(8.35) 官方网站:http://www.pcre.org/ 安装命令: # unzip pcre-8.35.zip # cd pcre-8.35 # ./configure # make && ma

基于CentOS与VmwareStation10搭建Oracle11G RAC 64集群环境:3.安装Oracle RAC-3.6.集群管理命令

3.6. 集群管理命令 3.6.1. RAC的启动与关闭 oracle rac默认会开机自启动,如需维护时可使用以下命令: 关闭: crsctl stop cluster 停止本节点集群服务 crsctl stop cluster –all 停止所有节点服务 开启: crsctl start cluster 开启本节点集群服务 crsctl stop cluster –all 开启所有节点服务 注:以上命令需以 root用户执行 3.6.2.RAC检查运行状况 以grid 用户运行 [[emai

使用docker安装elasticsearch伪分布式集群

docker安装elasticsearch伪分布式集群 0.在安装es之前,首先编辑一下宿主机的内核参数,否则配置es集群的时候极有可能启动不成功: [[email protected] ~]# vim /etc/sysctl.conf vm.max_map_count=655360 [[email protected] ~]# sysctl -p # 加载参数 1.搜索es的镜像,如下第一个就是官方镜像: 2.拉取镜像: [[email protected] ~]# docker pull e

kubeadm安装Kubernetes1.15安装部署详解-Part 1

简介: Kubernetes最初源于谷歌内部的Borg,提供了面向应用的容器集群部署和管理系统.Kubernetes的目标旨在消除编排物理/虚拟计算,网络和存储基础设施的负担,并使应用程序运营商和开发人员完全将重点放在以容器为中心的原语上进行自助运营.Kubernetes 也提供稳定.兼容的基础(平台),用于构建定制化的workflows 和更高级的自动化任务. Kubernetes 具备完善的集群管理能力,包括多层次的安全防护和准入机制.多租户应用支撑能力.透明的服务注册和服务发现机制.内建负