Here, I'll show you how to install a kubernetes cluster that contains 1 Master 2 minions.
Environmental requirements:
CENTOS7 64-bit system three machines
master:192.168.5.131
minions:192.168.5.132
minions:192.168.5.133
Components of the Kubernetes:
Etcd
Flannel
Kube-apiserver
Kube-controller-manager
Kube-scheduler
Kubelet
Kube-proxy
First, deploy to Centos7
The figure is then furnished
Prerequisite
Each machine disables iptables to avoid iptables conflicts with Docker:
$ systemctl Stop firewalld$ systemctl disable FIREWALLD
2. Install NTP and ensure normal operation
$ yum-y Install ntp$ systemctl start ntpd$ systemctl enable NTPD
3.2 x Minions machine installation Docker
Yum Install Docker-yyum Update-yreboot
CentOS system, using Devicemapper as the storage backend, the initial installation of Docker will use loopback, causing Docker boot error. Need to update before starting
PS Aux|grep Docker results are as follows
/usr/bin/docker-d--selinux-enabled--storage-driver devicemapper--storage-opt dm.fs=xfs--storage-opt Dm.thinpooldev=/dev/mapper/volgroup00-docker--pool
Second, install Kubernetes Master
The following steps are performed on master
Installing ETCD and kubernetes through Yum
Yum-y Install ETCD kubernetes
2. Modify the configuration file/etc/etcd/etcd.conf, make sure ETCD listens to all addresses, modify the following:
Etcd_name=defaultetcd_data_dir= "/var/lib/etcd/default.etcd" etcd_listen_client_urls= "http://0.0.0.0:2379"
3. Modify the configuration file/etc/kubernetes/apiserver, as follows:
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= "--PORTAL_NET=10.254.0.0/16" KUBE_ Admission_control= "--admission_control=namespaceautoprovision,limitranger,resourcequota" KUBE_API_ARGS= ""
4. Modify the configuration file /etc/kubernetes/controller-manager, define the Minions IP address
Kubelet_addresses= "--machines=192.168.5.132,192.168.5.133"
5. Start the service
For SERVICES in Etcd kube-apiserver Kube-controller-manager Kube-scheduler; Do systemctl restart $SERVICES systemctl enable $SERVICES systemctl status $SERVICES done
6. Define flannel network configuration to ETCD, this configuration will be pushed to the flannel service of each Minions
Etcdctl mk/coreos.com/network/config ' {"Network": "172.17.0.0/16"} '
Third, installation Minions
The following operations are performed on MINIONS1,MINIONS2
Installing flannel and Kubernetes
Yum-y Install flannel Kubernetes
2. Configure flannel for the ETCD service, modify the configuration file /etc/sysconfig/flanneld
Flannel_etcd= "http://192.168.5.131:2379"
3. Modify the Kubernetes configuration file to specify master. /etc/kubernetes/config
Kube_master= "--master=http://192.168.5.131:8080"
4. Configure the Kubelet service. /etc/kubernetes/kubelet
MINIONS1:
# # # # Kubernetes Kubelet (Minion) config# the address for the info server to serve on (set to 0.0.0.0 or "" for all Interfa CES) kubelet_address= "--address=192.168.5.132" # the port for the info server to serve onkubelet_port= '--port=10250 ' # you M Ay leave this blank to use the actual hostnamekubelet_hostname= '--hostname_override=192.168.5.132 ' # location of the Api-se Rverkubelet_api_server= "--api_servers=http://192.168.5.131:8080" # Add your own! Kubelet_args= ""
MINIONS2:
# # # # Kubernetes Kubelet (Minion) config# the address for the info server to serve on (set to 0.0.0.0 or "" for all Interfa CES) kubelet_address= "--address=192.168.5.133" # the port for the info server to serve onkubelet_port= '--port=10250 ' # you M Ay leave this blank to use the actual hostnamekubelet_hostname= '--hostname_override=192.168.5.133 ' # location of the Api-se Rverkubelet_api_server= "--api_servers=http://192.168.5.131:8080" # Add your own! Kubelet_args= ""
5. Start the service
For SERVICES in Kube-proxy Kubelet Docker Flanneld; Do systemctl restart $SERVICES systemctl enable $SERVICES systemctl status $SERVICES done
6. In each minions can see 2 network cards: Docker0 and Flannel0, the IP of the 2 network cards in different machine IP address is different
Minion1:
IP A | grep Flannel | grep inetinet 172.17.20.0/16 Scope Global Flannel0
Minion2:
$ IP A | grep Flannel | grep inetinet 172.17.21.0/16 Scope Global Flannel0
7. Login Master now to confirm the status of Minions
[[Email Protected]_master ~]# kubectl get nodesname LABELS STATUS192.168.5.132 kubernetes.io/hostname=192.168.5.132 Ready192.168.5.133 kubernetes.io/hostname=192.168.5.133 Ready
That's great! The Kubernetes cluster is configured, so let's get started with the pod.
If there is an error in creating the pod
Is Forbidden:no API token found for service account Default/default, retry after the token is automatically created and a Dded to the service account
If you configure the Apiserver as follows:
# Default Admission Control policies#kube_admission_control= "--admission_control=namespacelifecycle, Namespaceexists,limitranger,securitycontextdeny,serviceaccount,resourcequota "
Need to remove
Securitycontextdeny,serviceaccount
CentOS 7 Installation kubernetes cluster