部署K8S 三.配置master节点 kubeadm

7、配置阿里云docker镜像加速
sudo mkdir -p /etc/docker

sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://dp4f6za4.mirror.aliyuncs.com"]
}
EOF

sudo systemctl daemon-reload && systemctl restart docker

8、配置阿里云Kubernetes 镜像
cat >> /etc/yum.repos.d/kubernetes.repo << EOF
[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版本安装,不指定版本默认安装最新版。
yum install -y kubelet-1.18.0 kubeadm-1.18.0 kubectl-1.18.0
systemctl enable kubelet

kubeadm init \
  --apiserver-advertise-address=192.168.60.136 \
  --image-repository registry.aliyuncs.com/google_containers \
  --kubernetes-version v1.18.0 \
  --service-cidr=10.96.0.0/12 \
  --pod-network-cidr=10.244.0.0/16

mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config

[root@k8s-master ~]# kubectl get nodes
NAME         STATUS     ROLES    AGE    VERSION
k8s-master   NotReady   master   6m8s   v1.18.0

部署CNI网络插件
[root@k8s-master ~]#

wget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

(这一步如果提示无法连接,加条host解析)

vim /etc/hosts

185.199.110.133 raw.githubusercontent.com

kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

验证安装成功

kubectl get pods -n kube-system

 

你可能感兴趣的:(kubernetes,容器,云原生)