Secrets

A secret is a type of resource that holds sensitive data, such as authentication and key information, required by a workload. Its content is user-defined. After a secret is created on the MCP console, a secret with the same name is created in all clusters deployed on this MCP instance.

Creating a Secret

  1. Log in to the MCP console. In the navigation pane, choose Resource Management > Configuration Center, and click Create Secret under the Secrets tab.
  2. Set the parameters listed in Table 1.

    Table 1 Parameters for creating a secret

    Parameter

    Description

    Name

    Name of a secret, which must be unique in the same namespace.

    Namespace

    Namespace to which the secret belongs. If you do not specify this parameter, the value default is used by default.

    Cluster

    Cluster whether the secret is to be deployed.

    Type

    Type of the secret.

    • Opaque: common secret. In high-sensitive scenarios, you are advised to encrypt sensitive data using data encryption services and then store the encrypted data in secrets.
    • kubernetes.io/dockerconfigjson: a secret that stores the authentication information required for pulling images from a private repository. Enter an image repository address.
    • IngressTLS: a secret that stores the certificate required by ingresses (layer-7 load balancing Services).
    • Other: another type of secret, which is specified manually.

    Data

    Workload secret data can be used in containers.

    • If the secret type is Opaque, enter the key and value. The value must be a Base64-encoded value. You can click Perform Base64 Encoding in the Operation column to convert the entered value to a Base64-encoded value. For details about the Base64 encoding method, see Base64 Encoding.
    • If the secret type is kubernetes.io/dockerconfigjson, enter the account and password of the private image repository.

    Label

    Labels are attached to objects such as workloads, nodes, and Services in key-value pairs.

    Labels define identified attributes of these objects and can be used to manage and select objects.

    1. Click Add Label.
    2. Set Key and Value.

    Description

    Description of the secret.

  3. Click Create after the configuration is complete.

    The new secret is displayed in the secret list.

Using a Secret

After the secret is created, you can mount the secret to a container during workload creation (for details, see Deployments). Then, you can read the secret data from the mount path of the container.

Base64 Encoding

To encode a character string using Base64, run the echo -n Content to be encoded | base64 command. The following is an example:

root@ubuntu:~# echo -n "Content to be encoded" | base64
******

Related Operations

After a secret is created, you can perform the operations described in Table 2.
Table 2 Other operations

Operation

Description

Viewing a YAML file

Click View YAML in the row where the target secret resides to view its YAML file.

Updating a secret

  1. Choose More > Update in the row where the target secret resides.
  2. Modify the secret information according to Table 1.
  3. Click Update.

Deleting a secret

  1. Select the secrets to be deleted.
  2. Choose More > Delete in the Operation column.
  3. Click Yes.

Viewing events

Select a secret and choose More > View Event in the Operation column to view the events of the secret.

NOTE:

Event data will be retained for 1 hour and then automatically deleted.