Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Kubernetes Basics-1

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Kubernetes Overview what is Kubernetes

1.Kubernetes is a container cluster management system opened by Google in 2014, Kubernetes is referred to as K8S.

2.K8S is used for the deployment, extension and management of containerized applications.

3.K8S provides a series of functions such as container orchestration, resource scheduling, auto scaling, deployment management, service discovery and so on.

The goal of 4.Kubernetes is to make the deployment of containerized applications simple and efficient.

Official website: https://kubernetes.io/

2.Kubernetes characteristics

1. Self-repair

Restart failed containers in case of node failure, replace and redeploy to ensure the expected number of copies; kill containers that fail health checks, and do not process client requests until they are ready to ensure that online services are not interrupted.

two。 Elastic expansion

Use commands, UI or automatic rapid expansion and reduction of application instances based on CPU usage to ensure high availability at the peak of application business concurrency; recover resources at low peak and run the service at minimum cost.

3. Automatic deployment and rollback

K8S updates the application with a rolling update policy, updating one Pod at a time instead of deleting all Pod at the same time. If there are problems in the update process, the changes will be rolled back to ensure that the upgrade will not affect the business.

4. Service discovery and load balancing

K8S provides a unified access entry for multiple containers (internal IP address and a DNS name), and all containers associated with load balancer, so that users do not have to consider the container IP problem.

5. Confidentiality and configuration management

Manage confidential data and application configuration without exposing sensitive data in the mirror to improve the security of sensitive data. And some commonly used configurations can be stored in K8S to facilitate the use of applications.

6. Storage choreography

Mounting 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 cluster resources, greatly improving storage flexibility.

7. Batch processing

Provide one-time tasks, scheduled tasks; meet the scenarios of batch data processing and analysis.

3.Kubernetes Cluster Architecture and components

Master component 1.kube-apiserver

Kubernetes API, the unified entrance of the cluster, the coordinator of each component, provides the interface with RESTful API.

Service, all additions, deletions, modifications, and monitoring operations of object resources are handed over to APIServer and then submitted to

Etcd storage.

2.kube-controller-manager

Handle regular background tasks in the cluster, where each resource corresponds to a controller, while ControllerManager

Is responsible for managing these controllers.

3.kube-scheduler

Select a Node node for the newly created Pod according to the scheduling algorithm, which can be deployed arbitrarily and can be deployed in the

It can also be deployed on different nodes on the same node.

Etcd

Distributed key storage system. Used to save cluster state data, such as Pod, Service and other object information.

Node component 1.kubelet

Kubelet is the Agent of Master on the Node node, which manages the life cycle of the native running container, such as Creative

Build containers, mount data volumes on Pod, download secret, get container and node status, and so on. Kubelet will every

The Pod is converted into a set of containers.

2.kube-proxy

Implement Pod network agent on Node node, maintain network rules and four-layer load balancing work.

3.docker or rocket

Container engine, run the container.

Core concepts of 4.Kubernetes

Pod

Minimum deployment unit

A collection of containers

A container shared network namespace in Pod

Pod is short-lived

Controllers

ReplicaSet: ensure the expected number of Pod copies

Deployment: stateless application deployment

StatefulSet: stateful application deployment

DaemonSet: make sure all Node are running the same Pod

Job: one-time task

Cronjob: scheduled task

Higher-level objects, deploying and managing Pod

Service

Prevent Pod from losing contact

Define a set of Kubernetes core concepts of access policies for Pod

Label: tags attached to a resource for associating objects, queries, and filtering

Namespaces: namespace to logically isolate objects

Annotations: comment

Three official deployment methods

Minikube

Minikube is a tool that can quickly run a single point of Kubernetes locally for use only by users trying Kubernetes or daily development.

Deployment address: https://kubernetes.io/docs/setup/minikube/

Kubeadm

Kubeadm is also a tool that provides kubeadm init and kubeadm join for rapid deployment of Kubernetes clusters.

Deployment address: https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm/

Binary packet

It is recommended that you download the released binary package from the official version and deploy each component manually to form a Kubernetes cluster.

Download address: https://github.com/kubernetes/kubernetes/releases

Kubectl Command Line Management tool

Common commands issued by businesses are as follows:

1. Create

Kubectl create deployment nginx-image=nginx:1.14

Kubectl get deploy,pods

2. Release

Kubectl expose deployment nginx--port=80-type=NodePort-target-port=80-name=nginx-service

Kubectl get service

3. Update

Kubectl set image deployment/nginx nginx=nginx:1.15

4. Rollback

Kubectl rollout history deployment/nginx

Kubectl rollout undo deployment/nginx

5. Delete

Kubectl delete deploy/nginx

Kubectl delete svc/nginx-service

Resource scheduling (YAML)

Except for rapid deployment on the command line, applications deployed in K8s cluster are generally deployed using yaml files.

YAML is a concise, unmarked language.

Syntax format:

Indentation represents a hierarchical relationship

Tab "tab" indentation is not supported, using space indentation

Usually indent 2 spaces at the beginning

Indent a space after a character, such as a colon, comma, etc.

"- -" indicates the YAML format, the beginning of a file.

"#" comment

There are too many yaml fields, so we don't have to memorize them one by one. We can use the following methods.

Generate with the run command

Kubectl create deployment nginx-- image=nginx:1.14-o yaml-- dry-run > my-deploy.yaml

Export with the get command

Kubectl get my-deploy/nginx-o=yaml-- export > my-deploy.yaml

After generating the file, modify it according to the actual application.

The field spelling of the Pod container has been forgotten

Kubectl explain pods.spec.containers

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report