One: Introduction
1. What is k8s?
k8s is a docker container management tool
It is a new distributed architecture based container technology-leading solutions, open source cluster management system container.
On the basis of the docker provides operational deployment, resource scheduling, service discovery and dynamic stretching and a series of full functionality of the application container
2 .---- k8s advantages:
a, container arrangement
b, lightweight
c, open source
d, elastically stretchable
e, load balancing
Two: k8s core functionality
1. Self-healing: the failure of the vessel before restarting, when the node is unavailable, replace and re-scheduling containers on the node, container health checks on user-defined response will not be suspended, and ready to serve in the container will not put its the client broadcasts.
Elastically stretchable: cpu load value by monitoring the container, if the average is higher than 80%, increase in the number of containers, if this average number is less than 10% reduction in the container
Automatic discovery of service and load balancing: no need to modify your application to use unfamiliar service discovery mechanism, Kubernetes provides a single DNS name its own IP address and a set of containers to the container, and can load between them balanced.
And a rolling upgrade key rollback: Kubernetes gradually deploy configuration changes to the application or while monitoring application health to ensure that it does not terminate all instances simultaneously. If a problem occurs, Kubernetes changes to your resume, take advantage of the growing eco-system deployment solution.
192.168.175.250 node1
192.168.175.251 node2
configured to etcd master and master node:
ETCD_NAME="etcd"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.175.3:2379"
(2) to start the service
命令:[root@master ~]# systemctl start etcd
Note: etcd communication port using 2379
(3) View Status:
命令:[root@master ~]# systemctl enable etcd
(4) Check the etcd cluster member list, there is only one
命令:[root@master ~]# etcdctl member list
3. Configure master server
(1) Configuration master configuration file
command: [root @ master ~] # vim / etc / kubernetes / config # modify the following profile
KUBE_MASTER="--master=http://192.168.175.3:8080"
(2) Configuration apiserver profile
命令:[root@master ~]# vim /etc/kubernetes/apiserver
KUBE_API_ADDRESS="--insecure-bind-address=0.0.0.0"
KUBE_ETCD_SERVERS="--etcd-servers=http://192.168.175.3:2379"
KUBE_ADMISSION_CONTROL="--admission-control=AlwaysAdmit"
(3)配置 kube-scheduler 配置文件
命令:[root@master ~]# vim /etc/kubernetes/scheduler
KUBE_SCHEDULER_ARGS="0.0.0.0"
4.(1) 配置 etcd,指定容器云中 docker 的 IP 网段
命令:[root@master ~]# etcdctl mkdir /k8s/network
命令:[root@master ~]# etcdctl set /k8s/network/config '{"Network": "10.255.0.0/16"}'
命令:[root@master ~]# etcdctl get /k8s/network/config
(2)设置flanneld服务
命令:[root@master ~]# vim /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS="http://192.168.175.3:2379"
FLANNEL_ETCD_PREFIX="/k8s/network"
FLANNEL_OPTIONS="--iface=ens33" #设置自己的通信物理网卡
命令:[root@master ~]# systemctl restart flanneld #重启服务
(3)检查所有配置
命令:[root@master ~]# cat /run/flannel/subnet.env
FLANNEL_NETWORK=10.255.0.0/16
FLANNEL_SUBNET=10.255.94.1/24
FLANNEL_MTU=1472
FLANNEL_IPMASQ=false
命令:[root@master ~]# cat /run/flannel/docker
DOCKER_OPT_BIP="--bip=10.255.94.1/24"
DOCKER_OPT_IPMASQ="--ip-masq=true"
DOCKER_OPT_MTU="--mtu=1472"
DOCKER_NETWORK_OPTIONS=" --bip=10.255.94.1/24 --ip-masq=true --mtu=1472"
5. 启动master上4个服务
命令:[root@master ~]# systemctl restart kube-apiserver kube-controller-manager kube-scheduler flanneld
命令:[root@master ~]# systemctl status kube-apiserver kube-controller-manager kube-scheduler flanneld
命令:[root@master ~]# systemctl enable kube-apiserver kube-controller-manager kube-scheduler flanneld
6. 配置minion节点服务器
注意:minion各节点配置相同,这边已node1为例
(1)配置flanneld服务
命令:[root@node1 ~]# vim /etc/sysconfig/flanneld
FLANNEL_ETCD_ENDPOINTS="http://192.168.175.3:2379"
FLANNEL_ETCD_PREFIX="/k8s/network"
FLANNEL_OPTIONS="--iface=ens33"
(2)命令:[root@node1 ~]# vim /etc/kubernetes/config
KUBE_MASTER="--master=http://192.168.175.3:8080"
(3)命令:[root@node1 ~]# vim /etc/kubernetes/kubelet
KUBELET_ADDRESS="--address=0.0.0.0"
KUBELET_HOSTNAME="--hostname-override=node1"
KUBELET_API_SERVER="--api-servers=http://192.168.175.3:8080"
KUBELET_POD_INFRA_CONTAINER="--pod-infra-container-image=registry.access.redhat.com/rhel7/pod-infrastructure:latest"
(4)启动node1服务
命令:[root@node1 ~]# systemctl restart flanneld kube-proxy kubelet docker
命令:[root@node1 ~]# systemctl enable flanneld kube-proxy kubelet docker
命令:[root@node1 ~]# systemctl status flanneld kube-proxy kubelet dock
7.查看服务是否安装成功(在master上查看)
命令:[root@master ~]# kubectl get nodes
NAME STATUS AGE
node1 Ready 2h
node2 Ready 25s