Manage ConfigMaps using the saectl tool

更新时间:
复制 MD 格式

In SAE, configuration items correspond to the Kubernetes ConfigMap resource type. This topic describes how to create, view, update, and delete ConfigMaps using saectl, along with the supported YAML configuration fields.

Prerequisites

Before you begin, make sure you have:

Create a ConfigMap

  1. Create a file named cm.yaml with the following content. For a description of each field, see YAML configuration fields.

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: test-cm
      namespace: default
    data:
      product: "sae"
  2. From the directory containing cm.yaml, run:

    saectl apply -f cm.yaml

View ConfigMaps

List ConfigMaps

saectl get cm <configmap-name> -n <namespace>
  • Omit <configmap-name> to return all ConfigMaps in the namespace.

  • Omit -n <namespace> to use the default namespace.

The output is similar to:

NAMESPACE   NAME      DATA   AGE
default     test-cm   1      5m

The output includes the following fields:

FieldDescription
NAMESPACEThe namespace of the ConfigMap.
NAMEThe name of the ConfigMap.
DATAThe number of key-value pairs in the ConfigMap.
AGEHow long the ConfigMap has existed.

View ConfigMap details

Use either get or describe to inspect a ConfigMap's configuration.

Using `get` — returns configuration in YAML or JSON format:

saectl get cm <configmap-name> -o {yaml | json} -n <namespace>

Using `describe` — returns a human-readable summary:

saectl describe cm <configmap-name> -n <namespace>

The output is similar to:

Name:         test-cm
Namespace:    default
Labels:       <none>
Annotations:  <none>

Data
====
product:
----
sae

For both commands, omit -n <namespace> to use the default namespace.

Update a ConfigMap

Two commands are available: edit for inline editing, and apply for file-based updates.

Only the data field can be updated. Fields such as metadata.name, metadata.namespace, and metadata.uid are read-only after creation.

Edit a ConfigMap inline

  1. Open the ConfigMap's configuration in your editor:

    saectl edit cm <configmap-name> -n <namespace>
  2. Modify the configuration as needed. Save and close the file to apply the changes.

Update a ConfigMap from a file

Modify cm.yaml, then run:

saectl apply -f cm.yaml

Delete a ConfigMap

saectl delete cm <configmap-name> -n <namespace>

Omit -n <namespace> to use the default namespace.

YAML configuration fields

The following table describes the ConfigMap fields supported in SAE.

FieldDescription
metadata.nameThe name of the ConfigMap. Read-only after creation.
metadata.creationTimestampThe time when the ConfigMap was created. Read-only.
metadata.namespaceThe namespace the ConfigMap belongs to. Read-only after creation.
metadata.uidThe unique ID of the ConfigMap. Read-only.
dataThe key-value pairs stored in the ConfigMap. This is the only field that can be updated.