Replacing a Deployment

Function

This API is used to replace a specified Deployment.

The following fields can be updated:

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

URI

PUT /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 replace belongs.

pretty

No

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

Request

Request parameters

For the description about request parameters, see Table 2.

Example request

{
    "apiVersion": "apps/v1beta1", 
    "kind": "Deployment", 
    "metadata": {
        "annotations": {
            "description": ""
        }, 
        "labels": {
            "appgroup": ""
        }, 
        "name": "deployment-test"
    }, 
    "spec": {
        "replicas": 1, 
        "selector": {
            "matchLabels": {
                "app": "deployment-test"
            }
        }, 
        "template": {
            "metadata": {
                "annotations": {
                    "metrics.alpha.kubernetes.io/custom-endpoints": "[{api:'',path:'',port:'',names:''}]", 
                    "com.huawei.scheduler/container-type": "secure-container"
                }, 
                "labels": {
                    "app": "deployment-test"
                }
            }, 
            "spec": {
                "containers": [
                    {
                        "image": "nginx:latest", 
                        "name": "container-0", 
                        "resources": {
                            "limits": {
                                "cpu": "500m", 
                                "memory": "1024Mi"
                            }, 
                            "requests": {
                                "cpu": "500m", 
                                "memory": "1024Mi"
                            }
                        }, 
                        "lifecycle": {}
                    }
                ], 
                "imagePullSecrets": [
                    {
                        "name": "imagepull-secret"
                    }
                ], 
                "affinity": {}
            }
        }, 
        "minReadySeconds": 0, 
        "strategy": {
            "type": "RollingUpdate", 
            "rollingUpdate": {
                "maxSurge": 0, 
                "maxUnavailable": 1
            }
        }
    }
}

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": "4510942", 
        "generation": 3, 
        "creationTimestamp": "2018-03-14T01:42:17Z", 
        "labels": {
            "appgroup": ""
        }, 
        "annotations": {
            "description": ""
        }, 
        "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": "1", 
                                "memory": "1024Mi"
                            }, 
                            "requests": {
                                "cpu": "1", 
                                "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": 2, 
        "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.