当前位置:网站首页>[kubernetes guide ④] pod quick start
[kubernetes guide ④] pod quick start
2022-06-12 23:11:00 【Bulst】
Pod Quick start
Pod yes kubernetes The smallest unit for cluster management , The program must be deployed in a container to run , And the container must exist in Pod in .
Pod It can be considered as the encapsulation of the container , One Pod There can be one or more containers in the .

kubernetes After cluster startup , Each component in the cluster is also based on Pod Way to run . You can view it through the following command :
[[email protected] ~]# kubectl get pod -n kube-system
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system coredns-6955765f44-68g6v 1/1 Running 0 2d1h
kube-system coredns-6955765f44-cs5r8 1/1 Running 0 2d1h
kube-system etcd-master 1/1 Running 0 2d1h
kube-system kube-apiserver-master 1/1 Running 0 2d1h
kube-system kube-controller-manager-master 1/1 Running 0 2d1h
kube-system kube-flannel-ds-amd64-47r25 1/1 Running 0 2d1h
kube-system kube-flannel-ds-amd64-ls5lh 1/1 Running 0 2d1h
kube-system kube-proxy-685tk 1/1 Running 0 2d1h
kube-system kube-proxy-87spt 1/1 Running 0 2d1h
kube-system kube-scheduler-master 1/1 Running 0 2d1h
Create and run
kubernetes No separate operation is provided Pod The order of , It's all through Pod Controller
# Command format : kubectl run (pod Controller name ) [ Parameters ]
# --image Appoint Pod Mirror image
# --port Designated port
# --namespace Appoint namespace
[[email protected] ~]# kubectl run nginx --image=nginx:latest --port=80 --namespace dev
deployment.apps/nginx created
see pod Information
# see Pod essential information
[[email protected] ~]# kubectl get pods -n dev
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 43s
# see Pod Details of
[[email protected] ~]# kubectl describe pod nginx -n dev
Name: nginx
Namespace: dev
Priority: 0
Node: node1/192.168.5.4
Start Time: Wed, 08 May 2021 09:29:24 +0800
Labels: pod-template-hash=5ff7956ff6
run=nginx
Annotations: <none>
Status: Running
IP: 10.244.1.23
IPs:
IP: 10.244.1.23
Controlled By: ReplicaSet/nginx
Containers:
nginx:
Container ID: docker://4c62b8c0648d2512380f4ffa5da2c99d16e05634979973449c98e9b829f6253c
Image: nginx:latest
Image ID: docker-pullable://[email protected]:485b610fefec7ff6c463ced9623314a04ed67e3945b9c08d7e53a47f6d108dc7
Port: 80/TCP
Host Port: 0/TCP
State: Running
Started: Wed, 08 May 2021 09:30:01 +0800
Ready: True
Restart Count: 0
Environment: <none>
Mounts:
/var/run/secrets/kubernetes.io/serviceaccount from default-token-hwvvw (ro)
Conditions:
Type Status
Initialized True
Ready True
ContainersReady True
PodScheduled True
Volumes:
default-token-hwvvw:
Type: Secret (a volume populated by a Secret)
SecretName: default-token-hwvvw
Optional: false
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s
node.kubernetes.io/unreachable:NoExecute for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled <unknown> default-scheduler Successfully assigned dev/nginx-5ff7956ff6-fg2db to node1
Normal Pulling 4m11s kubelet, node1 Pulling image "nginx:latest"
Normal Pulled 3m36s kubelet, node1 Successfully pulled image "nginx:latest"
Normal Created 3m36s kubelet, node1 Created container nginx
Normal Started 3m36s kubelet, node1 Started container nginx
visit Pod
# obtain podIP
[[email protected] ~]# kubectl get pods -n dev -o wide
NAME READY STATUS RESTARTS AGE IP NODE ...
nginx 1/1 Running 0 190s 10.244.1.23 node1 ...
# visit POD
[[email protected] ~]# curl http://10.244.1.23:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
</head>
<body>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
Delete the specified Pod
# Delete the specified Pod
[[email protected] ~]# kubectl delete pod nginx -n dev
pod "nginx" deleted
# here , Show delete Pod success , But check again , Discovery has created a new
[[email protected] ~]# kubectl get pods -n dev
NAME READY STATUS RESTARTS AGE
nginx 1/1 Running 0 21s
# This is because of the current Pod By Pod Created by controller , The controller will monitor Pod condition , Once found Pod Death , Will be rebuilt immediately
# At this point, you want to delete Pod, Must delete Pod controller
# Let's check the current namespace Under the Pod controller
[[email protected] ~]# kubectl get deploy -n dev
NAME READY UP-TO-DATE AVAILABLE AGE
nginx 1/1 1 1 9m7s
# Next , Delete this PodPod controller
[[email protected] ~]# kubectl delete deploy nginx -n dev
deployment.apps "nginx" deleted
# Wait a moment , The query again Pod, Find out Pod Been deleted
[[email protected] ~]# kubectl get pods -n dev
No resources found in dev namespace.
Configuration operation
Create a pod-nginx.yaml, The contents are as follows :
apiVersion: v1
kind: Pod
metadata:
name: nginx
namespace: dev
spec:
containers:
- image: nginx:latest
name: pod
ports:
- name: nginx-port
containerPort: 80
protocol: TCP
Then you can execute the corresponding create and delete commands :
establish :kubectl create -f pod-nginx.yaml
Delete :kubectl delete -f pod-nginx.yaml
《 Core technology series column summary 》
- 《Java Is the core technology 》
- 《 Middleware core technology 》
- 《 Core technology of microservice 》
- 《 Cloud native core technology 》
- 《 Common business implementation set 》
- 《 Let's go to Dachang series 》
- 《 Open source project o s s a》
need Interview questions of Dachang 、 resume template 、 e-book 、 Learning materials Etc 【 official account 】 reply 「 1024 」 that will do .
边栏推荐
- 年薪50万是一条线,年薪100万又是一条线…...
- Coordinate transformation in pipelines
- 〖Kubernetes指南④〗Pod快速入门
- 【LeetCode】69. Square root of X
- ShardingSphere-proxy-5.0.0部署之分表实现(一)
- Leetcode 890 finding and replacing patterns [map] the leetcode path of heroding
- 启牛帮开通的股票账户是安全可信的吗?
- [recommended collection] easy to understand graphic network knowledge - Part 1
- InfoQ geek media's 15th anniversary solicitation | brief introduction to the four challenges of building a micro service architecture
- Use of map() function in JS
猜你喜欢

Anti aliasing / anti aliasing Technology

C语言:如何给全局变量起一个别名?

Leetcode1601: the maximum number of building change requests that can be reached (difficult)

The Milvus graphical management tool Attu is coming!

Colab tutorial (super detailed version) and colab pro/colab pro+ usage evaluation
![[North Asia data recovery] data recovery cases in which the partitions disappear and the partitions are inaccessible after the server reinstalls the system](/img/a9/7726139037860a5f880667cec4b6c2.jpg)
[North Asia data recovery] data recovery cases in which the partitions disappear and the partitions are inaccessible after the server reinstalls the system

LeetCode 146. LRU cache

度量学习(Metric Learning)【AMSoftmax、Arcface】

Opencv source code compilation

MYSQL 行转列、列转行、多列转一行、一行转多列
随机推荐
Qrcodejs2 QR code generation JS
OpenCV源代码编译
Industry reshuffle, a large number of programmers are going to lose their jobs? How can we break the current workplace dilemma
MySQL基础篇视图的总结
Use of map() function in JS
Dix points de défense clés dans les exercices d'attaque et de défense détaillés
四元数简介
Use js to listen for Keydown event
lua 条件语句
Research Report on truffle fungus industry - market status analysis and development prospect forecast
Zabbix的功能介绍和常用术语
The shutter library recommends sizer to help you easily create a responsive UI
Chapter 8 - shared model JUC
DETR(Detection with Transformers) 学习笔记
Research Report on market supply and demand and strategy of tizanidine industry in China
Zhengzhou University of light industry -- development and sharing of harmonyos pet health system
Automatically obtain the position offset of member variables inside the structure
Huawei officially entered the "front loading" stage, and the millimeter wave radar track entered the "localization +4d" cycle
Analysis report on the 14th five year development plan and operation mode of China's hazardous waste treatment industry from 2022 to 2028
C language: how to give an alias to a global variable?