Skip to content

Latest commit

 

History

History
53 lines (39 loc) · 1.5 KB

06-data-encryption-keys.md

File metadata and controls

53 lines (39 loc) · 1.5 KB

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:

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

The Encryption Config File

Create the encryption-config.yaml encryption config file:

cat > encryption-config.yaml <<EOF
kind: EncryptionConfig
apiVersion: v1
resources:
  - resources:
      - secrets
    providers:
      - aescbc:
          keys:
            - name: key1
              secret: ${ENCRYPTION_KEY}
      - identity: {}
EOF

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

for instance in master-1 master-2; do
  scp encryption-config.yaml ${instance}:~/
done

Move encryption-config.yaml encryption config file to appropriate directory.

for instance in master-1 master-2; do
  ssh ${instance} sudo mv encryption-config.yaml /var/lib/kubernetes/
done

Reference: https://kubernetes.io/docs/tasks/administer-cluster/encrypt-data/#encrypting-your-data

Next: Bootstrapping the etcd Cluster