Updating a Deployment

Function

This API is used to update a specified deployment.

The following fields can be updated:

  • metadata.labels
  • metadata.generateName
  • metadata.annotations
  • spec.template
  • spec.replicas
  • spec.revisionHistoryLimit
  • spec.progressDeadlineSeconds

URI

PATCH /apis/apps/v1/namespaces/{namespace}/deployments/{name}

Table 1 Path parameters

Parameter

Description

namespace

Object name and auth scope, such as for teams and projects.

name

Name of the deployment.

Table 2 Query parameter

Parameter

Mandatory

Description

pretty

No

If 'true', then the output is pretty printed.

Request

Request parameters

For the description about the Content-Type field, see Patch Request Method Operation Description.

Example request

Change the label of the deployment created in Creating a Deployment to deployment-test2.

Content-Type: application/merge-patch+json
{
    "metadata": {
        "labels": {
            "app": "deployment-test2"
        }
    }
}

Response

Response parameters

For the description about response parameters, see Table 79.

Example response

{
    "kind": "Deployment",
    "apiVersion": "apps/v1",
    "metadata": {
        "name": "deployment-test",
        "namespace": "namespace-test",
        "selfLink": "/apis/apps/v1/namespaces/namespace-test/deployments/deployment-test",
        "uid": "777dce52-b186-11e8-8cb0-c81fbe371a17",
        "resourceVersion": "5657176",
        "generation": 2,
        "creationTimestamp": "2018-09-06T03:39:32Z",
        "labels": {
            "app": "deployment-test2"
        },
        "annotations": {
            "deployment.kubernetes.io/revision": "2"
        },
        "enable": true
    },
    "spec": {
        "replicas": 2,
        "selector": {
            "matchLabels": {
                "app": "redis"
            }
        },
        "template": {
            "metadata": {
                "creationTimestamp": null,
                "labels": {
                    "app": "redis"
                },
                "enable": true
            },
            "spec": {
                "containers": [
                    {
                        "name": "container-0",
                        "image": "*.*.*.*:20202/cci/redis:V1",
                        "resources": {
                            "limits": {
                                "cpu": "500m",
                                "memory": "1Gi"
                            },
                            "requests": {
                                "memory": "1Gi",
                                "cpu": "500m"
                            }
                        },
                        "terminationMessagePath": "/dev/termination-log",
                        "terminationMessagePolicy": "File",
                        "imagePullPolicy": "IfNotPresent"
                    }
                ],
                "restartPolicy": "Always",
                "terminationGracePeriodSeconds": 30,
                "dnsPolicy": "ClusterFirst",
                "securityContext": {},
                "imagePullSecrets": [
                    {
                        "name": "imagepull-secret"
                    }
                ],
                "schedulerName": "default-scheduler"
            }
        },
        "strategy": {
            "type": "RollingUpdate",
            "rollingUpdate": {
                "maxUnavailable": "25%",
                "maxSurge": "25%"
            }
        },
        "revisionHistoryLimit": 10,
        "progressDeadlineSeconds": 600
    },
    "status": {
        "observedGeneration": 2,
        "replicas": 2,
        "updatedReplicas": 2,
        "readyReplicas": 2,
        "availableReplicas": 2,
        "conditions": [
            {
                "type": "Available",
                "status": "True",
                "lastUpdateTime": "2018-09-06T04:14:14Z",
                "lastTransitionTime": "2018-09-06T04:14:14Z",
                "reason": "MinimumReplicasAvailable",
                "message": "Deployment has minimum availability."
            },
            {
                "type": "Progressing",
                "status": "True",
                "lastUpdateTime": "2018-09-06T04:14:24Z",
                "lastTransitionTime": "2018-09-06T03:39:32Z",
                "reason": "NewReplicaSetAvailable",
                "message": "ReplicaSet \"deployment-test-68585dfddb\" has successfully progressed."
            }
        ]
    }
}

Status Code

Table 3 describes the status code of this API.

Table 3 Status code

Status Code

Description

200

This operation succeeds, and a Deployment resource object is returned.

For more status codes, see Status Codes.