Before installation, the three CENTOS7 servers are banned from the firewall, and the mirror that needs to be started 2 node machines must be kept consistent, otherwise the pod will not start
1 has three CENTOS7 servers: 10.1.1.170 (Master), 10.1.1.169 node1,10.1.1.171 Node2
2 Install NTP service on three machines to ensure all time can be synchronized
#yum-y Install NTP
#systemctl Start NTPD
#systemctl Enable NTPD
3 Installing Kubernetes Master on 10.1.1.170
Yum Install ETCD
Yum Install Kubernetes
Cd/etc/etcd
Vi etcd.conf, need to note:
Etcd_name=default
Etcd_data_dir= "/var/lib/etcd/default.etcd"
Etcd_listen_client_urls= "http://0.0.0.0:2379"
* cd/etc/kubernetes/
* VI Apiserver
[Email protected] kubernetes]# more Apiserver
###
# kubernetes System Config
#
# The following values is used to configure the Kube-apiserver
#
# The address on the local server to listen.
#KUBE_API_ADDRESS = "--insecure-bind-address=127.0.0.1"
Kube_api_address= "--address=0.0.0.0"
# The port is on the local server to listen.
Kube_api_port= "--port=8080"
# Port Minions Listen on
Kubelet_port= "--kubelet-port=10250"
# Comma separated list of nodes in the ETCD cluster
Kube_etcd_servers= "--etcd-servers=http://127.0.0.1:2379"
# Address range to use for services
Kube_service_addresses= "--SERVICE-CLUSTER-IP-RANGE=10.254.0.0/16"
# Default Admission Control policies
#KUBE_ADMISSION_CONTROL = "--admission-control=namespacelifecycle,namespaceexists,limitranger, Securitycontextdeny,serviceaccount,resourcequota "
Kube_admission_control= "--admission-control=namespacelifecycle,namespaceexists,limitranger,resourcequota"
# ADD Your own!
Kube_api_args= ""
* Cd/etc/kubernetes
* VI Controller-manager definition node
[Email protected] kubernetes]# more Controller-manager
###
# The following values is used to configure the Kubernetes Controller-manager
# defaults from config and apiserver should be adequate
# ADD Your own!
Kube_controller_manager_args= ""
Kubelet_addresses= "--machine=10.1.1.169,10.1.1.171"
* Start the service in turn and put the service into the startup directory (Etcd\kube-apiserver\kube-controller-manager\kube-scheduler):
Systemctl Restart Service Name
Systemctl Enable service Name
Systemctl Status Service Name
* Define flannel network configuration to ETCD, configuration is pushed to flannel network of each Minions
Etcdctl mk/coreos.com/network/config ' {"Network": "172.17.0.0/16"} '
4 Minions deployment on a node (10.1.1.169,10.1.1.171)
#yum Install Flannel
#yum Install Kubernetes
* Modify the flannel configuration file to use the ETCD service
#vi/etc/sysconfig/flanneld
[Email protected] ~]# More/etc/sysconfig/flanneld
# Flanneld configuration options
# ETCD URL location. Point the server where ETCD runs
Flannel_etcd= "http://10.1.1.170:2379"
# ETCD config key. This is the configuration key, that flannel queries
# for Address range assignment
flannel_etcd_key= "/atomic.io/network"
# any additional options-want to pass
#FLANNEL_OPTIONS = ""
* Configure Kubernetes configuration file
#vi/etc/kubernetes/config
[Email protected] kubernetes]# More/etc/kubernetes/config
###
# kubernetes System Config
#
# The following values is used to configure various aspects of all
# Kubernetes Services, including
#
# Kube-apiserver.service
# Kube-controller-manager.service
# Kube-scheduler.service
# Kubelet.service
# Kube-proxy.service
# Logging to stderr means we get it in the SYSTEMD journal
Kube_logtostderr= "--logtostderr=true"
# Journal message level, 0 is debug
Kube_log_level= "--v=0"
# Should this cluster is allowed to run privileged Docker containers
kube_allow_priv= "--allow-privileged=false"
# How the Controller-manager, scheduler, and proxy find the Apiserver
Kube_master= "--master=http://10.1.1.170:8080"
* Configure Kubelet Service
#vi/etc/kubernetes/kubelet
[Email protected] kubernetes]# More/etc/kubernetes/kubelet
###
# kubernetes Kubelet (Minion) config
# The address for the info server to serve in (set to 0.0.0.0 or "" for all Interfaces)
Kubelet_address= "--address=10.1.1.171"
# The port for the info server to serve on
Kubelet_port= "--port=10250"
# Leave this blank to use the actual hostname
Kubelet_hostname= "--hostname-override=10.1.1.171"
# Location of the Api-server
Kubelet_api_server= "--api-servers=http://10.1.1.170:8080"
# POD Infrastructure container
Kubelet_pod_infra_container= "--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
# ADD Your own!
Kubelet_args= ""
* Start Service (Kube-proxy\kubylet\docker\flanneld), very strange to start flanneld service times wrong, but after a while k8s everything OK
#systemctl Restart Services
#system Enable service
#systemctl Status Service
5 SSH password-free operation for three machines:
#ssh-keygen
#ssh-copy-id [email protected]
#ssh-copy-id [email protected]
6 Test kubernetes Service is normal
[[email protected] kubernetes]# Kubectl get nodes
NAME LABELS STATUS Age
10.1.1.169 kubernetes.io/hostname=10.1.1.169 Ready 20h
10.1.1.171 kubernetes.io/hostname=10.1.1.171 Ready 21h
[[email protected] kubernetes]# Kubectl get componentstatuses
NAME STATUS MESSAGE ERROR
Controller-manager Healthy OK Nil
Scheduler Healthy OK Nil
etcd-0 Healthy {"Health": "True"} Nil
Kubectl run Tomcat--image=tomcat:8.0--port=8080--replicas=5
[[email protected] kubernetes]# Kubectl get Rc,pods
CONTROLLER CONTAINER (s) IMAGE (s) SELECTOR replicas age
Centos7 centos7 centos:7 run=centos7 3 59m
MySQL MySQL mysql:5.5 run=mysql 7 1h
Tomcat Tomcat tomcat:8.0 Run=tomcat 5 19h
NAME Ready STATUS Restarts
centos7-asa0g 1/1 Running 59m
centos7-eow3g 0/1 Crashloopbackoff 59m
CENTOS7-QMSLB 0/1 Crashloopbackoff 59m
MYSQL-0A5TV 0/1 Crashloopbackoff 1h
MYSQL-131LH 0/1 Crashloopbackoff 1h
Mysql-7cj2s 0/1 Crashloopbackoff 1h
mysql-89h04 0/1 Crashloopbackoff 1h
Mysql-htu4u 0/1 Crashloopbackoff 1h
MYSQL-KHNDM 0/1 Crashloopbackoff 1h
MYSQL-UKE1C 0/1 Crashloopbackoff 1h
TOMCAT-1WWBN 1/1 Running 1 19h
TOMCAT-F83Z1 1/1 Running 1 19h
TOMCAT-FU2QF 1/1 Running 1 19h
Tomcat-l39ih 1/1 Running 1 19h
tomcat-o647v 1/1 Running 1 19h
On both nodes, you can find 2 tomcat running on one node, 3 tomcat running on one node, and once a mirror is deleted, a new node is started immediately.
This article is from the "old section of the Cultivation of Life" blog, please be sure to keep this source http://031028.blog.51cto.com/9866455/1837198
CENTOS7 kubernetes Installation Manual