The role of Kubernetes and Docker is not introduced here, directly into the subject.
The purpose of this article is to build Docker clusters and use kubernetes to manage them.
In addition to Kubernetes and Docker, the software environment in this paper also uses ETCD and flannel. The ETCD service runs on the master machine and is used with flannel on the Minion machine to make each minion run on the
Docker has different IP segments, and the ultimate goal is to have a Docker Containner running on different minion have one with any other Containner (Docker Containner running on another minion)
The same IP address. If you don't understand, you can search the Internet for ETCD and flannel.
Environment:
CENTOS7 System Machine Three:
192.168.50.130: Used to install Kubernetes Master
192.168.50.131: Used as kubernetes minion (Minion1)
192.168.50.132: Used as kubbernetes minion (Minion2)
One, shut down the system running firewall
If the system has a firewall turned on, follow the steps below to turn off the firewall (all machines)
# systemctl Stop firewalld# systemctl disable FIREWALLD
Second, master installation configuration
1. Install and configure Kubernetes Master (yum mode)
Yum Install Etcd kubernetes
Configure ETCD, edit/etc/etcd/etcd.conf. Make sure that the listed items are configured correctly and are not commented out, as shown in the following configuration
Etcd_name=defaultetcd_data_dir= "/var/lib/etcd/default.etcd" etcd_listen_client_urls= "http://0.0.0.0:2379" ETCD_ Advertise_client_urls= "http://localhost:2379"
Configure Kubernetes, edit/etc/kubernetes/apiserver
kube_api_address= "--address=0.0.0.0" kube_api_port= "--port=8080" kubelet_port= "--kubelet_port=10250" KUBE_ETCD_ servers= "--etcd_servers=http://127.0.0.1:2379" kube_service_addresses= "--service-cluster-ip-range=10.254.0.0/16 "Kube_admission_control="--admission_control=namespacelifecycle,namespaceexists,limitranger, Securitycontextdeny,resourcequota "Kube_api_args=" "
2. Start Etcd, Kube-apiserver, Kube-controller-manager and Kube-scheduler services
for inch Do systemctl Restart $SERVICES systemctl enable $SERVICES done
3. ETCD settings (which will be automatically obtained by the flannel running on Minion and used to set the IP address of Docker)
' {"Network": "172.17.0.0/16"} '
Tips:/coreos.com/network/config is just a configuration item name, no need to worry
4. Now that the master configuration is complete, run Kubectl get nodes to see how many Minion are running and their status. Here our minion haven't started to install the configuration, so the result is empty after running
# Kubectl Get nodesname LABELS STATUS
Three, Minion installation configuration (each Minion machine is installed according to the following configuration)
1. Installation and configuration of the environment
Yum Install Docker-engine flannel kubernetes
Configure flannel, edit/etc/sysconfig/flanneld
Flannel_etcd= "http://192.168.50.130:2379"
Configure Kubernetes, edit/etc/kubernetes/config
Kube_master= "--master=http://192.168.50.130:8080"
Configure Kubernetes, edit/etc/kubernetes/kubelet (please use each Minion own IP address such as: 192.168.50.131 instead of the following $localip)
kubelet_address= "--address=0.0.0.0" kubelet_port= "--port=10250" # Change the hostname to this host ' s IP addresskubelet_ Hostname= "--hostname_override= $LOCALIP" kubelet_api_server= "--api_servers=http://192.168.50.130:8080" KUBELET_ Args= ""
2. Prepare to start the service (if you have already run Docker on the machine, please look over it, ignore this step)
Run Ifconfig to see the network configuration of the machine (with DOCKER0)
#ifconfigDocker0 Link encap:ethernet HWaddr Geneva: the: B2: the: 2E: theinet Addr:172.17.0.1Bcast:0.0.0.0Mask:255.255.0.0Up Broadcast multicast MTU: theMetric:1RX Packets:0Errors0Dropped0Overruns:0Frame0TX Packets:0Errors0Dropped0Overruns:0Carrier0Collisions:0Txqueuelen:0
RX bytes:0(0.0B) TX Bytes:0(0.0B)
WARNING: You can see DOCKER0 on a machine running Docker, where you need to remove the DOCKER0 configuration before starting the service, and run at the command line: sudo IP link delete docker0
The purpose of this is to restart Docker by flannel assigning address segments to Docker.
3. Start the service
for inch Do systemctl Restart $SERVICES systemctl enable $SERVICES done
Tips: Here I come across a strange problem, starting the Kubelet service or the flannel service can be problematic and cannot be started if you encounter a similar problem. You can try uninstalling Kubernetes, reinstalling the configuration
That's what I'm dealing with, re-faking it. ^_^
Iv. Configuration Complete Verification Installation
Determine that two minion (192.168.50.131 and 192.168.50.132) and one master (192.168.50.130) have successfully installed the configuration and that the service has been started.
Switch to master machine, Run command Kubectl get nodes
# Kubectl Get Nodesname LABELS STATUS192.168. 50.131 kubernetes.io/hostname=192.168. 50.131 Ready192.168. 50.132 kubernetes.io/hostname=192.168. 50.132 Ready
You can see that the two Minion configured are already in the node list of master. If you want more node, just follow the Minion configuration and configure more machines.
A docker cluster managed by Kubernetes has been configured to do so. The following article will write about Kubernetes control minion running Docker container, about kubernetes of pod,replication Controller (RC), some things of service.
Kubernetes+docker+centos7