Skip to content

Commit 1668bf6

Browse files
committed
Revise example section
1 parent 027cba9 commit 1668bf6

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

AKS-Arc/encrypt-etcd-secrets.md

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Encrypt etcd secrets for Kubernetes clusters in AKS on Azure Local
33
description: Learn how to encrypt etcd secrets in AKS on Azure Local.
44
author: sethmanheim
55
ms.topic: how-to
6-
ms.date: 04/10/2025
6+
ms.date: 04/11/2025
77
ms.author: sethm
88
ms.lastreviewed: 04/10/2025
99
ms.reviewer: khareanushka
@@ -62,7 +62,7 @@ kubectl get --raw='/readyz?verbose'
6262
To verify that secrets and data has been encrypted using a KMS plugin, [see the Kubernetes documentation](https://kubernetes.io/docs/tasks/administer-cluster/kms-provider/#verifying-that-the-data-is-encrypted). You can use the following commands to verify that the data is encrypted:
6363

6464
```azurecli
65-
kubectl exec --stdin --tty <etcd pod name> -n kube-system -- etcdctl --cacert /etc/kubernetes/pki/etcd/ca.crt --key /etc/kubernetes/pki/etcd/server.key --cert /etc/kubernetes/pki/etcd/server.crt get /registry/secrets/default/db-user-pass -w fields
65+
kubectl exec --stdin --tty <etcd pod name> -n kube-system --etcdctl --cacert /etc/kubernetes/pki/etcd/ca.crt --key /etc/kubernetes/pki/etcd/server.key --cert /etc/kubernetes/pki/etcd/server.crt get /registry/secrets/default/db-user-pass -w fields
6666
```
6767

6868
- `kubectl exec`: This is the kubectl command used to execute a command inside a running pod. It allows you to run commands within the container of a pod.
@@ -75,11 +75,29 @@ kubectl exec --stdin --tty <etcd pod name> -n kube-system -- etcdctl --cacert /e
7575
```
7676

7777
- `-n kube-system`: This flag specifies the namespace where the pod is located. kube-system is the default namespace used by Kubernetes for system components, such as etcd, kube-dns, and other control plane services.
78+
- `--etcdctl`: Reads the secret from etcd. Additional fields are used for authentication prior to getting access to etcd.
79+
80+
The following example shows how to use this command:
7881

7982
```azurecli
8083
kubectl exec --stdin --tty etcd-moc-lrhdsg6jk1f -n kube-system -- etcdctl --cacert /etc/kubernetes/pki/etcd/ca.crt --key /etc/kubernetes/pki/etcd/server.key --cert /etc/kubernetes/pki/etcd/server.crt get /registry/secrets/default/db-user-pass -w fields
8184
```
8285

86+
The following fields are returned in the command output:
87+
88+
- **ClusterID**: cluster ID
89+
- **MemberID**: member ID
90+
- **Revision**: revision number
91+
- **RaftTerm**: 2
92+
- **Key**: path to the key
93+
- **CreateRevision**: revision number at the time the key was created
94+
- **ModRevision**: revision number at the time the key was modified
95+
- **Version**: the version of the key-value pair in etcd
96+
- **Value**: `k8s:enc:kms:v1:kms -plugin: <encrypted secret value>`
97+
- **Lease**: the lease associated with the secret
98+
- **More**: indicates whether there are more results
99+
- **Count**: the number of key-value pairs returned
100+
83101
After you run the command, examine the `Value` field in the output in the terminal window. This output shows the value stored in etcd for this key, which is the encrypted value of the secret. The value is encrypted using a KMS plugin. The `k8s:enc:kms:v1:` prefix indicates that Kubernetes is using the KMS plugin to store the secret in an encrypted format.
84102

85103
If you use the `kubectl describe secrets` command to retrieve secrets, it returns them in base64-encoded format, but unencrypted. The `kubectl describe` command retrieves the details of a Kubernetes resource via the API server, which manages encryption and decryption automatically. For sensitive data such as secrets, even if they are mounted on a pod, the API server ensures that they are decrypted when accessed. As a result, running the `kubectl describe` command does not display secrets in their encrypted form, but rather in their decrypted form if they are being used by a resource.

0 commit comments

Comments
 (0)