Kubernetes basis -1

Kubernetes Overview

  1. Kubernetes what
    1.Kubernetes is referred K8S Google in 2014, a vessel open source cluster management system, Kubernetes.
    2.K8S for deploying containerized applications, extensions and management.
    3.K8S provides a container scheduling, resource scheduling, resilient and elastic, deployment management, service discovery and a series of functions.
    4.Kubernetes goal is to deploy container applications simple and efficient.
    Official Website: https://kubernetes.io/

2.Kubernetes 特性

 1. 自我修复

Restarted when a node failure the failure of the container, replace and re-deploy, to ensure the desired number of copies; kill the health check fails container, and not before is not ready to handle client requests, to ensure that online services are not interrupted.
2. elastically stretchable
using a command, the UI or automatically based on the CPU usage and the rapid expansion of volume reduction application instance, to ensure high availability of the service peak concurrent application; resource recovery operations when the low peak, minimum cost to run the service.
3. Automatic deployment and rollback
K8S a rolling update policy update application, update a Pod, rather than delete all Pod, if a problem occurs during the update process, rolls back the changes, make sure the upgrade is not affected business.
4. Service Discovery and load balancing
K8S multiple containers to provide a unified access to all container entrance (the internal IP address and a DNS name), and load balancing is associated, so that the user need not consider the vessel IP issues.
5. confidential and configuration management
of confidential data and application configuration, without the need to expose sensitive data in the image, the sensitive data to improve security. And may be in K8S, it is convenient to use some common application storage configuration.
6. The storage arrangement
mounted external storage systems, whether from local storage, public clouds (such as AWS), or network storage (such as NFS, GlusterFS, Ceph) are used as part of a cluster resources, greatly improve storage flexibility.
7. Batch
one-time tasks, the timing task; meet batch data processing and analysis of scenarios.

3.Kubernetes cluster architecture and components
Kubernetes basis -1

         Master组件

    1.kube-apiserver

Unified entrance Kubernetes API, clusters, each component coordinator, RESTful API provides an interface to
services, resources additions and deletions to all objects of investigation and monitoring operations to APIServer process for submission to the
Etcd storage.
2.kube-controller-manager
processing cluster in routine background task, a resource corresponding to a controller, and ControllerManager
is responsible for the management of these controllers.
3.kube-scheduler
selecting a Node Pod newly created node according to the scheduling algorithm, can be arbitrarily deployed, can be deployed
on a single node, it can be deployed on different nodes.
etcd
distributed key-value storage system. For storing the cluster state data, such as object information Pod, Service and the like.

         Node组件

   1.kubelet

kubelet is a Master Agent on Node node, lifecycle management to run the machine container, such as creating
construction container, Pod mounted data volumes, download secret, to obtain container and node status and so on. kubelet each
converted into a group of containers a Pod.
2.kube-proxy
realize Pod Network Agent on Node node, network rules and four maintenance work load balancing.
3.docker or rocket
container engine running container.

4.Kubernetes core concepts
Pod
• The minimum unit of deployment
• A set of collection container
• container in a Pod shared network namespace
• Pod is short of
the Controllers
• ReplicaSet: to ensure that the expected number of copies Pod
• Deployment: Stateless application deployment
• StatefulSet : stateful application deployment
• DaemonSet: ensure that all run the same Node Pod
• the job: a one-time task
• Cronjob: regular tasks
more advanced level objects, deploy and manage Pod
Service
• Pod lost to prevent
access policy Kubernetes • define a set of Pod the core concept
label: label, attached to a resource for the associated objects, query and filter
namespaces: namespace, to isolate the target logical
annotations: Notes

Three deployment of official way

minikube
Minikube is a tool that can run Kubernetes a single point Fast locally, only to try to develop user Kubernetes or everyday use.
Deployment address: https://kubernetes.io/docs/setup/minikube/
kubeadm
Kubeadm is a tool that provides kubeadm init and kubeadm join, for rapid deployment Kubernetes cluster.
Deployment address: https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm/
binary packages
recommended, downloaded from the official release of the binary package, manually deploy each component, composed Kubernetes clusters.
Download: https://github.com/kubernetes/kubernetes/releases

kubectl command-line management tool

Kubernetes basis -1

业务发布常用命令如下:
1、创建
kubectl create deployment nginx --image=nginx:1.14
kubectl get deploy,pods
2、发布
kubectl expose deployment nginx --port=80 --type=NodePort --target-port=80 --name=nginx-service
kubectl get service
3、 更新
kubectl set image deployment/nginx nginx=nginx:1.15
4、 回滚
kubectl rollout history deployment/nginx
kubectl rollout undo deployment/nginx
5、 删除
kubectl delete deploy/nginx
kubectl delete svc/nginx-service

资源编排(YAML)

k8s集群中部署应用,除了在命令行快速部署外,一般都是采用yaml文件进行部署,

YAML 是一种简洁的非标记语言。
语法格式:
• 缩进表示层级关系
• 不支持制表符“tab” 缩进,使用空格缩进
• 通常开头缩进 2 个空格
• 字符后缩进 1 个空格,如冒号、逗号等
• “---” 表示YAML格式,一个文件的开始
• “#” 注释

yaml field too much, we do not have to memorize one by one, the following methods can be used.
Generation run command
kubectl the Create Deployment --image = nginx nginx: 1.14 -o-run YAML the --dry> My-deploy.yaml
• Export get command with
kubectl get my-deploy / nginx -o = yaml --export> my -deploy.yaml
after generating the file is modified according to the actual application.
Fields spelling • Pod container forget
kubectl explain pods.spec.containers

Guess you like

Origin blog.51cto.com/tuwei/2445624