参考,https://github.com/qxl1231/2019-k8s-centos
本人在搭建的过程中遇到的主要问题是镜像的下载,需要将教程中的镜像下载改为如下:

master端:
#!/bin/bash
images=(
    kube-apiserver:v1.16.0
    kube-controller-manager:v1.16.0
    kube-scheduler:v1.16.0
    kube-proxy:v1.16.0
    pause:3.1
    etcd:3.3.15-0
    coredns:1.6.2

    pause-amd64:3.1

    kubernetes-dashboard-amd64:v1.10.0
    heapster-amd64:v1.5.4
    heapster-grafana-amd64:v5.0.4
    heapster-influxdb-amd64:v1.5.2
)

for imageName in ${images[@]} ; do
    docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/$imageName
    docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/$imageName k8s.gcr.io/$imageName
    docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/$imageName
done

node端
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.16.0
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1

docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.16.0 k8s.gcr.io/kube-proxy:v1.16.0
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1 k8s.gcr.io/pause:3.1

docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.16.0
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1

kubeadm init --apiserver-advertise-address 192.168.153.100 --pod-network-cidr 10.244.0.0/16

放上常用到的命令

192.168.153.100 master
192.168.153.101 node1
192.168.153.102 node2
192.168.153.103 node3
192.168.153.104 node4
192.168.153.105 node5

k8s.gcr.io/kube-apiserver:v1.16.0
k8s.gcr.io/kube-controller-manager:v1.16.0
k8s.gcr.io/kube-scheduler:v1.16.0
k8s.gcr.io/kube-proxy:v1.16.0
k8s.gcr.io/pause:3.1
k8s.gcr.io/etcd:3.3.15-0
k8s.gcr.io/coredns:1.6.2

master端:
#!/bin/bash
images=(
    kube-apiserver:v1.16.0
    kube-controller-manager:v1.16.0
    kube-scheduler:v1.16.0
    kube-proxy:v1.16.0
    pause:3.1
    etcd:3.3.15-0
    coredns:1.6.2

    pause-amd64:3.1

    kubernetes-dashboard-amd64:v1.10.0
    heapster-amd64:v1.5.4
    heapster-grafana-amd64:v5.0.4
    heapster-influxdb-amd64:v1.5.2
)

for imageName in ${images[@]} ; do
    docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/$imageName
    docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/$imageName k8s.gcr.io/$imageName
    docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/$imageName
done

node端
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.16.0
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1

docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.16.0 k8s.gcr.io/kube-proxy:v1.16.0
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1 k8s.gcr.io/pause:3.1

docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.16.0
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1

kubeadm init --apiserver-advertise-address 192.168.153.100 --pod-network-cidr 10.244.0.0/16

scp Groceries.txt  [email protected]:/data/tw
scp $HOME/.kube/config root@node3:$HOME/.kube/

kubeadm join 192.168.153.100:6443 --token 5dmdy6.mivy7w3hyocxtl4d\
    --discovery-token-ca-cert-hash sha256:f164696e544a3bea116a7aa805fcc6da75c488ae471c025ec5dc5ab34792e7ae

yum remove kubelet kubeadm kubectl

常用命令
kubectl get nodes
kubectl get pods --all-namespaces
kubectl delete node node3
kubeadm reset
kubeadm token create
02-11 10:22