Skip to content

Commit 89bf68e

Browse files
authored
Merge pull request #22 from AnushkaKhare-Eng/patch-2
Update encrypt-etcd-secrets.md
2 parents aeae546 + 6beb15e commit 89bf68e

File tree

1 file changed

+31
-23
lines changed

1 file changed

+31
-23
lines changed

AKS-Arc/encrypt-etcd-secrets.md

Lines changed: 31 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,41 +66,49 @@ kubectl exec --stdin --tty <etcd pod name> -n kube-system --etcdctl --cacert /et
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.
69-
- `--stdin`: This flag allows you to send input (stdin) to the command you're running inside the pod. It's useful if you need to interact with the command, especially for commands that expect user input.
70-
- `--tty`: This flag allocates a TTY (terminal) for the command, making it behave like you're interacting with a terminal session. It's especially useful when you want to run interactive commands (like a shell) and see the output in a terminal-like environment.
69+
- `--stdin`: This flag allows you to send input (stdin) to the command you are running inside the pod.
70+
- `--tty`: This flag allocates a TTY (terminal) for the command, making it behave like you are interacting with a terminal session.
7171
- `<etcd pod name>`: to find the etcd pod name, run the following command:
7272

7373
```azurecli
7474
kubectl get pods -n kube-system | findstr etcd-moc
7575
```
7676

77-
- `-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.
77+
- `-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 and other control plane services.
7878
- `--etcdctl`: Reads the secret from etcd. Additional fields are used for authentication prior to getting access to etcd.
7979

80-
The following example shows how to use this command:
80+
The following fields are returned in the command output:
8181

82-
```azurecli
83-
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
82+
```output
83+
"ClusterID" : <cluster id>
84+
85+
"MemberID" : <member id>
86+
87+
"Revision" : <revision number>
88+
89+
"RaftTerm" : 2
90+
91+
"Key" : <path to the key>
92+
93+
"CreateRevision" : < revision number at the time the key was created>
94+
95+
"ModRevision" : <revision number at the time the key was modified >
96+
97+
"Version" : <The version of the key-value pair in etcd >
98+
99+
"Value" : "k8s:enc:kms:v1:kms-plugin: <encrypted secret value>"
100+
101+
"Lease" : <The lease associated with the secret>
102+
103+
"More" : <Indicates if there are more results>
104+
105+
"Count" : <The number of key-value pairs returned>
84106
```
85107

86-
The following fields are returned in the command output:
108+
After you run the command, examine the `Value` field in the output in the terminal window. This output shows the value stored in etcd secret store 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 v1 plugin to store the secret in an encrypted format.
87109

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-
101-
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.
102-
103-
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.
110+
> [!NOTE]
111+
> 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.
104112
105113
## Troubleshooting
106114

0 commit comments

Comments
 (0)