当前位置:网站首页>kubernetes的Controller之deployment
kubernetes的Controller之deployment
2022-06-26 14:38:00 【华为云】
kubernetes的Controller之deployment
Controller是kubernetes集群中管理和运行容器的对象,pod通过Controller进行应用的操作,Controller与pod通过label标签来对应,Controller可以进行负载
deployment是pod控制器的一种,部署无状态的应用,它用来管理pod和replicaSet,它支持滚动升级等功能
使用yaml来创建应用
首先我们使用命令创建一个yaml文件
kubectl create deployment web --image=nginx --dry-run -o yaml > nginx.yaml其中web表示应用的名字
这样我们就可以生成一个Nginx的yaml文件,然后可以基于这个文件做修改,使用这个文件的话使用命令
kubectl apply -f nginx.yaml然后对外暴露端口:
kubectl expose deployment web --port=80 --type=NodePort --target-port=80 --name=web1 -o yaml > web1.yaml其中port是内部端口,target-port是对外暴露的端口
完成之后可以使用下面的命令查看服务的状态
kubectl get pods,svc我们刚才说它支持应用的升级、回滚和弹性伸缩
升级
使用命令
kubectl set image deployment web nginx=nginx:1.16通过设置应用的版本号来让应用升级
升级的过程在应用容器创建完成后旧版本的应用才会暂停
查看升级状态
kubectl rollout status deployment webname回滚上一版本命令:
kubectl rollout undo deployment web也可以回滚到指定的版本,加入参数- -to revision=3
查看历史版本
kubectl rollout history deployment web总结
deployment可以保证支撑服务的pod数量,动态伸缩,弹性扩缩容,但是它没有解决如何进行服务访问的问,当新的节点以新的ip启动的时候,不能确定它的ip和端口,从而不能进行服务的发现和负载均衡,这就需要service对象了。service就像个注册中心,通过service拿到提供的ip和port,service还可以进行负载均衡,pod和service的关联是通过label和selector进行关联的。Service三种常用的类型有ClusterIp,NodePort和LoadBalancer,默认是ClusterIp,LoadBalancer可以在对外访问的时候。可以添加yaml文件中type字段的属性值更改service类型。
️ 感谢大家
如果你觉得这篇内容对你挺有有帮助的话:
- 欢迎关注我️,点赞,评论,转发
- 关注
盼盼小课堂,定期为你推送好文,还有群聊不定期抽奖活动,可以畅所欲言,与大神们一起交流,一起学习。 - 有不当之处欢迎批评指正。
边栏推荐
- 710. 黑名单中的随机数
- IP certificate application process of sectigo
- Mathematical modeling of war preparation 30 regression analysis 2
- How to personalize VIM editor format (DIY)
- Common evaluation indexes of classification model -- confusion matrix and ROC curve
- Naacl2022: (code practice) good visual guidance promotes better feature extraction, multimodal named entity recognition (with source code download)
- Is it safe to open an account by digging money? Is there any risk?
- 2021-10-29 atcoder ABC157——B - Bingo
- 'coach, I want to play basketball!'—— AI Learning Series booklet for system students
- 15 bs对象.节点名称.节点名称.string 获取嵌套节点内容
猜你喜欢

JVM 输出 GC 日志导致 JVM 卡住,我 TM 人傻了

Unity uses skybox panoramic shader to make panorama preview. There is a gap. Solution

关于 selenium.common.exceptions.WebDriverException: Message: An unknown server-side error 解决方案(已解决)

Stream常用操作以及原理探索

北京银行x华为:网络智能运维夯实数字化转型服务底座

Leaflet loading ArcGIS for server map layers

The annual salary of 500000 is one line, and the annual salary of 1million is another line

Use abp Zero builds a third-party login module (II): server development

View触摸分析

【 Native cloud】 Éditeur ivx Programmable par tout le monde
随机推荐
Datasets dataset class (2)
Numpy basic use
在云服务器中云磁盘如何挂载
Sharing ideas for a quick switch to an underlying implementation
Oracle ASMM and AMM
工作上对金额价格类小数点的总结以及坑
Informatics Olympiad all in one 1400: count the number of words (string matching)
Error when redis is started: could not create server TCP listening socket *: 6379: bind: address already in use - solution
启动Redis报错:Could not create Server TCP listening socket *:6379: bind: Address already in use–解决办法
Oracle ASMM和AMM
通俗语言说BM3D
fileinput. js php,fileinput
Leaflet load day map
备战数学建模30-回归分析2
A remove the underline from the label
nvidia-smi 报错
R语言glm函数逻辑回归模型、使用epiDisplay包logistic.display函数获取模型汇总统计信息(自变量初始和调整后的优势比及置信区间,回归系数的Wald检验的p值)、结果保存到csv
秒懂JSONArray和JSONObject的区别和使用
NAACL2022:(代码实践)好的视觉引导促进更好的特征提取,多模态命名实体识别(附源代码下载)...
Complimentary Book Cognitive Control: how does our brain accomplish tasks?