Creating a Secret
Secrets are user-defined resources that store authentication and sensitive information such as application keys. They can be used as files or environment variables in applications.
Prerequisites
You have created cluster and node resources. For more information, see Infrastructure Management. If cluster and node resources are already available, skip this operation.
Creating a Secret
- Log in to ServiceStage and choose Application Management > Application Configuration > Secret.
- Click Create Secret.
- Create a secret by Visualization or YAML.
- Manner 1. Visualization. On the displayed page, set the parameters listed in the following table. Parameters marked with an asterisk (*) are mandatory.
Table 1 Parameters for creating a secret Parameter
Description
Basic Information
*Name
Name of the secret, which must be unique in the same namespace.
*Cluster
Cluster where the secret will be used.
*Namespaces
Namespace to which the secret belongs. The default value is default.
Description
Description of the secret.
*Secret Type
Type of the secret. Options:
- Opaque: general secret type.
- dockerconfigjson: stores and pulls the authentication information required by private repository images.
- IngressTLS: stores the certificate required by Layer-7 ELB.
- Other: Enter a secret type that is none of the above.
Secret Data
Used in applications.
- Opaque secrets
- Click Add Data.
- Set keys and values. Keys must be encoded using Base64. For more information, see Base64 Encoding.
- dockerconfigjson secrets: Enter the username and password of a private image repository.
- IngressTLS secrets: Upload certificates and private key files.
Secret Label
Labels are attached to objects, such as applications, nodes, and services, in the form of key-value pairs.
Labels define the identifiable attributes of these objects and are used to manage and select the objects.
- Click Add Label.
- Set keys and values.
- Method 2. YAML.
To create a secret by uploading a file, ensure that a resource description file has been created. ServiceStage supports resource description files in JSON or YAML format. For more information, see Secret Resource File Configuration.
- Select a cluster from the Cluster drop-down list.
- (Optional) Click Upload File, select the created secret file, and then click Open.
Upload a file whose size is smaller than 2 MB. The file can be uploaded in the YAML format.
- Write or modify the secret file in Orchestration content.
- Manner 1. Visualization. On the displayed page, set the parameters listed in the following table. Parameters marked with an asterisk (*) are mandatory.
- After the configuration is complete, click Create.
The new secret is displayed in the secret list.
Secret Resource File Configuration
This section provides examples of configuring secret resource description files.
For example, to retrieve the username and password for an application, you can prepare a secret file.
username: my-username
password: my-password
- YAML format
The following shows the content of a secret file named secret.yaml. The value must be encoded using Base64. For more information, see Base64 Encoding.
apiVersion: v1 kind: Secret metadata: name: mysecret #Secret name. namespace: default #Namespace. The default value is default. data: username: ****** #The value must be encoded using Base64. password: ****** #The value must be encoded using Base64. type: Opaque #You are advised not to change this parameter value.
- JSON format
The following shows the content of a secret file named secret.json.
{ "apiVersion": "v1", "kind": "Secret", "metadata": { "name": "mysecret", "namespace": "default" }, "data": { "username": "******", "password": "******" }, "type": "Opaque" }
Base64 Encoding
To encrypt a character string using Base64, run the echo -n to-be-encoded content | base64 command. The following is an example.
root@ubuntu:~# echo -n "3306" | base64 MzMwNg==
Modifying or Deleting a Secret
The secret list contains system secret resources, which can only be viewed and cannot be modified or deleted.
| Operation | Description |
|---|---|
| Modifying a secret |
|
| Deleting a secret | Click Delete in the Operations column of the secret to be deleted, and follow the system prompts to delete the secret. |
| Deleting secrets in batches |
|
Last Article: Application Configuration
Next Article: Creating a Configuration Item
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.