In this guide, you’ll learn how to use Mozilla SOPS with PGP (GPG) to securely encrypt and manage Kubernetes secrets in Git repositories.Documentation Index
Fetch the complete documentation index at: https://notes.kodekloud.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
SOPS (Secrets OPerationS) lets you encrypt structured files—YAML, JSON, and ENV—so they can be safely stored in public Git repos. It integrates with multiple key management systems:| Provider | URI Scheme |
|---|---|
| Google KMS | gcp-kms://… |
| AWS KMS | awskms://… |
| Azure Key Vault | azurekeyvault://… |
| HashiCorp Vault | vault://… |
| PGP/GPG | pgp:KEYID |
For full SOPS documentation, see the Mozilla SOPS GitHub repository.
What Is PGP/GPG?
- PGP: Pretty Good Privacy
- GPG: GNU Privacy Guard (OpenPGP implementation)
Step 1: Generate a GPG Key
Create a 3072-bit RSA key without passphrase or expiration:Step 2: Store the Private Key in Kubernetes
Create a Kubernetes Secret in theflux-system namespace:
Never commit
sops.private.asc to Git. Only sops.pub.asc should be versioned.Step 3: Encrypt a Kubernetes Secret with SOPS
Follow these steps:- Generate a plain Secret manifest:
- Import the public key:
- Encrypt the file (or specific fields):
Encrypted
secret.yaml: - Commit the encrypted
secret.yamlto your Git repository.
Step 4: Decrypt with Flux’s Kustomize Controller
Configure yourKustomization to enable SOPS decryption:
sops-gpg secret to decrypt and apply your secret.yaml inside the cluster.