There are several ways to install the Kubernetes cluster, the KUBEADM approach is described earlier, and the manual installation method is described in this article.
The installation environment has 3 VMS on Azure:
HKUBE01:10.0. 1.4 HKUBE02: 10.0. 1.5 Hbube03: 10.0. 1.6
Where hkube01 is the master node, it will install Docker, ETCD, Kubernetes Master, flannel required components;
HKUBE02 and hkube03 are worker nodes and will install Docker, kubernetes node, flannel required components.
The installation process is as follows:
A master node
1 Installing the Software
Yum Install -y docker etcd Kubernetes-master
2 Configuring Boot Docker
Because the Docker-hub site is abroad, the download will be very slow, the Docker download point to the domestic mirror site:
vim/etc/docker/daemon.json{"registry-mirrors": [" registry.docker-cn.com"]}systemctl enable Dockersystemctl start Docker
3 Configuring Startup Etcd
Etcd and zookeeper are similar and are tools for storing key/value.
cd/etc/etcdvim etcd.confetcd_listen_client_urls="http://0.0.0.0:2379" Etcd_name="master"etcd_advertise_client_urls=http:// 10.0.1.4:2379systemctl enable etcdsystemctl start Etcd
4 Configuring Kubernetes
In the/etc/kubernetes directory, there are 4 configuration files:
Apiserver and config two configuration files need to be configured. Controller-manager and Scheduler do not need to be configured.
To configure the apiserver, you need to specify the ETCD address, the port of the Api-server, the address that provides the service, and the IP range of cluster:
vim/etc/kubernetes/apiserverkube_api_port = " --port=8080 " kube_api_address = " --insecure-bind-address=0.0.0.0 " kube_etcd_servers = " --etcd-servers=http://10.0.1.4:2379 " kube_service_addresses = " --service-cluster-ip-range=10.0.0.0/16 " admission_control =namespacelifecycle,namespaceexists,limitranger,resourcequota "
This article does not design kubernetes security issues, so in the Api-server configuration of the Admission_control to remove the security-related content Securitycontextdeny,serviceaccount.
To configure config, you need to specify the address and port of Kubernetes master:
vim/etc/kubernetes/configkube_master="--master=http://10.0.1.4:8080"
5 Starting the Service
Systemctl Enable Kube-apiserver Kube-controller-manager kube-schedulersystemctl start kube-apiserver Kube-controller-manager kube-schedulersystemctl status kube-apiserver Kube-controller-manager Kube-scheduler
Two node nodes
1 Installing the Software
Yum Install-y Docker Kubernetes-node
2 Configuring Boot Docker
Same as Master node:
vim/etc/docker/daemon.json{"registry-mirrors": [" registry.docker-cn.com"]}systemctl enable Dockersystemctl start Docker
3 Configuring Kubelet
There are 3 configuration files under/etc/kubernetes:
Config and kubelet two configuration files need to be configured, proxy is the configuration file of Kube-proxy, it can be left by default.
To configure config, you need to specify the address and port of Kubernetes master:
vim/etc/kubernetes/configkube_master="--master=http://10.0.1.4:8080"
Configure Kubelet to specify its work address, the name of the native registered to master, the address of master, and the port:
vim/etc/kubernetes/kubeletkubelet_address="--address=0.0.0.0"kubelet_ HOSTNAME="--hostname-override=hkube02"kubelet_api_server=" --api-servers=http://10.0.1.4:8080 "
Additionally, the Pod-infrastructure docker image specified by the CentOS Yum Source requires a Redhat certificate, which causes the installation to be unsuccessful. To avoid this problem, we changed the image in Kubelet to a mirror in Docker-hub.
Search First:
Docker Search Pod-infrastructure
Select a change, I chose the last one:
kubelet_pod_infra_container=""
4 Starting the Service
Systemctl Enable Kubelet kube-proxysystemctl start kubelet kube-proxysystemctl status Kubelet kube- Proxy
5 Check
On the master node, view:
Have seen HKUBE02 and HKUBE03 are registered up.
Create a deployment:
Kubectl Run Nginx–image=nginx
Kubectl Scale deployment Nginx--replicas=3
However, the network level pod can only be connected to other pods of this node.
Three networks
This article installs the flannel to enable container interoperability across nodes.
1 installation
Yum Install -y flannel
2 configuration
Configuration of the ETCD:
' {"Network": "192.168.0.0/16"} '
To configure the flannel configuration file:
Vim/etc/sysconfig/flannel
Systemctl Enable Flanneldsystemctl start Flannelsystemctl restart Docker
Turn on forwarding:
Iptables-p FORWARD ACCEPT
At this point you can see that the address of the DOCKER0 is the same as the port address segment of flannel:
3 Verification
To deploy the pod Nginx:
Kubectl run Nginx----replicas=3
Log into the hkube03 and go to the container:
By deploying flannel, you can achieve network interoperability across pods.
Summarize:
On Centos7, the Kubernetes components are installed through Yum to achieve kubernetes cluster deployment.
CENTOS7 manual installation of kubernetes clusters