sealed-secrets

by joaquinito2051

Helm chartv1.10.2App 0.12.1

A Helm chart for Sealed Secrets

About this chart

Sealed Secrets

This chart contains the resources to use sealed-secrets.

Prerequisites

  • Kubernetes >= 1.9

Installing the Chart

To install the chart with the release name my-release:

$ helm install --namespace kube-system --name my-release stable/sealed-secrets

The command deploys a controller and CRD for sealed secrets on the Kubernetes cluster in the default configuration. The configuration section lists the parameters that can be configured during installation.

Uninstalling the Chart

To uninstall/delete the my-release deployment:

$ helm delete [--purge] my-release

The command removes all the Kubernetes components associated with the chart and deletes the release.

Using kubeseal

Install the kubeseal CLI by downloading the binary from sealed-secrets/releases.

Fetch the public key by passing the release name and namespace:

kubeseal --fetch-cert \
--controller-name=my-release \
--controller-namespace=my-release-namespace \
> pub-cert.pem

Read about kubeseal usage on sealed-secrets docs.

Configuration

ParameterDescriptionDefault
controller.createtrue if Sealed Secrets controller resources should be createdtrue
namespaceThe name of the Namespace to deploy the controller.Release.namespace
rbac.createtrue if rbac resources should be createdtrue
rbac.pspEnabledtrue if psp resources should be createdfalse
serviceAccount.createWhether to create a service account or nottrue
serviceAccount.nameThe name of the service account to create or use"sealed-secrets-controller"
secretNameThe name of the TLS secret containing the key used to encrypt secrets"sealed-secrets-key"
image.tagThe Sealed Secrets image tagv0.12.1
image.pullPolicyThe image pull policy for the deploymentIfNotPresent
image.repositoryThe repository to get the controller image fromquay.io/bitnami/sealed-secrets-controller
resourcesCPU/Memory resource requests/limits{}
crd.createtrue if crd resources should be createdtrue
crd.keeptrue if the sealed secret CRD should be kept when the chart is deletedtrue
networkPolicyWhether to create a network policy that allows access to the servicefalse
securityContext.runAsUserDefines under which user the operator Pod and its containers/processes run1001
securityContext.fsGroupDefines fsGroup for the operator Pod and its containers/processes run65534
commandArgsSet optional command line arguments passed to the controller process[]
ingress.enabledEnables Ingressfalse
ingress.annotationsIngress annotations{}
ingress.pathIngress path/v1/cert.pem
ingress.hostsIngress accepted hostnames["chart-example.local"]
ingress.tlsIngress TLS configuration[]
podAnnotationsAnnotations to annotate pods with.{}
podLabelsLabels to be added to pods{}
priorityClassNameOptional class to specify priority for pods""
  • In the case that serviceAccount.create is false and rbac.create is true it is expected for a service account with the name serviceAccount.name to exist in the same namespace as this chart before installation.
  • If serviceAccount.create is true there cannot be an existing service account with the name serviceAccount.name.
  • If a secret with name secretName does not exist in the same namespace as this chart, then on install one will be created. If a secret already exists with this name the keys inside will be used.
  • OpenShift: unset the runAsUser and fsGroup like this:
  securityContext:
    runAsUser:
    fsGroup:

Backup current key pairs:

oc get secret -l sealedsecrets.bitnami.com/sealed-secrets-key=active -o yaml > sealed-secrets-key-pairs.yaml

Bring your own keys

Set your vars

export PRIVATEKEY="mytls.key"
export PUBLICKEY="mytls.crt"
export NAMESPACE="jtudelag-test-sealedsecrets-heml-chart"
export SECRETNAME="mycustomkeys"

Generate a pair of new RSA key pairs:

openssl req -x509 -nodes -newkey rsa:4096 -keyout "$PRIVATEKEY" -out "$PUBLICKEY" -subj "/CN=sealed-secret/O=sealed-secret"

Create a tls k8s secrets, using your recently created RSA key pair:

oc -n "$NAMESPACE" create secret tls "$SECRETNAME"  --cert="$PUBLICKEY" --key="$PRIVATEKEY" --dry-run -o yaml
oc -n "$NAMESPACE" label secret "$SECRETNAME" sealedsecrets.bitnami.com/sealed-secrets-key=active

Delteing controller is needed to pick they new keys:

oc -n  "$NAMESPACE" delete pod -l app.kubernetes.io/name=sealed-secrets

See the new "private keys" in the controller logs

oc -n "$NAMESPACE" logs $(oc -n  "$NAMESPACE" get pod -l app.kubernetes.io/name=sealed-secrets -o name | cut -d '/' -f2)

controller version: v0.12.1+dirty
2020/06/09 14:30:45 Starting sealed-secrets controller version: v0.12.1+dirty
2020/06/09 14:30:45 Searching for existing private keys
2020/06/09 14:30:45 ----- sealed-secrets-key5rxd9
2020/06/09 14:30:45 ----- mycustomkeys
2020/06/09 14:30:45 HTTP server serving on :8080

Used your recently created public key to "seal" your secret, instead of the controller one:

Usually you have to seale your secrets using the controller provided key:

kubeseal --controller-name myrelease-sealed-secrets --controller-namespace jtudelag-test-sealedsecrets-heml-chart --scope cluster-wide < mysecret.yaml

But you can use your own key by using the --cert flag:

kubeseal --cert ./mytls.crt --scope cluster-wide < mysecret.yaml | oc applyf -f-

We can see the secret has been unsealed succesfully:

oc -n "$NAMESPACE" logs $(oc -n  "$NAMESPACE" get pod -l app.kubernetes.io/name=sealed-secrets -o name | cut -d '/' -f2)
controller version: v0.12.1+dirty
2020/06/09 14:30:45 Starting sealed-secrets controller version: v0.12.1+dirty
2020/06/09 14:30:45 Searching for existing private keys
2020/06/09 14:30:45 ----- sealed-secrets-key5rxd9
2020/06/09 14:30:45 ----- mycustomkeys
2020/06/09 14:30:45 HTTP server serving on :8080
2020/06/09 14:37:55 Updating jtudelag-test-sealedsecrets-heml-chart/mysecret
2020/06/09 14:37:55 Event(v1.ObjectReference{Kind:"SealedSecret", Namespace:"jtudelag-test-sealedsecrets-heml-chart", Name:"mysecret", UID:"f3a6c537-d254-4c06-b08f-ab9548f28f5b", APIVersion:"bitnami.com/v1alpha1", ResourceVersion:"20469957", FieldPath:""}): type: 'Normal' reason: 'Unsealed' SealedSecret unsealed successfully

NOTE: mytls.key is your private key, which is used by the controller to unseal your secret. Dont share it with anyone, and save it in a safe place!!

Deploy sealed-secrets with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has sealed-secrets on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the chartsealed-secrets is pinned at v1.10.2 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply