您好,登錄后才能下訂單哦!
這篇文章主要講解了“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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。