k8s集群搭建 2019

参考,https://github.com/qxl1231/2019-k8s-centos
事实上k8s集群的搭建很简单,笔者在搭建的过程中遇到的主要问题是镜像无法下载的问题。
如果发现教程中提供的镜像地址无法使用,可以去docker hub搜索,使用对应的镜像地址:
docker hub:https://hub.docker.com
例如:
k8s集群搭建 2019_第1张图片

kubectl常用命令:
https://www.jianshu.com/p/9ce65e37f746
下面是笔者在搭建过程中的笔记:

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

你可能感兴趣的:(k8s集群搭建 2019)