With Helm >= v3.1.1 there is the possibillity to run a post renderer after the templates has been renderered by helm. porecry is a post-renderer which can be used to decrypt values which are stored encrypted in the values.yaml files which are used to renderer the helm templates.
The goal is to be able to store the secrets values.yaml
in the repository encrypted. When using helm to render the manifests, the post-renderer can decrypt the values used in the secrets manifests.
- create a porecry secret (local or in cluster)
- use porecry to get the base64 ciphertext
- store the ciphertext in the values.yaml for the helm chart
- use porecry as post-renderer along with helm
You can download the binary from the release page and install it in your $PATH
To build the tool your self you need make
, git
and go
git clone https://github.com/sebidude/porecry.git
cd porecry
make build-linux
A porecry secrets is a simple kubernetes secret which can be stored locally or in the clusters.
Create a porecry secret
porecry init --secret porecry --namespace mynamespace -o secret.yaml
You can now add the secret to your cluster.
kubectl apply -f secret.yaml
If the secret is not added to the cluster you can use the following flags to use it from the local file created previously.
export PORECRY_LOCAL="--local --secret secret.yaml"
Now let's encrypt some data.
echo -n "mypassword" | porecry $PORECRY_LOCAL enc
myapp:
lables:
app: myapp
service:
port: 8080
secrets:
password: "[op:decrypt,mode:local,secret:secret.yaml] --- here goes the ciphertext ---"
Note the meta information stated in front of the ciphertext. This tells porecry how to process the following data.
op
- operation.encrypt
- encrypt the valuedecrypt
- decrypt the value
mode
local
- use the secret from a local file which contains the secret manifestcluster
- load the secret from the cluster, your kubeconfig is pointing to
secret
filename
can be specified whenmode
islocal
namespace/secretname
can be specified whenmode
iscluster
Example:
[op:encrypt,mode:local,secret:secret.yaml]this is plaintext`
encrypt the value this is plaintext
using the secret from the local
file secret.yaml
[op:encrypt,mode:cluster,secret:kube-system/porecry]this is plaintext
encrypt the value this is plaintext
using the secret porecry
found in namespace kube-system
in the cluster your kubeconfig points to.
cat values.yaml | porecry $PORECRY_LOCAL post
In a helm chart one would create a template for the applications secrets and render the values from the values.yaml into it and then use the --post-renderer porecry
to decrypt the values in the rendered manifests.
First copy your values.yaml which we created previously to the examples/porecry
folder in your checkout.
helm template porecry examples/porecry --post-renderer porecry