k8s profile and build

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.

 
2. Core Concepts
(1)master
                    K8s cluster node management, access to resource data is responsible for managing a cluster, the cluster provides entrance
(2)Node
                    node cluster architecture is k8s running pod service node
(3) In
                    Running on Node node, a combination of several associated container, the inner pod comprising a container run on the same host, use the same network name space, IP address, port, capable of communicating over localhost
 
K8s of application scenarios: Three
k8s best suited to run micro Services Architecture
 
Four: the preparatory work before the building (all servers)
1. Prepare three linux servers, each server configuration 2G memory and 2CPU
The role of host names IP addresses
Master                master                  192.168.175.3
Node node1 192.168.175.250
Node node2 192.168.175.251
 
2. Install the vim  
Command: yum -y install vim
 
3. Change the hosts file to add the host name and IP mapping relationship
Command: vim / etc / hosts
192.168.175.3     master
192.168.175.250   node1
192.168.175.251   node2
 
4. Close the firewall and selinux 
Command: iptables -F # Clear firewall rules
Command: systemctl stop firewalld # turn off the firewall
Command: setenforce 0 # selinux closed
 
Four: Kubernetes build
1. In each node k8s assembly mounted thereon
configured to etcd master and master node:
命令:[root@master ~]# yum install -y kubernetes etcd flannel ntp
命令:[root@node1 ~]# yum install -y kubernetes etcd flannel ntp
命令:[root@node2 ~]# yum install -y kubernetes etcd flannel ntp
 
2. (1) Configuration etcd
Command: [root @ master ~] # vim /etc/etcd/etcd.conf # modify the following configuration
ETCD_LISTEN_CLIENT_URLS="http://localhost:2379,http://192.168.175.3:2379"
ETCD_NAME="etcd"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.175.3:2379"

 

(2) to start the service

命令:[root@master ~]# systemctl start etcd
命令:[root@master ~]# systemctl status etcd
命令:[root@master ~]# systemctl enable 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

Guess you like

Origin www.cnblogs.com/zgqbky/p/12149753.html