kubernatescluster搭建的过程
这篇文章主要讲解了“kubernates cluster搭建的过程”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“kubernates cluster搭建的过程”吧!
贵定ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18980820575(备注:SSL证书合作)期待与您的合作!
如果选择Ubuntu,则建议选择16.04.6版本。因为国内各大镜像上都有针对该版本的k8s,且广泛应用。
安装环境:3台Ubuntu 16.04
Step 1: Install & Enable Docker on both the nodes
# 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
<
{
"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
Step 2: Add the Kubernetes signing key on both the nodes
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
Step 3: Add Xenial Kubernetes Repository on both the nodes
sudo apt-add-repository " deb https://mirrors.aliyun.com/kubernetes/apt/ kubernetes-xenial main"
Step 4: Install Kubeadm
apt-get update
apt-get install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubectl
kubeadm version
Kubernetes Deployment
Step 1: Disable swap memory (if running) on both the nodes
sudo swapoff -a
Step 2: Give Unique hostnames to each node
sudo hostnamectl set-hostname master-node-vm1
sudo hostnamectl set-hostname slave-node-vm2
sudo hostnamectl set-hostname slave-node-vm3
Step3: deploy required docker images for kubernates to each node
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
Step4: Initialize Kubernetes on the master node
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
Step5: Join Kubernetes on the slave node
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
Step6: Check all nodes on master node
kubectl get nodes
感谢各位的阅读,以上就是“kubernates cluster搭建的过程”的内容了,经过本文的学习后,相信大家对kubernates cluster搭建的过程这一问题有了更深刻的体会,具体使用情况还需要大家实践验证。这里是创新互联,小编将为大家推送更多相关知识点的文章,欢迎关注!
本文标题:kubernatescluster搭建的过程
转载源于:http://scyanting.com/article/ipphdi.html