deployment Environment Description:
1.CENTOS 7.4
2.Docker Version 17.05.0
3,etcd version:3.3.8
4,flannel-v0.10.0
node nodes run :
Kubelet
Kube-proxy
Docker
Flannel
run on the MASTER node :
Etcd
Flannel
Kube-apiserver
Kube-controller-manager
Kube-scheduler
IP Address |
Role |
Cpu |
Memory |
192.168.1.10 |
K8s-master1 |
2 C |
2G |
192.168.1.20 |
K8s-node1 |
2 C |
2G |
192.168.1.30 |
K8s-node2 |
2 C |
2G |
to modify hosts files for each host :
1 , Install the operating system, select Minimize installation , After the installation is complete yum The relevant packages are as follows:
Yum-y install wget ntpdate bind-utils iptables-services
Close Firewall
# systemctl Stop Firewalld.service # Stop Firewall
# systemctl Disable Firewalld.service # disable firewall boot up
# systemctl start Iptables.service # reboot firewall
# Systemctl Enable Iptables.service # set up firewall boot
#iptables-A input-p TCP--dport 4001-m State--state new-j ACCEPT
#iptables-A input-p TCP--dport 2379-m State--state new-j ACCEPT
#iptables-A input-p TCP--dport 2380-m State--state new-j ACCEPT
Turn off selinux
#setenforce 0
[Email protected] ~]# sed-i '/^selinux=/c selinux=disabled '/etc/selinux/config
2 , installation ETCD
git address:https://github.com/coreos/etcd/releases/
ETCD Chinese Document:http://etcd.doczh.cn/documentation/
Download the installation package:https://github.com/coreos/etcd/releases/download/v3.3.8/etcd-v3.3.8-linux-amd64.tar.gz
#tar-ZXVF etcd-v3.3.8-linux-amd64.tar.gz
#ln-S Etcd-v3.3.8-linux-amd64 etcd
#cd ETCD
#cp etcd*/bin/
#etcd--version # Confirm if you can use
#mkdir/ETC/ETCD # Create etcd profile directory
edit The etcd configuration file:vim/etc/etcd/etcd.conf Modify the following , the nodes node according to the IP address of the corresponding modification,
Node2 node, modify the node3 node accordingly
Check cluster health status:etcdctl–endpoints http://192.168.1.10:2379 Cluster-health
Check The node of the ETCD cluster and see if that is the leader node
Etcdctl–endpoints http://192.168.1.10:2379 Member List
3, installation kubernetes yum install kubernetes (master,nodes all need to install)
after the installation is complete, you can modify the configuration file:
configuration file in the /etc/kubernetes directory,MASTER needs to modify The Apiserver config two configuration files, if more than one cluster needs to be modified Controller-manager:
Config configuration can be used to define logs and to have privileged access to hardware on the host --allow-privileged main settings kube_master and kube_etcd_servers
Kube_logtostderr definition Logs the error log to stderr or records in a file
Kube_log_level defining log Levels
Kube_allow_priv whether the privileged container is allowed to run.
The apiserver configuration file is as follows, where the Kube_api_args item, configurable security certificate, is not ignorable
Configure Kube_api_address,kube_api_port,kube_service_addresses in apiserver
Configuring Kubelet configuration Files on node nodes kubelet_address,kubelet_port,KU card ignoring books belet_hostname,kubelet_api_server
5, installation, configuration flannel https://github.com/coreos/flannel/releases/download/v0.10.0/ Flannel-v0.10.0-linux-amd64.tar.gz
after the decompression of the main Flanneld,mk-docker-opts.sh These two files, which Flanneld as the main execution file,sh Scripts are used to generate Docker boot parameters.
The Flanneld needs to be copied to the/usr/bin directory and invoked at startup.
Configure Vim/usr/lib/systemd/system/flanneld.service on all servers
All servers edit the configuration file /etc/sysconfig/flanneld, and set the address of the ETCD.
Add a network configuration record in ETCD that will be used to Flanneld the virtual IP address segment assigned to each Docker and modify as needed the network address segment for DOCKER.
Etcdctl set/coreos.com/network/config ' {"Network": "10.1.0.0/16"} '
Note:the Flanneld will overwrite the Docker0 Bridge, and if the Docker service is already started, you need to stop the Docker service.
start the Flanneld service
Systemctl Restart Flannel
set the IP address of the Docker0 bridge
Source/run/flannel/subnet.env
Ifconfig Docker0 ${flannel_subnet}
Verify that the IP address of the network interface Docker0 belongs to the flannel0 subnet after completion
[[Email protected] ~]# IP A
6. Start Kubernetes\etcd\flannel\docker
start Etcd on master node ( can also be deployed separately ) Flannel systemctl start Kube-apiserver ,Kube-controller-manager ,Kube-scheduler
You can also write a script to start it:
For master in Etcd Flanneld kube-apiserver Kube-controller-manager Kube-scheduler; Do systemctl restart $master; Done
Node nodes start systemctl start flannel kube-proxt , systemctl start Kubelet, systemctl start Docker
For node in Etcd flanneld kube-proxy kubelet docker;do systemctl restart $node;d One
7, verify kubernetes cluster is normal
Kubectl get nodes get all node information
[Email protected] kubernetes]# Kubectl cluster-info
Kubectl describe node D8s-node1 gets detailed information about the nodes, including the node's system configuration,CPU, memory, number of pods that can be created
Kubectl Get namespace
Kubernetes cluster Installation Deployment