官方文档:
参考:
1. 安装docker
-
curl -sSL | sh
-
cat > /etc/docker/daemon.json <
-
{
-
"registry-mirrors": [""]
-
}
-
EOF
# 在/etc/default/docker中添加
DOCKER_OPTS="--registry-mirror="
systemctl restart docker
2. 安装kubeadm、kubelet、kubectl
-
#!/bin/bash
-
set -e
-
apt-get -y install apt-transport-https ca-certificates curl software-properties-common
-
curl -s | apt-key add -
-
add-apt-repository \
-
"deb \
-
kubernetes-xenial \
-
main"
-
apt-get update
-
apt-get install -y kubelet kubeadm kubectl
-
systemctl enable kubelet && systemctl start kubelet
3. 初始化master节点
-
kubeadm init --pod-network-cidr=192.168.200.0/24 --kubernetes-version=v1.17.3 --image-repository registry.cn-hangzhou.aliyuncs.com/google_containers
成功会显示
kubeadm join 192.168.100.12:6443 --token 7u1jah.da6w4tilh0j5097w \
--discovery-token-ca-cert-hash sha256:bcd0ce4354f2e8b794b830d7a14389b6a06e46e225486ece8218424a1744583
4. 为了可以执行kubectl
-
mkdir -p $HOME/.kube
-
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
-
chown $(id -u):$(id -g) $HOME/.kube/config
5. 安装pod network
-
wget
-
# 什么都不要改,会自动检测出pod ip的范围
-
kubectl create -f calico.yaml
6. 为了让master节点也可以调度pod
-
kubectl taint nodes --all node-role.kubernetes.io/master-
7. 加入worker节点
在worker节点上执行kubeadm init成功后返回的命令,即
-
kubeadm join 192.168.100.12:6443 --token 7u1jah.da6w4tilh0j5097w \
-
--discovery-token-ca-cert-hash sha256:bcd0ce4354f2e8b794b830d7a14389b6a06e46e225486ece8218424a1744583f
阅读(1437) | 评论(0) | 转发(0) |