A secret is a type of resource that holds sensitive data, such as authentication and key information. Its content is user-defined. After creating secrets, you can use them as files or environment variables in a containerized workload.
Cluster and node resources have been created. For more information, see Creating a CCE Cluster. If you have available clusters and node resources, skip this operation.
Parameter |
Description |
---|---|
Name |
Name of the secret you create, which must be unique. |
Cluster |
Cluster that will use the secret you create. |
Namespace |
Namespace to which the secret belongs. If you do not specify this parameter, the value default is used by default. |
Description |
Description of a secret. |
Type |
Type of the secret you create.
|
Secret Data |
Workload secret data can be used in containers.
|
Secret Label |
Labels are attached to objects such as workloads, nodes, and Services in key-value pairs. Labels define the identifiable attributes of these objects and are used to manage and select the objects.
|
To create a resource by uploading a file, ensure that the resource description file has been created. CCE supports files in JSON or YAML format. For more information, see Secret Resource File Configuration.
The new secret is displayed in the key list.
This section describes configuration examples of secret resource description files.
For example, you can retrieve the username and password for a workload through a secret.
The secret.yaml file is defined as shown below. The value must be based on the Base64 coding method. For details about the method, 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 Base64-encoded. password: ****** #The value must be encoded using Base64. type: Opaque #You are advised not to change this parameter value.
# echo -n "content to be encoded" | base64 ******
vi cce-secret.yaml
apiVersion: v1 kind: Secret metadata: name: mysecret type: Opaque data: username: ****** password: ******
kubectl create -f cce-secret.yaml
You can query the secret after creation.
kubectl get secret
The secret list contains system secret resources that can be queried only. The system secret resources cannot be updated or deleted.
Operation |
Description |
---|---|
Viewing a YAML file |
Click View YAML next to the secret name to view the YAML file corresponding to the current secret. |
Updating a secret |
|
Deleting a secret |
Select the secret you want to delete and click Delete. Follow the prompts to delete the secret. |
Deleting secrets in batches |
|