Updating a Secret

Function

This API is used to update some information about a specified secret.

URI

PATCH /api/v1/namespaces/{namespace}/secrets/{name}

Table 1 Path parameters

Parameter

Description

namespace

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

name

Name of the secret.

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

Content-Type: application/merge-patch+json
{
    "data": {
        "test2": "dGVzdA=="
    }
}

Response

Response parameters

For the description about response parameters, see Table 123.

Example response

Add a key-value pair "test2": "dGVzdA==" for the secret created in Creating a Secret.

{
    "kind": "Secret",
    "apiVersion": "v1",
    "metadata": {
        "name": "secret-test",
        "namespace": "namespace-test",
        "selfLink": "/api/v1/namespaces/namespace-test/secrets/secret-test",
        "uid": "e6170b6d-aff6-11e8-8f17-c81fbe371a17",
        "resourceVersion": "5199399",
        "creationTimestamp": "2018-09-04T03:59:19Z",
        "enable": true
    },
    "data": {
        "key1": "MWYyZDFlMmU2N2Rm",
        "key2": "YWRtaW4=",
        "test2": "dGVzdA=="
    },
    "type": "Opaque"
}

Status Code

Table 3 describes the status code of this API.

Table 3 Status code

Status Code

Description

200

OK

For more status codes, see Status Codes.