分别登陆到三台机器上执行脚本文件
[root@centos7-a bin]# ./etcd.sh etcd01 10.10.10.128 etcd01=https://10.10.10.128:2380,etcd02=https://10.10.10.129:2380,etcd03=https://10.10.10.130:2380 [root@centos7-b bin]# ./etcd.sh etcd02 10.10.10.129 etcd01=https://10.10.10.128:2380,etcd02=https://10.10.10.129:2380,etcd03=https://10.10.10.130:2380 [root@centos7-c bin]# ./etcd.sh etcd03 10.10.10.130 etcd01=https://10.10.10.128:2380,etcd02=https://10.10.10.129:2380,etcd03=https://10.10.10.130:2380验证集群是否是健康的
### 3.4.9 [root@centos7-a ~]# ETCDCTL_API=3 etcdctl --write-out="table" --cacert=http://www.likecs.com/opt/etcd/ssl/ca.pem --cert=http://www.likecs.com/opt/etcd/ssl/server.pem --key=http://www.likecs.com/opt/etcd/ssl/server-key.pem --endpoints=https://10.10.10.128:2379,https://10.10.10.129:2379,https://10.10.10.130:2379 endpoint health +---------------------------+--------+-------------+-------+ | ENDPOINT | HEALTH | TOOK | ERROR | +---------------------------+--------+-------------+-------+ | https://10.10.10.128:2379 | true | 31.126223ms | | | https://10.10.10.129:2379 | true | 28.698669ms | | | https://10.10.10.130:2379 | true | 32.508681ms | | +---------------------------+--------+-------------+-------+查看集群成员
[root@centos7-a ~]# ETCDCTL_API=3 etcdctl --write-out="table" --cacert=http://www.likecs.com/opt/etcd/ssl/ca.pem --cert=http://www.likecs.com/opt/etcd/ssl/server.pem --key=http://www.likecs.com/opt/etcd/ssl/server-key.pem --endpoints=https://10.10.10.128:2379,https://10.10.10.129:2379,https://10.10.10.130:2379 member list +------------------+---------+--------+---------------------------+---------------------------+------------+ | ID | STATUS | NAME | PEER ADDRS | CLIENT ADDRS | IS LEARNER | +------------------+---------+--------+---------------------------+---------------------------+------------+ | 2cec243d35ad0881 | started | etcd02 | https://10.10.10.129:2380 | https://10.10.10.129:2379 | false | | c6e694d272df93e8 | started | etcd03 | https://10.10.10.130:2380 | https://10.10.10.130:2379 | false | | e9b57a5a8276394a | started | etcd01 | https://10.10.10.128:2380 | https://10.10.10.128:2379 | false | +------------------+---------+--------+---------------------------+---------------------------+------------+给 etcdctl创建别名,三台机器分别执行
vim .bashrc alias etcdctl2="ETCDCTL_API=2 etcdctl --ca-file=http://www.likecs.com/opt/etcd/ssl/ca.pem --cert-file=http://www.likecs.com/opt/etcd/ssl/server.pem --key-file=http://www.likecs.com/opt/etcd/ssl/server-key.pem --endpoints=https://10.10.10.128:2379,https://10.10.10.129:2379,https://10.10.10.130:2379" alias etcdctl3="ETCDCTL_API=3 etcdctl --cacert=http://www.likecs.com/opt/etcd/ssl/ca.pem --cert=http://www.likecs.com/opt/etcd/ssl/server.pem --key=http://www.likecs.com/opt/etcd/ssl/server-key.pem --endpoints=https://10.10.10.128:2379,https://10.10.10.129:2379,https://10.10.10.130:2379" source .bashrc 3.3 安装 k8s 相关组件 3.3.1 下载二进制安装包 [root@centos7-nginx ~]# mkdir k8s-1.18.3 && cd k8s-1.18.3/ [root@centos7-nginx k8s-1.18.3]# wget https://dl.k8s.io/v1.18.3/kubernetes-server-linux-amd64.tar.gz [root@centos7-nginx k8s-1.18.3]# tar xf kubernetes-server-linux-amd64.tar.gz [root@centos7-nginx k8s-1.18.3]# cd kubernetes [root@centos7-nginx kubernetes]# ll 总用量 33092 drwxr-xr-x. 2 root root 6 5月 20 21:32 addons -rw-r--r--. 1 root root 32587733 5月 20 21:32 kubernetes-src.tar.gz -rw-r--r--. 1 root root 1297746 5月 20 21:32 LICENSES drwxr-xr-x. 3 root root 17 5月 20 21:27 server [root@centos7-nginx kubernetes]# cd server/bin/ [root@centos7-nginx bin]# ll 总用量 1087376 -rwxr-xr-x. 1 root root 48128000 5月 20 21:32 apiextensions-apiserver -rwxr-xr-x. 1 root root 39813120 5月 20 21:32 kubeadm -rwxr-xr-x. 1 root root 120668160 5月 20 21:32 kube-apiserver -rw-r--r--. 1 root root 8 5月 20 21:27 kube-apiserver.docker_tag -rw-------. 1 root root 174558720 5月 20 21:27 kube-apiserver.tar -rwxr-xr-x. 1 root root 110059520 5月 20 21:32 kube-controller-manager -rw-r--r--. 1 root root 8 5月 20 21:27 kube-controller-manager.docker_tag -rw-------. 1 root root 163950080 5月 20 21:27 kube-controller-manager.tar -rwxr-xr-x. 1 root root 44032000 5月 20 21:32 kubectl -rwxr-xr-x. 1 root root 113283800 5月 20 21:32 kubelet -rwxr-xr-x. 1 root root 38379520 5月 20 21:32 kube-proxy -rw-r--r--. 1 root root 8 5月 20 21:28 kube-proxy.docker_tag -rw-------. 1 root root 119099392 5月 20 21:28 kube-proxy.tar -rwxr-xr-x. 1 root root 42950656 5月 20 21:32 kube-scheduler -rw-r--r--. 1 root root 8 5月 20 21:27 kube-scheduler.docker_tag -rw-------. 1 root root 96841216 5月 20 21:27 kube-scheduler.tar -rwxr-xr-x. 1 root root 1687552 5月 20 21:32 mounter