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/v1beta1/namespaces/{namespace}/deployments/{name}

Table 1 describes the parameters of this API.

Table 1 Parameter

Parameter

Mandatory

Description

name

Yes

Name of the Deployment.

namespace

Yes

Namespace to which the Deployment you want to update belongs.

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.

For the description about request parameters, see Table 2.

Example request

{
    "metadata": {
        "annotations": {
            "description": "test"
        }
    }
}

Response

Response parameters

For the description about response parameters, see Table 2.

Example response

{
    "kind": "Deployment", 
    "apiVersion": "apps/v1beta1", 
    "metadata": {
        "name": "deployment-test", 
        "namespace": "8f6c39e7c269440c881bba2fc49586d6", 
        "selfLink": "/apis/apps/v1beta1/namespaces/8f6c39e7c269440c881bba2fc49586d6/deployments/deployment-test", 
        "uid": "ed89a51c-2728-11e8-b891-84a9c46e8c8b", 
        "resourceVersion": "4510945", 
        "generation": 4, 
        "creationTimestamp": "2018-03-14T01:42:17Z", 
        "labels": {
            "appgroup": ""
        }, 
        "annotations": {
            "deployment.kubernetes.io/revision": "1", 
            "description": "test"
        }, 
        "enable": true
    }, 
    "spec": {
        "replicas": 1, 
        "selector": {
            "matchLabels": {
                "app": "deployment-test"
            }
        }, 
        "template": {
            "metadata": {
                "creationTimestamp": null, 
                "labels": {
                    "app": "deployment-test"
                }, 
                "annotations": {
                    "com.huawei.scheduler/container-type": "secure-container", 
                    "metrics.alpha.kubernetes.io/custom-endpoints": "[{api:'',path:'',port:'',names:''}]"
                }, 
                "enable": true
            }, 
            "spec": {
                "containers": [
                    {
                        "name": "container-0", 
                        "image": "nginx:latest", 
                        "resources": {
                            "limits": {
                                "cpu": "500m", 
                                "memory": "1024Mi"
                            }, 
                            "requests": {
                                "cpu": "500m", 
                                "memory": "1024Mi"
                            }
                        }, 
                        "lifecycle": {}, 
                        "terminationMessagePath": "/dev/termination-log", 
                        "terminationMessagePolicy": "File", 
                        "imagePullPolicy": "Always"
                    }
                ], 
                "restartPolicy": "Always", 
                "terminationGracePeriodSeconds": 30, 
                "dnsPolicy": "ClusterFirst", 
                "securityContext": {}, 
                "imagePullSecrets": [
                    {
                        "name": "imagepull-secret"
                    }
                ], 
                "affinity": {}, 
                "schedulerName": "default-scheduler"
            }
        }, 
        "strategy": {
            "type": "RollingUpdate", 
            "rollingUpdate": {
                "maxUnavailable": 1, 
                "maxSurge": 0
            }
        }, 
        "revisionHistoryLimit": 2, 
        "progressDeadlineSeconds": 600
    }, 
    "status": {
        "observedGeneration": 3, 
        "replicas": 1, 
        "updatedReplicas": 1, 
        "unavailableReplicas": 1, 
        "conditions": [
            {
                "type": "Available", 
                "status": "True", 
                "lastUpdateTime": "2018-03-14T01:42:17Z", 
                "lastTransitionTime": "2018-03-14T01:42:17Z", 
                "reason": "MinimumReplicasAvailable", 
                "message": "Deployment has minimum availability."
            }, 
            {
                "type": "Progressing", 
                "status": "True", 
                "lastUpdateTime": "2018-03-14T01:42:17Z", 
                "lastTransitionTime": "2018-03-14T01:42:17Z", 
                "reason": "ReplicaSetUpdated", 
                "message": "ReplicaSet \"deployment-test-4094680052\" is progressing."
            }
        ]
    }
}

Status Code

Table 2 describes the status code of this API.

Table 2 Status code

Status Code

Description

200

This operation succeeds.

For more status codes, see Status Codes.