Kubeadm installation
kubeadm is Kubernetes official tool for quick installation Kubernetes cluster, along Kubernetes each version release will be updated simultaneously, some of the practical aspects of the cluster configuration kubeadm have to make adjustments, you can learn to cluster configuration Kubernetes official in experiments kubeadm Some new best practices.
Installation Docker ce
Docker install
each machine needs to be filled
Preparing the Environment
Edit correspondence between hosts
cat <<EOF >>/etc/hosts
192.168.37.61 Smile1
192.168.37.62 Smile2
192.168.37.63 Smile3
EOF
Turn off the firewall
systemctl stop firewalld.service
systemctl disable firewalld.service
Disable SELINUX
sudo setenforce 0
sed -i "s/^SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
Close swap
swapoff -a
sed -i 's/.*swap.*/#&/' /etc/fstab
Add the following kernel configuration parameters
cat > /etc/sysctl.d/k8s.conf <<EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF
The source yum configuration K8S
cat <
[Kubernetes]
name = Kubernetes
baseurl =
http://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64
enabled = 1
gpgcheck = 0
repo_gpgcheck = 0
gpgkey =
http://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
http://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
EOF
Installation kubelet, kubeadm, kubectl
yum makecache fast
yum install -y kubelet kubeadm kubectl
Adjust the startup mode
kubelet boot environment variables to be like the docker's drive cgroup-driver
docker info | grep -i cgroup
Cgroup Driver: cgroupfs --> 运行命令显示
docker's cgroup-driver is cgroupfs, and k8s default systemd
modify docker of cgroup-driver
vim /etc/docker/daemon.json
加入内容 : { "exec-opts": ["native.cgroupdriver=systemd"] }
The final contents of the file
{
"registry-mirrors": [
"https://dockerhub.azk8s.cn",
"https://reg-mirror.qiniu.com"
],
"exec-opts": ["native.cgroupdriver=systemd"]
}
Restart Docker
systemctl restart docker
systemctl status docker
Start kubelet Service
systemctl enable kubelet.service
systemctl start kubelet.service
Configuring Master Node
Be kubernetes cluster initialization
Master node Run:
kubeadm the init = --kubernetes-Version 1.15.0
--apiserver-advertise-address 192.168.37.61 =
--image-Repository = gcr.azk8s.cn / google_containers
--pod-Network-CIDR = 10.244. 0.0 / 16 --token-ttl 0
--kubernetes-version: specify the version number
--apiserver-advertise-address: Specifies the host address
in which image-repository This step is very important, kubeadm default from the official website k8s.grc.io download the required image, domestic inaccessible, requiring Ali cloud or other designated domestic warehouse mirror address.
The segment is defined POD: 10.244.0.0/16,
It will return the following message after successful initialization
//这个返回信息三条命令是配置kubectl工具的命令
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
// 这个返回信息是配置Node节点的命令
kubeadm join 192.168.98.230:6443 --token dexs09.ftjp7y7obq6a3t6n \
--discovery-token-ca-cert-hash sha256:4aace846f8a6c381902592049591152fd7250b63e500e370a4b64902d202f7f2
Configuration tool kubectl
After a successful return to the initialization run three commands
Network deployment pod
There are many Reference
We chose flannel , several others may be a problem
wget https://raw.githubusercontent.com/coreos/flannel/a70459be0084506e4ec919aa1c114638878db11b/Documentation/kube-flannel.yml
//在kube-flannel.yml里面默认的镜像下载地址是quay.io,国内无法访问,这里替换所有的quay.io为 quay-mirror.qiniu.com
sed -i "s/quay.io/quay-mirror.qiniu.com/g" kube-flannel.yml
The installation command
kubectl apply -f kube-flannel.yml
View the running status
kubectl get pod --all-namespaces -o wide
Make sure that all of the pod are in the running state
Node node deployment
All of the node cluster node is added to kubernets
//在Node节点上执行(这个命令就是集群初始化之后的返回信息)
kubeadm join 192.168.98.230:6443 --token dexs09.ftjp7y7obq6a3t6n \
--discovery-token-ca-cert-hash sha256:4aace846f8a6c381902592049591152fd7250b63e500e370a4b64902d202f7f2
Status of each node in the cluster is detected last
kubectl get nodes
View the status of each pod again, to ensure that all state in Runing
kubectl get pod --all-namespaces -o wide
If you have a problem, reconfigure the Master
kubeadm reset