Kubernetes概念之deployment
一整天一整天的坐在办公室,真的很~~~,懵圈中....,求解救。
本文通过《Kubernetes权威指南》的概念部分学习总结
Deployment作用
Deployment与RC的作用其实是一样的,都是为了管理Pod的副本数
Deployment的使用场景
1)创建一个Deployment对象来生成对应的Replica Set并完成Pod副本的创建过程。
2)检查Deployment的状态来看部署动作是否完成(Pod副本的数量是否达到了预期的值)
3)更新Deployment以创建新的Pod
4)如果当前Deployment不稳定,则回滚到一个早先的Deployment版本
5)挂起或者恢复一个Deployment
例子
创建一个deployment,管理一个运行tomcat的pod
1、创建deployment.yaml文件
apiVersion: extensions/v1beta1 kind: Deployment metadata: name: frontend spec: replicas: 1 selector: matchLabels: tier: frontend matchExpressions: - {key: tier, operator: In, values: [frontend]} template: metadata: labels: app: app-demo tier: frontend spec: containers: - name: tomcat-demo image: tomcat imagePullPolicy: IfNotPresent ports: - containerPort: 8080
2、创建deployment
[root@master ~]# kubectl create -f tomcat-deployment.yaml
deployment.extensions/frontend created
3、查看deployment信息
[root@master ~]# kubectl get deployment NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE frontend 1 1 1 1 23s
输出结果的含义:
DESIRED:Pod副本数量的期望值,即deployment里定义的Replica
CURRENT:当前Replica的值,这个值会不断的增加,直到达到DESIRED为止,表明整个部署过程完成
UP-TO-DATE:最新版本的Pod的副本数量,用于指示在滚动升级过程中,有多少个Pod副本已经成功升级
AVAILABEL:当前集群中可用的Pod副本数量,即集群中当前存活的Pod数量
4、查看Pods信息
[root@master ~]# kubectl get pods NAME READY STATUS RESTARTS AGE frontend-6cfdb4d686-j8jj7 1/1 Running 0 9m
5、查看deployment的详细信息
[root@master ~]# kubectl describe deployment Name: frontend Namespace: default CreationTimestamp: Fri, 20 Sep 2019 06:40:40 +0000 Labels: app=app-demo tier=frontend Annotations: deployment.kubernetes.io/revision=1 Selector: tier=frontend,tier in (frontend) Replicas: 1 desired | 1 updated | 1 total | 1 available | 0 unavailable StrategyType: RollingUpdate MinReadySeconds: 0 RollingUpdateStrategy: 1 max unavailable, 1 max surge Pod Template: Labels: app=app-demo tier=frontend Containers: tomcat-demo: Image: tomcat Port: 8080/TCP Host Port: 0/TCP Environment: <none> Mounts: <none> Volumes: <none> Conditions: Type Status Reason ---- ------ ------ Available True MinimumReplicasAvailable Progressing True NewReplicaSetAvailable OldReplicaSets: <none> NewReplicaSet: frontend-6cfdb4d686 (1/1 replicas created) Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal ScalingReplicaSet 9m deployment-controller Scaled up replica set frontend-6cfdb4d686 to 1
作者:李先生
-------------------------------------------
个性签名:在平凡中坚持前行,总有一天会遇见不一样的自己!
如果觉得这篇文章对你有小小的帮助的话,记得在右下角点个“推荐”哦,博主在此感谢!
万水千山总是情,打赏一分行不行,所以如果你心情还比较高兴,也是可以扫码打赏博主,哈哈哈(っ•̀ω•́)っ✎⁾⁾!
![微信公众号](https://images.cnblogs.com/cnblogs_com/lemon-le/871591/o_w2.png)
![微信打赏](https://www.cnblogs.com/images/cnblogs_com/lemon-le/871591/o_wechat.png)
![微信打赏](https://www.cnblogs.com/images/cnblogs_com/lemon-le/871591/o_zhifubao.png)
微信公众号 微信打赏 支付宝打赏
posted on 2019-09-20 16:05 Captain_Li 阅读(1693) 评论(2) 编辑 收藏 举报