当前位置:网站首页>Introduction to kubernetes resource objects and common commands (II)
Introduction to kubernetes resource objects and common commands (II)
2022-07-01 02:37:00 【Jiangxiaonan】
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/
边栏推荐
- Zero foundation self-study SQL course | window function
- 【微信小程序开发】样式汇总
- 【微信小程序開發】樣式匯總
- 我的PMP学习考试心得
- SWT / anr problem - SWT caused by long execution time of native method
- The mobile edge browser cannot open the third-party application
- 先写API文档还是先写代码?
- Lenovo x86 server restart management controller (xclarity controller) or TSM method
- Pulsar Geo Replication/灾备/地域复制
- AI 边缘计算平台 - BeagleBone AI 64 简介
猜你喜欢
![Pytorch —— 基礎指北_貳 高中生都能看懂的[反向傳播和梯度下降]](/img/6e/279dbb7a8d7a5ecd240de464c5b8b2.png)
Pytorch —— 基礎指北_貳 高中生都能看懂的[反向傳播和梯度下降]

Contrastive learning of Class-agnostic Activation Map for Weakly Supervised Object Localization and

js中的图片预加载
![Pytorch —— 基础指北_贰 高中生都能看懂的[反向传播和梯度下降]](/img/6e/279dbb7a8d7a5ecd240de464c5b8b2.png)
Pytorch —— 基础指北_贰 高中生都能看懂的[反向传播和梯度下降]

如何在智汀中实现智能锁与灯、智能窗帘电机场景联动?

Focusing on green and low carbon, data center cooling has entered a new era of "intelligent cooling"

园区运营效率提升,小程序容器技术加速应用平台化管理

pycharm 软件deployment 灰色 无法点

Leetcode interview question 17.10 Main elements

The image variables in the Halcon variable window are not displayed, and it is useless to restart the software and the computer
随机推荐
C language a little bit (may increase in the future)
Restcloud ETL实践之数据行列转换
Xception学习笔记
在国内如何买港股的股?用什么平台安全一些?
Pytorch - - Basic Reference North Deux élèves du secondaire peuvent comprendre [Rétropropagation et Gradient descendant]
CentOS installs multiple versions of PHP and switches
Pycharm 打开远程目录 Remote Host
SWT / anr problem - deadlock
我的PMP学习考试心得
5款主流智能音箱入门款测评:苹果小米华为天猫小度,谁的表现更胜一筹?
Optimal Transport系列1
Résumé des styles de développement d'applets Wechat
Restcloud ETl数据通过时间戳实现增量数据同步
Mnasnet learning notes
7_OpenResty安装
Some uses of Halcon array
VirtualBox installation enhancements
[multi source BFS] 934 Shortest Bridge
Record a service deployment failure troubleshooting
[wechat applet development] style summary