UNCLASSIFIED - NO CUI

Skip to content
Snippets Groups Projects
encryption.md 8.43 KiB

Big Bang Encryption

Table of Contents

Big Bang follows a GitOps approach to managing the Big Bang Kubernetes cluster configuration. Using GitOps, we must securely store secrets in Git using encryption. The private key, which is stored in key storage, is used by the continuous deployment tool to decrypt and deploy the secrets for use in the cluster.

SOPS

Secrets Operations (SOPS) is used to securely encrypt values in YAML, JSON, ENV, INI and BINARY formats. Secrets, such as pull credentials or certificates, should be encrypted with SOPS prior to committing into a Git repository.

The private key used in SOPS should NEVER be stored in Git along side the encrypted secrets.

SOPS supports the ability to add multiple keys to the same file so multiple key pairs can use the same secret. This is useful for environments which may have different keys, but use the same secrets. For each key used, SOPS writes the public key, used to encrypt, and an encrypted copy of the data to the file. Decryption requires use of one of the private keys used. After editing, the embedded public keys are used to re-encrypt the file for all key pairs.

Create Encryption Keys

To setup Big Bang with SOPS, a key pair must be created. The private key is used for decryption and must be securely stored but accessible to the cluster. The public key is used for encryption. Follow the appropriate instructions below to create your key pair.

Key Management Key Pair Instructions Notes
GNU Privacy Guard (GPG)* gpg --full-generate-key Use key type = RSA and RSA, keysize = 4096, expiration = 0
Amazon Web Services (AWS) Key Management Service (KMS) Link Advanced setup help (e.g. roles, profiles, contexts)
Google Cloud Platform (GCP) Key Management Service (KMS) Link
HashiCorp Vault Link

*GPG is not recommended for production use because the private key can be misplaced or compromised too easily

Configure SOPS

SOPS uses .sops.yaml as a configuration file for which keys to use for newly created files. Once a file is created, the key fingerprints are stored in the file and must be re-keyed to use any changes to .sops.yaml.

  1. Follow the SOPS instructions to configure .sops.yaml based on the encryption method you used. Multiple keys of the same type can be added using the block scalar yaml construct, >-, and separating them by a comma and newline.

    If you are using the Big Bang sample files, make sure to remove the development Big Bang key.

  2. Add the following regex to only encrypt data in the yaml files

    creation_rules:
    - encrypted_regex: '^(data|stringData)$'
  3. Save .sops.yaml in the root of folder of your configuration

  4. If you have existing secrets, use the following to re-key them with the configuration in .sops.yaml

    # You must have the old private key to rekey the file
    sops updatekeys <encrypted file>

Deploy Private Key

This must be completed before deploying Big Bang or else deploying Secrets will fail.

GPG

  1. Deploy your SOPS private key to a secret named sops-gpg in the cluster

    gpg --export-secret-keys --armor <new key fingerprint> | kubectl create secret generic sops-gpg -n bigbang --from-file=yourkey.asc=/dev/stdin

AWS KMS