There are several ways to install kubenetes, and this article will show you how to install Kubernetes with Kubeadm.
One node ready
1/etc/hosts file
192.168.235.133 kube01192.168.235.134 kube02192.168.235.135 kube03
2 Close Swap
Note Swap mounts in the/etc/fstab
#/dev/mapper/centos-swap swap swap defaults 0 0
3 Modifying kernel parameters
Cat <<eof >/etc/sysctl.d/k8s.confnet.bridge.bridge-nf-call-ip6tables = 1net.bridge.bridge-nf-call-iptables = 1EOFsysctl--system
4 Installing Docker
Yum Install Docker-ysystemctl enable Dockersystemctl start Docker
Two mounting Kubeadm
1 increasing the repo of Yum
Cat <<eof >/etc/yum.repos.d/kubernetes.repo[kubernetes]name=kubernetesbaseurl=https:// packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64enabled=1gpgcheck=1repo_gpgcheck=1gpgkey=https:// PACKAGES.CLOUD.GOOGLE.COM/YUM/DOC/YUM-KEY.GPG Https://packages.cloud.google.com/yum/doc/rpm-package-key.gpgEOF
2 installation
Setenforce 0yum install-y kubelet kubeadm kubectlsystemctl enable Kubelet && systemctl start Kubelet
Three use Kubeadm to install kubenetes cluster
1 initialization with Kubeadm
Run on the master node:
Kubeadm init >--pod-network-cidr=10.244.0.0/16 >--apiserver-advertise-address=192.168.235.133
Installation Complete:
Your Kubernetes Master has initialized successfully! To start using your cluster, you need to run the following as a regular user:mkdir-p $HOME/.kubesudo cp-i/etc/kubernete s/admin.conf $HOME/.kube/configsudo chown $ (id-u): $ (id-g) $HOME/.kube/configyou should now deploy a pod network to the C Luster. Run "Kubectl apply-f [Podnetwork].yaml" with one of the options listed At:https://kubernetes.io/docs/concepts/cluster-ad Ministration/addons/you can now joins any number of machines by running the following on each Nodeas Root:kubeadm join 192. 168.235.133:6443--token 8ojndu.qaow6tuo95psar5g--discovery-token-ca-cert-hash sha256 : 79c955c758bd76f02335c33540f3880039bcf9aa137c9b67366a990ccefbaead
2 Installing Pod Netwok
Mkdir-p ~/K8S/CD ~/k8swget https://raw.githubusercontent.com/coreos/flannel/master/Documentation/ Kube-flannel.ymlkubectl apply-f kube-flannel.yml
3 adding Node2 and Node3 to the cluster
Kubeadm Join 192.168.235.133:6443--token 8ojndu.qaow6tuo95psar5g--discovery-token-ca-cert-hash sha256 : 79c955c758bd76f02335c33540f3880039bcf9aa137c9b67366a990ccefbaead
Observe on the master node:
[[email protected] k8s]# kubectl get nodesname STATUS ROLES age VERSIONkube01 Ready Master 23m V1.10.2kube02 ready <non e> 5m v1.10.2kube03 Ready <none> 5m v1.10.2
Summarize:
The Kubernetes cluster can be easily installed using KUBEADM.
Installing Kubernetes with Kubeadm