Deployment的暂停和恢复

# Deployment 暂停功能
[root@k8s-master01 ~]# kubectl rollout pause deployment nginx 
deployment.apps/nginx paused
[root@k8s-master01 ~]# kubectl set image deploy nginx nginx=nginx:1.15.3 --record
deployment.apps/nginx image updated
# 进行第二次配置变更,添加内存CPU配置
[root@k8s-master01 ~]# kubectl set -h
Configure application resources

 These commands help you make changes to existing application resources.

Available Commands:
  env            Update environment variables on a pod template
  image          Update image of a pod template
  resources      Update resource requests/limits on objects with pod templates
  selector       Set the selector on a resource
  serviceaccount Update ServiceAccount of a resource
  subject        Update User, Group or ServiceAccount in a RoleBinding/ClusterRoleBinding

Usage:
  kubectl set SUBCOMMAND [options]

Use "kubectl <command> --help" for more information about a given command.
Use "kubectl options" for a list of global command-line options (applies to all commands).
[root@k8s-master01 ~]# kubectl set resources deploy nginx -c nginx --limits=cpu=200m,memory=128Mi --requests=cpu=10m,memory=16Mi
deployment.apps/nginx resource requirements updated
[root@k8s-master01 ~]# kubectl get deploy nginx -oyaml
apiVersion: apps/v1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "11"
    kubernetes.io/change-cause: kubectl set image deploy nginx nginx=nginx:1.15.3
      --record=true
  creationTimestamp: "2020-09-19T02:41:11Z"
  generation: 18
  labels:
    app: nginx
  name: nginx
  namespace: default
  resourceVersion: "2660534"
  selfLink: /apis/apps/v1/namespaces/default/deployments/nginx
  uid: 1d9253a5-a36c-48cc-aefe-56f95967db66
spec:
  paused: true
  progressDeadlineSeconds: 600
  replicas: 2
  revisionHistoryLimit: 10
  selector:
    matchLabels:
      app: nginx
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: nginx
    spec:
      containers:
      - image: nginx:1.15.3
        imagePullPolicy: IfNotPresent
        name: nginx
        resources:
          limits:
            cpu: 200m
            memory: 128Mi
          requests:
            cpu: 10m
            memory: 16Mi
        terminationMessagePath: /dev/termination-log
        terminationMessagePolicy: File
      dnsPolicy: ClusterFirst
      restartPolicy: Always
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
status:
  availableReplicas: 2
  conditions:
  - lastTransitionTime: "2020-09-19T03:26:50Z"
    lastUpdateTime: "2020-09-19T03:26:50Z"
    message: Deployment has minimum availability.
    reason: MinimumReplicasAvailable
    status: "True"
    type: Available
  - lastTransitionTime: "2020-09-19T03:30:15Z"
    lastUpdateTime: "2020-09-19T03:30:15Z"
    message: Deployment is paused
    reason: DeploymentPaused
    status: Unknown
    type: Progressing
  observedGeneration: 18
  readyReplicas: 2
  replicas: 2
# 查看pod是否被更新
[root@k8s-master01 ~]# kubectl get po
NAME                     READY   STATUS    RESTARTS   AGE
nginx-6cdd5dd489-lv28z   1/1     Running   0          30m
nginx-6cdd5dd489-nqqz7   1/1     Running   0          30m
[root@k8s-master01 ~]# kubectl rollout resume deploy nginx 
deployment.apps/nginx resumed
[root@k8s-master01 ~]# kubectl get rs
NAME               DESIRED   CURRENT   READY   AGE
nginx-5475c49ffb   0         0         0       21m
nginx-5dfc8689c6   0         0         0       33m
nginx-66bbc9fdc5   0         0         0       52m
nginx-68db656dd8   1         1         0       15s
nginx-6cdd5dd489   2         2         2       31m
nginx-799b8478d4   0         0         0       21m
nginx-7d79b96f68   0         0         0       24m
nginx-f974656f7    0         0         0       21m
原文地址:https://www.cnblogs.com/Applogize/p/14383528.html