当前位置:网站首页>Technology sharing | introduction to kubernetes pod
Technology sharing | introduction to kubernetes pod
2022-06-27 18:44:00 【Ink Sky Wheel】
author : Shen Yajun
Members of the research and development team of akerson , In charge of the company DMP Back end development of products , Too many hobbies , Three days and three nights are endless , Keep a low profile ...
In this paper, the source : Original contribution
* Produced by aikesheng open source community , Original content is not allowed to be used without authorization , For reprint, please contact the editor and indicate the source .
pod What is it?
Why pod
IPC
Means of communication , Need to run on the same host . If deployed in kubernetes The environment process needs to run inside the container , Therefore, one of the possible solutions is to run multiple processes in the same container to achieve a deployment mode similar to that on the same host . however container Is designed so that each container runs a separate process , Unless the process itself creates multiple child processes , Of course, if you choose to run multiple unrelated processes in the same container , Then you need to manage other processes yourself , Include the lifecycle of each process ( Restart the suspended process )、 Log cutting, etc . If multiple processes output logs on standard output and standard error output , It will cause confusion in the log , therefore docker and kubernetes We want to run only one process in a container .
Pod As a service unit that can run independently , Simplify the difficulty of application deployment , It provides great convenience for application deployment management with a higher level of abstraction .
Pod As the smallest application instance, it can run independently , So it's easy to deploy 、 Horizontal expansion and contraction 、 Convenient for scheduling management and resource allocation .
Pod Containers in share the same data and network address space ,Pod There is also a unified resource management and allocation .
pause Containers
stay linux Run a process in the environment , This process will inherit all of the parent process namespace
, It can also be used unsharing
Create a new namespace
. Use the following unshare
Way to run shell And create a new PID、UTS、IPC and mount Namespace .
sudo unshare --pid --uts --ipc --mount -f chroot rootfs bin/sh
Other processes can use system calls setns
Add to new namespace ,pod
The implementation of is similar , Demonstrate how to manually create a simple pod
## First run a pause Containers
docker run -d --name pause -p 8880:80 --ipc=shareable gcr.io/google_containers/pause-amd64:3.0
## establish nginx Containers , And add it to pause Containers net ipc and pid namespace
$ cat <<EOF >> nginx.conf
error_log stderr;
events { worker_connections 1024; }
http {
access_log dev/stdout combined;
server {
listen 80 default_server;
server_name example.com www.example.com;
location {
proxy_pass http://127.0.0.1:2368;
}
}
}
EOF
docker run -d --name nginx -v `pwd`/nginx.conf:/etc/nginx/nginx.conf --net=container:pause --ipc=container:pause --pid=container:pause nginx
## function ghost Containers And add it to pause Containers network ipc and pid namespace
docker run -d --name ghost --net=container:pause --ipc=container:pause --pid=container:pause ghost
stay ghost Use in container ps You can see pause and nginx process ,
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND
root 1 0.0 0.0 1032 4 ? Ss 10:06 0:00 pause
root 8 0.0 0.1 8864 3120 ? Ss 10:15 0:00 nginx: master process nginx -g daemon off;
101 38 0.0 0.1 9312 3088 ? S 10:15 0:00 nginx: worker process
node 48 0.3 6.9 969996 142296 ? Ssl 10:18 0:09 node current/index.js
adopt localhost:8080 visit ghost page , Then you should be able to see ghost adopt Nginx The agent runs , because pause、nginx and ghost Sharing between containers network namespace, As shown in the figure below :

pod Commonly used way
pod There are two types of usage :
pod Only one container runs in the . In this case, we can put pod A wrapper regarded as a container ,kubernetes Through management pod Way to manage containers ;
pod Run multiple containers that need to share resources and work closely together . As shown in the figure below , Two containers pass through Volume Shared files ,Filer Puller Update files from the remote ,Web Server Responsible for the presentation of documents .

Whether it is necessary for them to run in the same kubernetes node ?
They represent a whole , Or an independent component ?
Do they need to be expanded or reduced as a whole ?
Pod Use
establish Pod
In the following ways kubectl apply -f nginx-pod.yaml
establish pod, And pass kubectl get pod
see pod The state of , As shown below .
apiVersion: v1
kind: Pod
metadata:
name: nginx # pod name
spec:
containers: # List of containers
- name: nginx # Container name
image: nginx:1.14.2 # Containers use mirroring
ports: # Container port mapping
- containerPort: 80
kubectl describe pod nginx
see pod The state of , The following shows pod Some information ,
Status
The fields are pod A summary introduction in its life cycle ,Running Express pod In normal operation
Name: nginx
Namespace: default
.....
Start Time: Sat, 04 Jun 2022 09:24:36 +0000
Labels: <none>
.....
Status: Running
IP: 10.42.1.139
Containers:
nginx:
Container ID: docker://xxxx
Image: nginx:1.14.2
Image ID: docker-pullable://
.....
pod Life cycle of
Pod After creation , Follow the defined lifecycle , from Pending The stage begins , If pod At least one container in the is started normally , entering Running, And then according to Pod Whether any of the containers in the has entered... Due to fault termination Succeeded or Failed Stage ,pod In its life cycle, it may be in the following states
Pending:Pod Has been Kubernetes Cluster acceptance , But one or more containers are not ready to run . This includes Pod The time spent waiting for scheduling and downloading container images over the network . Running:Pod Bound to a node , And all containers have been created . At least one container is still running , Or in the process of starting or restarting . Succeeded:Pod All containers in have been successfully terminated , Will not restart . Failed:Pod All containers in have terminated , And at least one container is terminated due to failure . in other words , The container either exits in a non-zero state , It's either terminated by the system . Unknown: For some reason , Can't get Pod The state of . This phase is usually due to and should run Pod An error occurred while communicating with the node of .
pod Create a process

User pass Kubectl Submit Pod` Description file to API Server; API Server take Pod The information of the object is stored in Etcd; Pod The creation of will generate events , Return to API Server; Controller Listening for events ; Pod Mount the disk if necessary ,Controller Will check whether there are any that meet the conditions PV; If the conditions are met PV,Controller Will bind Pod and PV, Tell... About the binding relationship API Server; API Server Write binding information to Etcd; Generate Pod Update event ; Scheduler Listen to the Pod Update event ; Scheduler Would be Pod choice Node; If there is one that meets the conditions Node,Scheduler Will bind Pod and Node, And tell the binding relationship API Server; API Server Write binding information to Etcd; Generate Pod Update event ; Kubelet Listen to the Pod Update event , establish Pod; Kubelet inform CRI( Container runtime interface ) Download mirroring ; Kubelet inform CRI Run container ; CRI call Docker Run container ; Kubelet inform Volume Manager, Hang the disc on Node At the same time mount to Pod; CRI call CNI( Container network interface ) Configure container network ;
Related to recommend :
Technology sharing | kubernetes operator brief introduction
Technology sharing | kubernetes Environment test deployment MySQL Capriccio
Technology sharing | MongoDB Check if the sorting exceeds the memory limit
Aikesheng open source community SQLE Is a database for users and managers , Support multi scenario audit , Support standardized online process , Native support MySQL Audit and database type extensible SQL Audit tools .
type | Address |
---|---|
Version Library | https://github.com/actiontech/sqle |
file | https://actiontech.github.io/sqle-docs-cn/ |
Publish the information | https://github.com/actiontech/sqle/releases |
Data audit plug-in development documentation | https://actiontech.github.io/sqle-docs-cn/3.modules/3.7_auditplugin/auditplugin_development.html |
More about SQLE Information and communication , Please join the official QQ Communication group :637150065...

边栏推荐
- seata-server 端数据库连接用户、业务数据库 undo_log 所属用户都需要什么权限?
- How much room does Migu video have for development without relying on sports events?
- Asemi rectifier bridge kbp307 parameters, kbp307 details, kbp307 pictures
- Bit.Store:熊市漫漫,稳定Staking产品或成主旋律
- 开源之夏 2022 | openGauss 项目中选公布
- 2022 Liaoning's latest eight members (Safety Officer) simulated test question bank and answers
- All you want to know about large screen visualization is here
- Repeatedly recognized by authoritative organizations! Smartbi was selected into the top three lists of high-tech and high growth enterprises
- [UVM foundation] UVM_ Is in agent_ Active variable definition
- How can Seata performance be improved? For example, add a computing node to the database?
猜你喜欢
【网络研讨会】MongoDB 携手 Google Cloud 加速企业数字化创新
VSCode 建议你启用 gopls,它到底是个什么东东?
TP5 generates the most detailed two-dimensional code tp6 (also available)
Wanzhou gold industry: what knowledge points do you need to master to invest in precious metals?
Uploading multiple attachments from canvas apps to SharePoint
2022 Liaoning latest fire facility operator simulation test question bank and answers
Offline disk group
The power of code refactoring: how to measure the success of refactoring
Advanced learning of MySQL -- Application -- view, stored procedure, trigger
Shardingsphere & Atlas & MYCAT comparison
随机推荐
[UVM basics] set a monitor at the input port of the DUT to explain the necessity
Set up your own website (10)
1. introduction to MariaDB
TP5 restrict access frequency
时序数据库(Time Series Database)的存储引擎要想做到极致,还得自研
Asemi rectifier bridge kbp310 function pin diagram
「技术课堂」如何用 VSCode 从 0 到 1 改写 TDengine 代码
Redis installation
JXL export Excel
WOx WPM installing the Youdao plug-in
SQL update批量更新
Wanzhou gold industry: what are the common gold investment and warehouse building modes?
(5) SPI application design and simulation verification 3 - verification code implementation
Part 31 supplement (31) ECMAScript conversion to string and number
Android kotlin learning
Simple anti shake for wechat applet
[UVM foundation] can only be used in build_ Research on executing instantiation action in phase
Contest3182 - the 39th individual training match for 2021 freshmen_ E: ringring
leetcode 92. Reverse linked list II
TDengine 连接器上线 Google Data Studio 应用商店