Summary of basic concepts of Kubernetes

Introduction to the

Kubernetes is an open source container management platform developed by Google, which provides multi-host cluster, container scheduling, container scaling and other functions

Basic Components

docker

An implementation of the container runtime environment that encapsulates the underlying container

etcd

Etcd is a data warehouse used by Kubernetes cluster to store cluster-related data

Master node Component

The master node is the brain of the main cluster, handling external API requests, assigning scheduling tasks, and managing the number of copies of the container

kube-apiserver
  • kubernetesExternal service entrance, communication link of other components, stateless service, can be expanded horizontally
kube-scheduler
  • Responsible for pod task scheduling
kube-controller-manager
  • To deal withnodeThe node is down
  • Responsible for ensuring the number of pod copies
  • Manage the endpoint and connect the Service and POD
  • Create default API tokens and accounts for the new namespace

Node Node component

Nodes do the work, performing tasks assigned by the master node

kubelet
  • Responsible for starting and stopping containers to ensure container operation.
kube-proxy
  • Responsible for generating network rules and routing rules according to service

Component communication

Architecture diagram

! [](k8s-

arch.png)

Communication between components is entirely dependent on Kube-Apiserver, and other components interact with Kube-Apiserver over HTTP.

When using Kubectl or directly calling the API provided by Kube-Apiserver to request the creation of pod and service, the workflow is as follows:

  • kube-apiserverStore the associated POD and Service configurations toetcdIn the
  • kube-schedulerfromkube-apiserverGet the configuration of the relevant POD, and schedule the POD to the appropriate one based on the resource and condition constraints in the clusternodenodes
  • kube-controller-managerfromkube-apiserverObtain the configuration of relevant POD and Service, check the status of POD regularly, ensure that there are enough copies of pod configured by users in operation, and generate the rule relationship between Service and POD.
  • kubeletfromkube-apiserverGets the relevant POD configuration assigned to this node, starts the container locally and periodically checks to return the container status
  • kube-proxyfromkube-apiserverGet the rules for service to POD and maintain them on this nodeiptableoripvsRelated Routing rules

Basic concept

pod

  • kubernetesA POD can have multiple containers that share network and storage volumes

service

  • kubernetesAbstract out a concept, can be understood as a load balancer, back-end pod

cluster ip

  • Service IP address in the cluster, which is similar to the IP address of the load balancer

ingress

  • A way to expose services inside a cluster to the outside

nodeport

  • The second way to expose services to the outside of the cluster is to follow the service configuration to the inside of the clusternodeThe nodes all listen for the corresponding port that can passnodeA node accesses an internal service in the cluster

loadbalancer

  • A way to expose internal cluster services to the outside of the cluster, which is generally only available on cloud platforms

deployment

  • Encapsulates thepod/replicaset, can realize the specified POD copy number, rolling update, expansion of POD, generally an application (service) onedeployment

statefullSet

  • Equivalent to stateful servicedeployment, the host name and pod name will not change after the restart

daemonSet

  • At the end of eachnodeNodes all need to run the POD availabledaemonSet

job

  • One-off task

cronJob

  • Similar to thecrontabScheduled Task Execution

dns

  • kube-dns/corednsProvides DNS services in the cluster, and resolves services tocluster ipTo realize service discovery

pv

  • The administrator uses the storage space created in advance for users to apply for

pvc

  • Users apply for storage space

storageClass

  • Define the storage class for PVC to use when the user passes through the PVC and specifiesstorageClassRequest the pvkubernetesAccording tostorageClassDynamically creating a PV

Debugging skills

See the log

Viewing POD Logs
  • kubectl logs pod-name
View events
  • kubectl describe pod-name
View docker logs
  • Kubectl get pod -o wide find the node where the container is running

  • Use docker ps -a on node to find the container that failed

  • docker logs container-id

View kubelet and other component logs
  • journalctl -u kubelet