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

Introduction to the components and deployment methods of k8s

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

Share

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

The knowledge points of this article include: the introduction of kubernetes components, the core concepts of kubernetes, kubernetes cluster deployment and the use of kubernetes. Read the complete article, I believe you have a certain understanding of kubernetes.

1. Master component

● kube-apiserver

Kubernetes API, the unified entrance to the cluster and the coordinator of each component, provides interface services through RESTful API. All object resource additions, deletions, modifications, and monitoring operations are handed over to APIServer and then submitted to Etcd for storage.

● kube-controller-manager

Handle the regular background tasks in the cluster, each resource corresponds to a controller, and ControllerManager is responsible for managing these controllers.

● kube-scheduler

According to the scheduling algorithm, select a Node node for the newly created Pod, which can be deployed arbitrarily, on the same node or on different nodes.

● etcd

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

2. Node components

● kubelet

Kubelet is the Agent of Master on the Node node, which manages the lifecycle of native running containers, such as creating containers, mounting data volumes on Pod, downloading secret, getting container and node status, and so on. Kubelet converts each Pod into a set of containers.

● kube-proxy

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

● docker or rocket

Container engine, run the container.

How it works:

1. Prepare the yml file containing the Deployment of the application, and then send it to ApiServer through the kubectl client tool.

2. ApiServer receives the request from the client and stores the resource content in the database (etcd).

3. Controller components (including scheduler, replication, endpoint) monitor resource changes and respond.

4. ReplicaSet checks the database changes and creates the desired number of pod instances.

5. Scheduler checks the database changes again and finds the Pod that has not been assigned to the specific execution node (node), then assigns the pod to the node where they can run according to a set of relevant rules, and updates the database to record the pod allocation.

6. Kubelete monitors database changes, manages the life cycle of subsequent pod, and discovers those pod that are assigned to run on the node where it is located. If a new pod is found, the new pod is run on that node.

Attachment: kuberproxy runs on each host of the cluster and manages network communication, such as service discovery and load balancing. When data is sent to the host, it is routed to the correct pod or container. For data sent from the host, it can discover the remote server based on the request address and route the data correctly, in some cases using the round robin scheduling algorithm (Round-robin) to send requests to multiple instances in the cluster.

Core concepts of Kubernetes

1 、 Pod

● minimum deployment unit

A collection of ● containers

● Container sharing Network Namespace in Pod

● Pod is short-lived

2 、 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 tasks

Higher-level objects, deploying and managing Pod

3 、 Service

● prevents Pod from losing contact

● defines a set of access policies for Pod

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

● Namespaces: naming space, logically isolating objects

● Annotations: comment

Kubernetes cluster deployment

1. 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 package

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

Environmental planning of Kubernetes platform

3. Self-signed SSL certificate

Etcd database cluster deployment

Kubernetes binary deployment

K8s software package:

Link: https://pan.baidu.com/s/1oN2wkGZ_7parS8sMaaogGw

Extraction code: lbjx

K8s deployment planning:

Master:192.168.35.128 kube-apiserver kube-controller-manager kube-scheduler etcd

Node1:192.168.35.195 kubelet kube-proxy docker flannel etcd

Node2:192.168.35.138 kubelet kube-proxy docker flannel etcd

Master operation:

[root@localhost ~] # mkdir k8s

[root@localhost ~] # cd k8s/

[root@localhost K8s] # ls / / drag in from the host

Etcd-cert.sh etcd.sh

[root@localhost k8s] # mkdir etcd-cert

[root@localhost k8s] # mv etcd-cert.sh etcd-cert

The above etcd-cert.sh etcd.sh script

Vim etcd.sh

#! / bin/bash

# example:. / etcd.sh etcd01 192.168.1.10 etcd02= https://192.168.1.11:2380,etcd03=https://192.168.1.12:2380

ETCD_NAME=$1

ETCD_IP=$2

ETCD_CLUSTER=$3

WORK_DIR=/opt/etcd

Cat

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