Skip to content

Commit ca8ae6e

Browse files
authored
Merge pull request #22316 from tengqm/fix-19337
Fix indentation of list and code snippet for kms-provider
2 parents b315b96 + f03c187 commit ca8ae6e

File tree

1 file changed

+96
-92
lines changed

1 file changed

+96
-92
lines changed

content/en/docs/tasks/administer-cluster/kms-provider.md

Lines changed: 96 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@ content_type: task
77
<!-- overview -->
88
This page shows how to configure a Key Management Service (KMS) provider and plugin to enable secret data encryption.
99

10-
1110
## {{% heading "prerequisites" %}}
1211

13-
1412
* {{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
1513

1614
* Kubernetes version 1.10.0 or later is required
@@ -19,8 +17,6 @@ This page shows how to configure a Key Management Service (KMS) provider and plu
1917

2018
{{< feature-state for_k8s_version="v1.12" state="beta" >}}
2119

22-
23-
2420
<!-- steps -->
2521

2622
The KMS encryption provider uses an envelope encryption scheme to encrypt data in etcd. The data is encrypted using a data encryption key (DEK); a new DEK is generated for each encryption. The DEKs are encrypted with a key encryption key (KEK) that is stored and managed in a remote KMS. The KMS provider uses gRPC to communicate with a specific KMS
@@ -30,10 +26,12 @@ plugin. The KMS plugin, which is implemented as a gRPC server and deployed on th
3026

3127
To configure a KMS provider on the API server, include a provider of type ```kms``` in the providers array in the encryption configuration file and set the following properties:
3228

33-
* `name`: Display name of the KMS plugin.
34-
* `endpoint`: Listen address of the gRPC server (KMS plugin). The endpoint is a UNIX domain socket.
35-
* `cachesize`: Number of data encryption keys (DEKs) to be cached in the clear. When cached, DEKs can be used without another call to the KMS; whereas DEKs that are not cached require a call to the KMS to unwrap.
36-
* `timeout`: How long should kube-apiserver wait for kms-plugin to respond before returning an error (default is 3 seconds).
29+
* `name`: Display name of the KMS plugin.
30+
* `endpoint`: Listen address of the gRPC server (KMS plugin). The endpoint is a UNIX domain socket.
31+
* `cachesize`: Number of data encryption keys (DEKs) to be cached in the clear.
32+
When cached, DEKs can be used without another call to the KMS;
33+
whereas DEKs that are not cached require a call to the KMS to unwrap.
34+
* `timeout`: How long should kube-apiserver wait for kms-plugin to respond before returning an error (default is 3 seconds).
3735

3836
See [Understanding the encryption at rest configuration.](/docs/tasks/administer-cluster/encrypt-data)
3937

@@ -57,17 +55,18 @@ Then use the functions and data structures in the stub file to develop the serve
5755

5856
* kms plugin version: `v1beta1`
5957

60-
In response to procedure call Version, a compatible KMS plugin should return v1beta1 as VersionResponse.version
58+
In response to procedure call Version, a compatible KMS plugin should return v1beta1 as VersionResponse.version.
6159

6260
* message version: `v1beta1`
6361

64-
All messages from KMS provider have the version field set to current version v1beta1
62+
All messages from KMS provider have the version field set to current version v1beta1.
6563

6664
* protocol: UNIX domain socket (`unix`)
6765

68-
The gRPC server should listen at UNIX domain socket
66+
The gRPC server should listen at UNIX domain socket.
6967

7068
### Integrating a KMS plugin with the remote KMS
69+
7170
The KMS plugin can communicate with the remote KMS using any protocol supported by the KMS.
7271
All configuration data, including authentication credentials the KMS plugin uses to communicate with the remote KMS,
7372
are stored and managed by the KMS plugin independently. The KMS plugin can encode the ciphertext with additional metadata that may be required before sending it to the KMS for decryption.
@@ -80,108 +79,113 @@ To encrypt the data:
8079

8180
1. Create a new encryption configuration file using the appropriate properties for the `kms` provider:
8281

83-
```yaml
84-
apiVersion: apiserver.config.k8s.io/v1
85-
kind: EncryptionConfiguration
86-
resources:
87-
- resources:
88-
- secrets
89-
providers:
90-
- kms:
91-
name: myKmsPlugin
92-
endpoint: unix:///tmp/socketfile.sock
93-
cachesize: 100
94-
timeout: 3s
95-
- identity: {}
96-
```
97-
98-
2. Set the `--encryption-provider-config` flag on the kube-apiserver to point to the location of the configuration file.
99-
3. Restart your API server.
100-
101-
Note:
102-
The alpha version of the encryption feature prior to 1.13 required a config file with
103-
`kind: EncryptionConfig` and `apiVersion: v1`, and used the `--experimental-encryption-provider-config` flag.
82+
```yaml
83+
apiVersion: apiserver.config.k8s.io/v1
84+
kind: EncryptionConfiguration
85+
resources:
86+
- resources:
87+
- secrets
88+
providers:
89+
- kms:
90+
name: myKmsPlugin
91+
endpoint: unix:///tmp/socketfile.sock
92+
cachesize: 100
93+
timeout: 3s
94+
- identity: {}
95+
```
96+
97+
1. Set the `--encryption-provider-config` flag on the kube-apiserver to point to the location of the configuration file.
98+
1. Restart your API server.
10499

105100
## Verifying that the data is encrypted
106-
Data is encrypted when written to etcd. After restarting your kube-apiserver, any newly created or updated secret should be encrypted when stored. To verify, you can use the etcdctl command line program to retrieve the contents of your secret.
107-
108-
1. Create a new secret called secret1 in the default namespace:
109-
```
110-
kubectl create secret generic secret1 -n default --from-literal=mykey=mydata
111-
```
112-
2. Using the etcdctl command line, read that secret out of etcd:
113-
```
114-
ETCDCTL_API=3 etcdctl get /kubernetes.io/secrets/default/secret1 [...] | hexdump -C
115-
```
116-
where `[...]` must be the additional arguments for connecting to the etcd server.
117101

118-
3. Verify the stored secret is prefixed with `k8s:enc:kms:v1:`, which indicates that the `kms` provider has encrypted the resulting data.
102+
Data is encrypted when written to etcd. After restarting your `kube-apiserver`,
103+
any newly created or updated secret should be encrypted when stored. To verify,
104+
you can use the `etcdctl` command line program to retrieve the contents of your secret.
119105

120-
4. Verify that the secret is correctly decrypted when retrieved via the API:
121-
```
122-
kubectl describe secret secret1 -n default
123-
```
124-
should match `mykey: mydata`
106+
1. Create a new secret called secret1 in the default namespace:
107+
```
108+
kubectl create secret generic secret1 -n default --from-literal=mykey=mydata
109+
```
110+
1. Using the etcdctl command line, read that secret out of etcd:
111+
```
112+
ETCDCTL_API=3 etcdctl get /kubernetes.io/secrets/default/secret1 [...] | hexdump -C
113+
```
114+
where `[...]` must be the additional arguments for connecting to the etcd server.
115+
116+
1. Verify the stored secret is prefixed with `k8s:enc:kms:v1:`, which indicates that the `kms` provider has encrypted the resulting data.
117+
118+
1. Verify that the secret is correctly decrypted when retrieved via the API:
119+
```
120+
kubectl describe secret secret1 -n default
121+
```
122+
should match `mykey: mydata`
125123

126124
## Ensuring all secrets are encrypted
125+
127126
Because secrets are encrypted on write, performing an update on a secret encrypts that content.
128127

129-
The following command reads all secrets and then updates them to apply server side encryption. If an error occurs due to a conflicting write, retry the command. For larger clusters, you may wish to subdivide the secrets by namespace or script an update.
128+
The following command reads all secrets and then updates them to apply server side encryption.
129+
If an error occurs due to a conflicting write, retry the command.
130+
For larger clusters, you may wish to subdivide the secrets by namespace or script an update.
131+
130132
```
131133
kubectl get secrets --all-namespaces -o json | kubectl replace -f -
132134
```
133135
134136
## Switching from a local encryption provider to the KMS provider
137+
135138
To switch from a local encryption provider to the `kms` provider and re-encrypt all of the secrets:
136139
137140
1. Add the `kms` provider as the first entry in the configuration file as shown in the following example.
138141
139-
```yaml
140-
apiVersion: apiserver.config.k8s.io/v1
141-
kind: EncryptionConfiguration
142-
resources:
143-
- resources:
144-
- secrets
145-
providers:
146-
- kms:
147-
name : myKmsPlugin
148-
endpoint: unix:///tmp/socketfile.sock
149-
cachesize: 100
150-
- aescbc:
151-
keys:
152-
- name: key1
153-
secret: <BASE 64 ENCODED SECRET>
154-
```
155-
156-
2. Restart all kube-apiserver processes.
157-
158-
3. Run the following command to force all secrets to be re-encrypted using the `kms` provider.
159-
160-
```
161-
kubectl get secrets --all-namespaces -o json| kubectl replace -f -
162-
```
142+
```yaml
143+
apiVersion: apiserver.config.k8s.io/v1
144+
kind: EncryptionConfiguration
145+
resources:
146+
- resources:
147+
- secrets
148+
providers:
149+
- kms:
150+
name : myKmsPlugin
151+
endpoint: unix:///tmp/socketfile.sock
152+
cachesize: 100
153+
- aescbc:
154+
keys:
155+
- name: key1
156+
secret: <BASE 64 ENCODED SECRET>
157+
```
158+
159+
1. Restart all kube-apiserver processes.
160+
161+
1. Run the following command to force all secrets to be re-encrypted using the `kms` provider.
162+
163+
```
164+
kubectl get secrets --all-namespaces -o json| kubectl replace -f -
165+
```
163166

164167
## Disabling encryption at rest
168+
165169
To disable encryption at rest:
166170

167171
1. Place the `identity` provider as the first entry in the configuration file:
168172

169-
```yaml
170-
apiVersion: apiserver.config.k8s.io/v1
171-
kind: EncryptionConfiguration
172-
resources:
173-
- resources:
174-
- secrets
175-
providers:
176-
- identity: {}
177-
- kms:
178-
name : myKmsPlugin
179-
endpoint: unix:///tmp/socketfile.sock
180-
cachesize: 100
181-
```
182-
2. Restart all kube-apiserver processes.
183-
3. Run the following command to force all secrets to be decrypted.
184-
```
185-
kubectl get secrets --all-namespaces -o json | kubectl replace -f -
186-
```
173+
```yaml
174+
apiVersion: apiserver.config.k8s.io/v1
175+
kind: EncryptionConfiguration
176+
resources:
177+
- resources:
178+
- secrets
179+
providers:
180+
- identity: {}
181+
- kms:
182+
name : myKmsPlugin
183+
endpoint: unix:///tmp/socketfile.sock
184+
cachesize: 100
185+
```
186+
1. Restart all kube-apiserver processes.
187+
1. Run the following command to force all secrets to be decrypted.
188+
```
189+
kubectl get secrets --all-namespaces -o json | kubectl replace -f -
190+
```
187191

0 commit comments

Comments
 (0)