Generating the Data Encryption Config and Key

Kubernetes stores a variety of data including cluster state, application configurations, and secrets. Kubernetes supports the ability to encrypt cluster data at rest.

In this lab you will generate an encryption key and an encryption config suitable for encrypting Kubernetes Secrets.

The Encryption Key

Generate an encryption key:

  1. ENCRYPTION_KEY=$(head -c 32 /dev/urandom | base64)

The Encryption Config File

Create the encryption-config.yaml encryption config file:

  1. cat > encryption-config.yaml <<EOF
  2. kind: EncryptionConfig
  3. apiVersion: v1
  4. resources:
  5. - resources:
  6. - secrets
  7. providers:
  8. - aescbc:
  9. keys:
  10. - name: key1
  11. secret: ${ENCRYPTION_KEY}
  12. - identity: {}
  13. EOF

Copy the encryption-config.yaml encryption config file to each controller instance:

  1. for instance in controller-0 controller-1 controller-2; do
  2. gcloud compute scp encryption-config.yaml ${instance}:~/
  3. done

Next: Bootstrapping the etcd Cluster