• Cloud Container Engine

cce
  1. Help Center
  2. Cloud Container Engine
  3. API Reference
  4. Secret (Native Kubernetes APIs)
  5. Replacing a Specified Secret

Replacing a Specified Secret

Function

This API is used to replace a secret object under a specified Namespace.

The following fields can be updated:

  • metadata.selfLink
  • metadata.resourceVersion
  • metadata.generation
  • metadata.creationTimestamp
  • metadata.deletionTimestamp
  • metadata.labels
  • metadata.clusterName
  • metadata.generateName
  • metadata.annotations
NOTE:
  • When the value of type is Opaque, both key and value of data can be updated.
  • When the value of type is not Opaque, only value of data can be updated.

URI

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

Table 1 describes the parameters of this API.

Table 1 Parameter description

Parameter

Mandatory

Description

pretty

No

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

namespace

Yes

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

name

Yes

Name of the Secret.

Request

Request parameters:

For the description about request parameters, see Table 2.

Example request:

{ 
   "apiVersion": "v1", 
   "kind": "Secret", 
   "metadata": { 
     "name": "mysecret" 
   }, 
   "type": "Opaque", 
   "data": { 
    "password": "******", #The Base64 coding scheme is required. The method is as follows: echo -n "Content to be encoded" | base64
    "username": "******", #The Base64 coding scheme is required. The method is as follows: echo -n "Content to be encoded" | base64
   } 
 }

Response

Response parameters:

For the description about response parameters, see the parameter description in Request.

Example response:

{
    "kind": "Secret",
    "apiVersion": "v1",
    "metadata": {
        "name": "mysecret",
        "namespace": "ns-12130306-s",
        "selfLink": "/api/v1/namespaces/ns-12130306-s/secrets/mysecret",
        "uid": "0bbfb314-dfb3-11e7-9c19-fa163e2d897b",
        "resourceVersion": "418375",
        "creationTimestamp": "2017-12-13T03:09:34Z",
        "enable": true
    },
    "data": {
        "password": "******", 
        "username": "******", 
    },
    "type": "Opaque",
    "httpcode": 200,
    "header": {
        "X-Frame-Options": "SAMEORIGIN",
        "Strict-Transport-Security": "max-age=31536000; includeSubdomains;",
        "Server": "Web Server",
        "X-Router-Status": "fresh,upstream return 200",
        "X-Content-Type-Options": "nosniff",
        "Connection": "keep-alive",
        "X-Download-Options": "noopen",
        "Set-Cookie": "efdcc980e5624bc68b22fc14c24c3d58=WyI3NjkyODcxNzciXQ; Expires=Thu, 14-Dec-17 03:09:34 GMT; Domain=192.145.50.250; Path=/; Secure; HttpOnly",
        "Content-Length": "364",
        "X-XSS-Protection": "1; mode=block;",
        "Date": "Wed, 13 Dec 2017 03:09:34 GMT",
        "Content-Type": "application/json"
    }
}

Status Code

Table 2 describes the status code of this API.

Table 2 Status code

Status Code

Description

200

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

For the description about status codes, see section Status Codes.