For this time, I decided to use kind as my kubernetes cluster. To start I have to install kind:
brew install kind
kind create cluster
export GITHUB_USER=[github_user]
export GITHUB_TOKEN=[github_token]
cd ~/.config/gh
mkdir flex-boostrap-demos.pat
flux bootstrap github --hostname=github.com --owner=[username] --repository=sops-flux-playground --branch=main --path=clusters/kind0 --personal --private=false
git clone https://github.com/[username]/sops-flux-playground.git
cd sops-flux-playground
code .
#gotk-sync.yaml
#In the Spec, you will add the following:
spec:
decryption:
provider: sops
secretRef:
name: sops-gpg
brew install gnupg sops
gpg --batch --full-generate-key <<EOF
%no-protection
Key-Type: 1
Key-Length: 4096
Subkey-Type: 1
Subkey-Length: 4096
Expire-Date: 0
Name-Email: [email protected]
Name-Real: kind0
EOF
gpg --list-secret-keys
sec rsa4096 2023-03-09 [SCEA]
ABB063E31C65B14C81B607021CC77C4A64215338
uid [ultimate] kind0 <[email protected]>
ssb rsa4096 2023-03-09 [SEA]
gpg --export-secret-keys --armor ABB063E31C65B14C81B607021CC77C4A64215338 | kubectl create secret generic --namespace flux-system --from-file=sops.asc=/dev/stdin sops-gpg
gpg --export --armor ABB063E31C65B14C81B607021CC77C4A64215338 > clusters/kind0/flux-system/sops.pub.asc
Pay attention to the path where you are located on the terminal
git add .
git commit -m "Adding secrets into my repo"
git push
We recommend to create a secret for each environment you have
flux reconcile source git flux-system
kubectl describe kustomizations.kustomize.toolkit.fluxcd.io -A
kubectl describe kustomizations.kustomize.toolkit.fluxcd.io -A | grep sops
By now, you should see that your repo is up-to-date and ready to use the secrets that you created.