kubernetes概念 - Kubenetes Deployment
Deployment当中借助于ReplicaSet进行更新的策略反映在Deployment的对象定义所需字段可使用kubectl explain deploy,Deployment属于extension群组。在1.10版本中它被移至到apps群组。他与ReplicaSet相比增加了几个字段。 stratgy 重要字段,定义更新策略,它支持两种策略 重建式更新 Recreate与滚动更新RollingUpdate,如果type为RollingUpdate,那么RollingUpdate的策略还可以使用RollingUpdate来定义,如果type为Recreate,那么RollingUpdate字段无效。 默认值为RollingUpdate stratgy.RollingUpdate控制RollingUpdate更新力度 maxSurge 对应的更新过程当中,最多能超出目标副本数几个。有两种取值方式,为直接指定数量和百分比。在使用百分比时,在计算数据时如果不足1会补位1个。 maxUnavailable 最多有几个副本不可用。 revisionHistoryLimit 滚动更新后,在历史当中最多保留几个历史版本,默认10。 在使用Deployment创建Pod时,Deployment会自动创建ReplicaSet,而且Deployment名称是使用Pod模板的hash值,此值是固定的。 Deployment在实现更新应用时,可以通过编辑配置文件来实现,使用kubectl apply -f更改每次变化。每次的变化通过吧变化同步至apiserver中,apiserver发现其状态与etcd不同,从而改变etcd值来实现修改其期望状态,来实现现有状态去逼近期望状态。 kubectl explain deploy yaml 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 apiVersion: apps/v1 kind: Deployment metadata: name: app-deploy namespace: default spec: replicas: 2 selector: matchLabels: app: deploy release: canary template: metadata: labels: app: deploy release: canary spec: containers: - name: my-deploy image: node01:5000/busybox:v1 ports: - name: http containerPort: 80 command: ["/bin/sh","-c","/bin/httpd -f -h /tmp"] 使用kubectl apply 声明式更新、创建资源对象。...