您好,登录后才能下订单哦!
这篇文章主要讲解了“kubernates cluster搭建的过程”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“kubernates cluster搭建的过程”吧!
如果选择Ubuntu,则建议选择16.04.6版本。因为国内各大镜像上都有针对该版本的k8s,且广泛应用。
安装环境:3台Ubuntu 16.04
# Install Docker CE
## Set up the repository:
### Install packages to allow apt to use a repository over HTTPS
apt-get update && apt-get install apt-transport-https ca-certificates curl software-properties-common
### Add Docker’s official GPG key
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
### Add Docker apt repository.
add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$( lsb_release -cs ) \
stable"
## Install Docker CE.
apt-get update && apt-get install docker-ce = 18 .06.2~ce~3-0~ubuntu
# Setup daemon.
cat > /etc/docker/daemon.json <<EOF
{
"exec-opts": ["native.cgroupdriver=systemd"],
"log-driver": "json-file",
"log-opts": {
"max-size": "100m"
},
"storage-driver": "overlay2"
}
EOF
mkdir -p /etc/systemd/system/docker.service.d
# Restart docker.
systemctl daemon-reload
systemctl restart docker
systemctl enable docker
docker verision
sudo apt install curl
curl -s https://mirrors.aliyun.com/kubernetes/apt/doc/apt-key.gpg | sudo apt-key add
sudo apt-get update && sudo apt-get install -y apt-transport-https
sudo apt-add-repository " deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main"
apt-get update
apt-get install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubectl
kubeadm version
sudo swapoff -a
sudo hostnamectl set-hostname master-node-vm1
sudo hostnamectl set-hostname slave-node-vm2
sudo hostnamectl set-hostname slave-node-vm3
kubeadm config images list | sed -e 's/^/docker pull /g' -e 's#k8s.gcr.io#docker.io/mirrorgooglecontainers#g' | sh -x
docker images | grep mirrorgooglecontainers | awk '{print "docker tag ", $1 ":" $2 , $1 ":" $2 }' | sed -e 's#mirrorgooglecontainers#k8s.gcr.io#2' | sh -x
docker images | grep mirrorgooglecontainers | awk '{print "docker rmi ", $1 ":" $2 }' | sh -x
docker pull coredns/coredns:1.3.1
docker tag coredns/coredns:1.3.1 k8s.gcr.io/coredns:1.3.1
docker rmi coredns/coredns:1.3.1
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
sudo kubeadm init --kubernetes-version=v1.14.3 --pod-network-cidr=10.244.0.0/16
####check all required containers is running:
kubectl get pods --all-namespaces
after initialize the master node you will see below info
copy the last sentence to slave node to join master node:
kubeadm join 192.168.7.86:6443 --token uedhm1.s9yo055ckphqdw16 --discovery-token-ca-cert-hash sha256:d96d1d924df350fe361082afe1c981c8fb6d2361aa6d1811c8d628b93b90e61d
kubectl get nodes
感谢各位的阅读,以上就是“kubernates cluster搭建的过程”的内容了,经过本文的学习后,相信大家对kubernates cluster搭建的过程这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是亿速云,小编将为大家推送更多相关知识点的文章,欢迎关注!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。