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
- Log in to the MCP console. In the navigation pane, choose Resource Management > Configuration Center, and click Create Secret under the Secrets tab.
- 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.
- Click Add Label.
- Set Key and Value.
Description
Description of the secret.
- 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
| 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 |
|
| Deleting a secret |
|
| 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. |
Last Article: ConfigMaps
Next Article: Policy Center
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.