当前位置:网站首页>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类型。
️ 感谢大家
如果你觉得这篇内容对你挺有有帮助的话:
- 欢迎关注我️,点赞,评论,转发
- 关注
盼盼小课堂
,定期为你推送好文,还有群聊不定期抽奖活动,可以畅所欲言,与大神们一起交流,一起学习。 - 有不当之处欢迎批评指正。
边栏推荐
- How to personalize VIM editor format (DIY)
- Heap optimization dijkstra/hash table storage node number
- nvidia-smi 报错
- Detailed explanation of C language programming problem: can any three sides form a triangle, output the area of the triangle and judge its type
- Deploy the flask environment using the pagoda panel
- BM3D in popular language
- 工作上对金额价格类小数点的总结以及坑
- NAACL2022:(代码实践)好的视觉引导促进更好的特征提取,多模态命名实体识别(附源代码下载)...
- 启动Redis报错:Could not create Server TCP listening socket *:6379: bind: Address already in use–解决办法
- 备战数学建模31-数据插值与曲线拟合3
猜你喜欢
Use abp Zero builds a third-party login module (I): Principles
This is the graceful file system mounting method, which is effective through personal testing
The engine "node" is inconsistent with this module
Unity 利用Skybox Panoramic着色器制作全景图预览有条缝隙问题解决办法
【使用yarn运行报错】The engine “node“ is incompatible with this module.
这才是优美的文件系统挂载方式,亲测有效
【 Native cloud】 Éditeur ivx Programmable par tout le monde
年薪50万是一条线,年薪100万又是一条线…...
View触摸分析
Authoritative announcement on the recruitment of teachers in Yan'an University in 2022
随机推荐
View触摸分析
R语言dplyr包bind_rows函数把两个dataframe数据的行纵向(竖直)合并起来、最终行数为原来两个dataframe行数的加和(Combine Data Frames)
ArcGIS secondary development -- arcpy batch automatic map publishing service
券商经理给的开户链接办理股票开户安全吗?我想开个户
Is it safe to open a stock account with the account manager online??
qt下多个子控件信号槽绑定方法
Numpy basic use
Where do people get their top energy?
'教练,我想打篮球!' —— 给做系统的同学们准备的 AI 学习系列小册
Complimentary Book Cognitive Control: how does our brain accomplish tasks?
Solution to the upper limit of TeamViewer display devices
Excel-VBA 快速上手(二、条件判断和循环)
Two dimensional DFS
R语言glm函数逻辑回归模型、使用epiDisplay包logistic.display函数获取模型汇总统计信息(自变量初始和调整后的优势比及置信区间,回归系数的Wald检验的p值)、结果保存到csv
2022年最新贵州建筑八大员(机械员)模拟考试题库及答案
启动Redis报错:Could not create Server TCP listening socket *:6379: bind: Address already in use–解决办法
权威发布 | 延安大学2022年教师岗位招聘公告
【使用yarn运行报错】The engine “node“ is incompatible with this module.
Deploy the flask environment using the pagoda panel
网上找客户经理办理股票开户安全吗??