About cloud computing and cloud platform to build Kubernetes

I. Introduction to Cloud Computing

1, virtualization technology and cloud computing links

Cloud computing concept:

  • Cloud computing is a network, storage, hardware, software, integrated technology, it is emphasized that the concept of resource pools and dynamic resource pools can be unlimited expansion, volume reduction, and ultimately allow tenants to lease those resources.
  • Cloud computing is ultimately to provide services to tenants, tenants according to their needs, to apply resource pool, resource pools provide a platform called cloud platform.

Virtualization concepts:

  • Virtualization technology to the physical resources into logical resource can be managed to break the physical barriers resource structure, so that the service is running in a virtual machine on a virtual basis, rather than run directly on the physical resources.

Contact: virtualization technology is a module in the cloud, and is an integral module. Cloud computing offers a large variety of resource pooling, virtualization technology is a reasonable allocation of these resources in the resource pool to the virtual machine. Then put the virtual machine for sale to individual SMEs tenants were rented at different prices in different configurations.

2, classification of cloud computing

(1) service type classification

  • IaaS(Infrastructure as a Server)
  • PaaS(Platform as a Server)
  • SaaS (Software as a Server)
    Here Insert Picture Descriptionpattern analysis:
  • Without the cloud, we need to do is the left-most green part (ie everything)
  • When we introduced IaaS, brown things on to the next part of the cloud platform, the green part above deal with their own (providing hardware such as network, storage, etc.)
  • When we introduced PaaS, figure shows, we only use their own software deployment services.
  • When we introduced SaaS, we can use the software developed by the cloud provider, these are the existing open source software in general, free software for secondary development, with higher performance, greater support and optimization. Like SaaS, we basically only provide website code. What else do not have to maintain it yourself.

More image description is available in blog: https://blog.csdn.net/weixin_44571270/article/details/89737883

(2) to serve the object classification

  • Public cloud
  • Private Cloud
  • Hybrid Cloud

3, Kubernetes entry

1, Kubernetes is doing?
Kubernetes also known k8s, because there are eight letters and middle name. It is a container management platform automation. Born to manage docker container born. Use Kubernetes can achieve the following functions:

  • Deployment and automated replication container;
  • Feel free to expand or shrink the size of the container;
  • The containers are organized into groups, and to provide load balancing between the containers;
  • Easily upgraded new version of the application container;
  • Providing an elastic container, the container fails if it replaces the like.

2, Kubernetes platform components
Kubernetes cluster There are two main types of nodes: master, minion node, Minion node to node running Docker containers, Docker running on the node and is responsible for interaction, and provides a proxy function. The main master is managing a large number of distributed nodes of minion.

  • Kubelect Master: Master node responsible for external API interface provides a range of managed clusters and nodes interact and Minion is achieved by operating the management of the cluster.
  • Apiserver: inlet cluster user interaction and kubernetes, deletions core object encapsulates change search operation, provided RESTFul style API interface, persistence is achieved by etcd and maintain the consistency of the object.
  • Scheduler: responsible for scheduling and managing cluster resources, such as when a pod quit unexpectedly need to re-dispensing machines, scheduler through a certain scheduling algorithm to find the most appropriate node.
  • Controller-manager: mainly used to ensure consistent pod number of copy and the actual operation of replication Controller defined, and also to ensure that the mapping from service to the pod is always up to date.
  • Kubelet: Docker run interactively on a minion node, and the node is responsible for, such as start and stop the container and monitoring the operating status.
  • Proxy: running minion node, is responsible for providing proxy functionality for the pod, will regularly obtain service information from etcd, and to forward traffic by modifying the iptables service according to information (the original version is to provide forwarding directly by the program less efficient.) node, and forward traffic to where you want to access pod up.
  • Etcd: etcd consistency kv is a distributed storage system database, may be used for service registration and discovery shared storage configuration database is used to store information kubernetes, ETCD component as a highly available, strong consistency repository service discovery, gradually concern for developers. In the cloud computing era, how to make service fast and transparent access to computing cluster, how to share configuration information is quickly found all the machines in the cluster, more importantly, how to build such a high-availability, security, ease of deployment and rapid response services cluster, born etcd is to solve the problem.
  • Flannel: Flannel is CoreOS team for a cover net Kubernetes design (the Overlay
    Network) tools, Flannel purpose is for all nodes in a cluster re planning to use the rules of IP addresses, so that the containers on different nodes can be obtained belong to a network and Unique IP addresses, and so that the container can belong to different nodes on the IP network through direct communication.

Two, Kubernetes cloud platform to build

General business, there will be multiple master nodes, high availability usually do, then there will be etcd distributed cluster. But when we learn technology, it will not be so complicated. The simplest architecture system, need at least two or three physical servers.

Built environment

Here Insert Picture DescriptionI am here using two physical machines. K8s master node 201, node 200 when minion, one can make ETCD. Share a physical server on the master node.

Build process

1, the installation prelude
#两个服务器都要执行以下命令:
setenforce 0
或者 sed -i '/SELINUX/s/enforcing/disabled/g' /etc/selinux/config
systemctl stop firewalld

#ntp时间同步,master节点和million节点需要时间一致
yum install ntp -y
ntpdate pool.ntp.org
systemctl start ntpd
2, Master node installation
yum install kubernetes-master etcd -y
3, configuration etcd
vim /etc/etcd/etcd.conf

Here Insert Picture Description
Note: The 2380 port is the port for communication between the server and the etcd etcd server, also known as distributed cluster communication port.
2379 port to provide HTTP AP services, i.e. to provide services to the client through the port, where the port and to provide services to the master node minion.
27.0.0.1:2379 command to execute locally etcd connection, 172.16.193.201: 2379 for remote connections.

mkdir -pv /data/etcd
chown -R etcd.etcd /data/etcd
4, configuration k8s
cd /etc/kubernetes/
ll

Here Insert Picture Description
k8s been installed to produce three services:

  • apiserver: Unified Command (operation) entrance
    Here Insert Picture Description
  • controller-manager: If the container fails, it will create a new container immediately to ensure that the total number of containers unchanged
  • scheduler: scheduling controller and found that the container resource is full, it will automatically dispatched to other containers.

Modify k8s config configuration:
Here Insert Picture DescriptionStart three services:
Here Insert Picture Description

5, minion node installation
yum install kubernetes-node docker *rhsm* -y
6, configuration k8s

After installing k8s minion node generates two services:

  • kubelet: by interacting with docker, issued an order tasks. That is, the future will not docker run, docker ps so the. You can use kubelet this again. You can also create a web interface to run in a container.

Here Insert Picture Description

  • proxy: SNAT, DNAT is to do here. Forward traffic, the specific process is unclear!

K8s minion edit the configuration file:

vim config

Here Insert Picture DescriptionStart the two services:
Here Insert Picture Description

7, master end node view minion

Views:
Here Insert Picture DescriptionDelete minion nodes:
Here Insert Picture Descriptionadd nodes minion:
only two restart services on k8s minion node.

8, installation flannel

Note: This service is to unify the ip assigned to the docker container.

#这个flannel所有节点都要安装,无论master还是minion。
yum install flannel -y
vim /etc/sysconfig/flanneld

Here Insert Picture Description

etcdctl mk /atomic.io/network/config '{"network":"172.17.0.0/16"}'
#             这个是key                     这个是value
systemctl start flanneld

Host installation flannel services:
Here Insert Picture Description
Docker containers:
Here Insert Picture Description

Third, build k8s Dashboard UI interface

1, master node to do the operation

(1) Create a Dashboard-controller.yaml, Dashborad-service.yaml file
touch Dashboard-controller.yaml

The following content written to the file:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: kubernetes-dashboard
  namespace: kube-system
  labels:
    k8s-app: kubernetes-dashboard
    kubernetes.io/cluster-service: "true"
spec:
  selector:
    matchLabels:
      k8s-app: kubernetes-dashboard
  template:
    metadata:
      labels:
        k8s-app: kubernetes-dashboard
      annotations:
        scheduler.alpha.kubernetes.io/critical-pod: ''
        scheduler.alpha.kubernetes.io/tolerations: '[{"key":"CriticalAddonsOnly", "operator":"Exists"}]'
    spec:
      containers:
      - name: kubernetes-dashboard
        image: bestwu/kubernetes-dashboard-amd64:v1.6.3
        resources:
          limits:
            cpu: 100m
            memory: 50Mi
          requests:
            cpu: 100m
            memory: 50Mi
        ports:
        - containerPort: 9090
        args:
          - --apiserver-host=http://172.16.193.201:8080 #此处需要修改ip
        livenessProbe:
          httpGet:
            path: /
            port: 9090
          initialDelaySeconds: 30
          timeoutSeconds: 30

touch Dashboard-service.yaml

The following content written to the file:

apiVersion: v1
kind: Service
metadata:
  name: kubernetes-dashboard
  namespace: kube-system
  labels:
    k8s-app: kubernetes-dashboard
    kubernetes.io/cluster-service: "true"
spec:
  selector:
    k8s-app: kubernetes-dashboard
  ports:
  - port: 80
    targetPort: 9090
(2) modify the configuration file apiserver

Note: If you do not remove ServiceAccount parameters which, api will refuse access to the UI interface.

#KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ServiceAccount,ResourceQuota"
KUBE_ADMISSION_CONTROL="--admission-control=NamespaceLifecycle,NamespaceExists,LimitRanger,SecurityContextDeny,ResourceQuota"

If you are the last to find the words to do this step. You need to be modified, restart apiserver, then execute:

kubectl delete -f Dashboard-controller.yaml
kubectl delete -f Dashboard-service.yaml

2, do the minion node operation (this step can not be omitted)

Note: This step can not, the next step will be to download their own image. Under understand why changed its name on the line, k8s version and the dashboard version can not be that much difference, so I do not recommend themselves docker pull the mirror!

Download pod-infrastructure, kubernetes-dashboard image:

docker pull docker.io/tianyebj/pod-infrastructure
docker pull docker.io/mirrorgooglecontainers/kubernetes-dashboard-amd64

#这个改名是因为Dashboard-controller.yaml文件中调用过这个镜像
docker tag docker.io/siriuszg/kubernetes-dashboard-amd64 bestwu/kubernetes-dashboard-amd64:v1.6.3

#这个改名是因为minion节点中的/etc/kubernetes/kubelet文件中调用过它
docker tag docker.io/tianyebj/pod-infrastructure registry.access.redhat.com/rhel7/pod-infrastructure

3, create and run a mirror

kubectl create -f Dashboard-controller.yaml
kubectl create -f Dashboard-service.yaml
iptables -P FORWARD ACCEPT (全部节点都要配置)

Error: error: yaml: line 38:
did not find expected key to this whole mistake has caused me a long, long time.
Solution of these files have spaces did not play right. wrong format. Recopy or less. .json file format of the stringent requirements of the format, a space no more, no less a.

4, access k8s UI interface

Check whether a successful build dashboard interface:

kubectl get pods -namespace kube-system

This is a failure:
Here Insert Picture Description
An error occurred, you can see the log:

kubectl logs kubernetes-dashboard-3584070908-vp0gl -n kube-system

This is a success:
Here Insert Picture DescriptionHere Insert Picture DescriptionHere Insert Picture DescriptionSuccess!

He published 188 original articles · won praise 150 · views 30000 +

Guess you like

Origin blog.csdn.net/weixin_44571270/article/details/104767600