当前位置:网站首页>Introduction to kubernetes resource objects and common commands (II)
Introduction to kubernetes resource objects and common commands (II)
2022-07-01 07:31:00 【Silly [email protected]】
Deployment
Deployment seeing the name of a thing one thinks of its function , Deployment means deployment .Deploymen Used to control the Pod, send Pod Have multiple copies , self-healing , Ability to expand, shrink, etc .
Multiple copies
copy , It can be understood as Pod The number of . these Pod Will be randomly assigned to any node in the cluster .
Create a named my-app Deployment of , Use image as nginx. Replications for 3.
Command line mode
kubectl create deploy my-app --image=nginx --replicas=3
yaml The way ,my-app.yml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: my-app
name: my-app
spec:
replicas: 3
selector:
matchLabels:
app: my-app
template:
metadata:
labels:
app: my-app
spec:
containers:
- image: nginx
name: nginx
kubectl apply -f my-app.yml

Expansion and contraction capacity
Expanding or shrinking capacity is to expand or reduce the original number of copies . When the traffic is large, the capacity can be expanded , After the flow peak, the volume can be reduced , Maximize resource utilization .
Command line mode
kubectl scale --replicas=5 deployment/my-app
The number of copies is determined by 3 A into 5 individual .
modify yaml The way
kubectl edit deployment my-app
take replicas Change it to the quantity you want , Save and exit to expand or shrink the volume .

self-healing & Fail over
Use Deployment The deployed application is always consistent with the set number of copies , When pod Exceptions or server downtime occur , Or delete pod, The replica will be pulled up again on the normal node , To meet the number of copies we set .
We simulate the k8s-worker1 The node is down .
Find out k8s-worker1 Two of the nodes pod Status as Terminating. stay k8s-worker2 Two more Running State of pod. Failover is achieved .
Expand :
Look inside the cluster pod Information .
kubectl get pod -owide
Monitor the cluster pod situation , Print details .
kubectl get pod -w

threshold :pod An abnormal condition has occurred ,k8s Will not kill immediately pod To restart , Instead, the corresponding restart operation is performed only after the threshold is exceeded , To prevent frequent startup caused by faults such as short-term network problems pod.
Scroll to update
The traditional updating and upgrading requires that the service be stopped for upgrading .k8s Don't stop the service , Will pod Replace... In turn Become the latest , That is, start a new pod, Kill an old pod, Until all updates are completed .
take nginx Image update to 1.16.1 edition .
Command line mode
kubectl set image deployment/my-app nginx=nginx:1.16.1 --record
modify yaml The way
kubectl edit deployment/my-app
take images It is amended as follows 1.16.1 in , Save to exit .

Expand :
View a deployed yaml.
kubectl get deployment [my-app] -oyaml
Version rollback
Rollback the version to a certain time in history .
View history
[[email protected] ~]# kubectl rollout history deployment/my-app
deployment.apps/my-app
REVISION CHANGE-CAUSE
1 <none>
2 kubectl set image deployment/my-app nginx=nginx:1.16.1 --record=true
[[email protected] ~]#
View a history detail
[[email protected] ~]# kubectl rollout history deployment/my-app --revision=2
deployment.apps/my-app with revision #2
Pod Template:
Labels: app=my-app
pod-template-hash=5ff664f457
Annotations: kubernetes.io/change-cause: kubectl set image deployment/my-app nginx=nginx:1.16.1 --record=true
Containers:
nginx:
Image: nginx:1.16.1
Port: <none>
Host Port: <none>
Environment: <none>
Mounts: <none>
Volumes: <none>
[[email protected] ~]#
Roll back ( Back to the last time )
[[email protected] ~]# kubectl rollout undo deployment/my-app
deployment.apps/my-app rolled back
[[email protected] ~]#
Roll back ( Back to the specified version )
[[email protected] ~]# kubectl rollout undo deployment/my-app --to-revision=2
deployment.apps/my-app rolled back
[[email protected] ~]#
The rollback version should be filled in as required .
Summary :

except Deployment,k8s also StatefulSet 、DaemonSet 、Job etc. Type resources . We all call it The workload . Stateful applications use StatefulSet Deploy , Stateless applications use Deployment Deploy https://kubernetes.io/zh-cn/docs/concepts/workloads/controllers/
This paper is written by mdnice Multi platform Publishing
版权声明
本文为[Silly [email protected][email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/182/202207010723585906.html
边栏推荐
- MATLAB之基础知识
- C# Newtonsoft.Json中JObject的使用
- 2022 Guangdong Provincial Safety Officer a certificate third batch (main person in charge) special operation certificate examination question bank simulated examination platform operation
- 【编程强训3】字符串中找出连续最长的数字串+数组中出现次数超过一半的数字
- Oracle创建自增id
- DC-4 target
- TodoList经典案例①
- Huawei modelarts training alexnet model
- ctfshow-web351(SSRF)
- Do securities account opening affect the security of account opening
猜你喜欢
![[Shenzhen IO] precise Food Scale (some understanding of assembly language)](/img/8c/1e64401e812538d8606df557054355.png)
[Shenzhen IO] precise Food Scale (some understanding of assembly language)

Système de gestion de l'exploitation et de l'entretien, expérience d'exploitation humanisée

Caesar

ctfshow-web351(SSRF)

奥迪AUDI EDI 项目中供应商需要了解哪些信息?

2022 operation of refrigeration and air conditioning equipment operation of national question bank simulated examination platform

1286_ Implementation analysis of task priority setting in FreeRTOS

Illusory and simple screen raindrop post-processing effect

关系数据库如何工作

ONES 创始人王颖奇对话《财富》(中文版):中国有没有优秀的软件?
随机推荐
vscode 根据 ESLint 规范自动格式化代码
长路漫漫、技术作伴
The database is locked. Is there a solution
Autosar 学习记录(1) – EcuM_Init
JAX的深度学习和科学计算
C# 读写自定义的Config文件
The computer has a network, but all browser pages can't be opened. What's the matter?
[R language] two /n data merge functions
Redisson uses the full solution - redisson official documents + comments (Part 2)
Minecraft 1.16.5模组开发(五十一) 方块实体 (Tile Entity)
base64
Discussion on several research hotspots of cvpr2022
Summary of the concept and advantages of 5g massive MIMO
redisson使用全解——redisson官方文档+注释(下篇)
Eigen矩阵运算库快速上手
Alibaba OSS postman invalid according to policy: policy condition failed: ["starts with", "key", "test/"]
运维管理系统,人性化操作体验
奥迪AUDI EDI 项目中供应商需要了解哪些信息?
2022 operation of refrigeration and air conditioning equipment operation of national question bank simulated examination platform
TCP/UDP 通信问题整理