akeyless-secrets-injection

by akeyless.io

Helm chartv2.8.0App 0.42.0Verified publisher

A Helm chart that deploys a mutating admission webhook that configures applications to request env vars from Akeyless Vault Secrets

About this chart

Akeyless Kubernetes Secrets Injection

This chart will install a mutating admission webhook, that injects an executable to containers in pods which than can request secrets from Akeyless Vault through environment variable definitions or local file on the container. This chart has been tested to work with Kubernetes version 1.16, and above.

The webhook accepts AdmissionReview v1 and v1beta1. If image.tag is set to a version older than 0.41.0, the chart registers only v1beta1, because older webhook images cannot answer v1.

Before you start

Before you install this chart you must create a namespace for it, this is due to the order in which the resources in the charts are applied (Helm collects all of the resources in a given Chart and it's dependencies, groups them by resource type, and then installs them in a predefined order (see here).

The MutatingWebhookConfiguration gets created before the actual backend Pod which serves as the webhook itself, Kubernetes would like to mutate that pod as well, but it is not ready to mutate yet (infinite recursion in logic).

Creating the namespace

The default namespaceSelector uses the kubernetes.io/metadata.name label, which Kubernetes (1.21+) automatically applies to all namespaces. No manual labeling is required.

set the target namespace name or skip for the default name: vswh

export WEBHOOK_NS=`<namespace>`

Get Repo Info

$ helm repo add akeyless https://akeylesslabs.github.io/helm-charts
$ helm repo update

See helm repo for command documentation.

Installing the Chart

The values.yaml file holds default values, replace the values with the ones from your environment where needed.

To install the chart run:

helm install RELEASE_NAME akeyless/akeyless-secrets-injection --namespace "${WEBHOOK_NS}"

Deleting the Chart

helm delete RELEASE_NAME --namespace "${WEBHOOK_NS}"

Extra Objects

extraObjects renders additional Kubernetes manifests as part of the release. Each entry is rendered with tpl, so it can reference .Release, .Chart and .Values. Custom resources require their CRDs to be installed before the release.

extraObjects:
  - apiVersion: v1
    kind: ConfigMap
    metadata:
      name: "{{ .Release.Name }}-extra"
      namespace: "{{ .Release.Namespace }}"
    data:
      chart: "{{ .Chart.Name }}-{{ .Chart.Version }}"

An entry is either a map or a string (- |). What the chart does to each:

String entryMap entry
Values and typesexactly as writtennumbers are read as 64-bit floats: 1.0 renders as 1, integers above 2^53 lose precision
Templated valueskeep their type: {{ .Values.x }} renders a numberalways strings: "{{ .Values.x }}" renders '3'
Key order, quoting, commentskeptkeys sorted, quoting normalized, comments dropped
{{ }} anywhere in the objectevaluated as a templateevaluated as a template

The chart tests cover values and types, templated values and {{ }} handling. Key order, quoting and comments follow Helm and are not tested here.

To pass a literal {{ }} through, for example a Prometheus alert using {{ $labels.instance }}, escape it as {{ "{{" }} and {{ "}}" }}. Use a string entry when a field needs an exact value or a templated number or boolean:

extraMinAvailable: 1
extraObjects:
  - |
    apiVersion: policy/v1
    kind: PodDisruptionBudget
    metadata:
      name: "{{ .Release.Name }}-extra"
      namespace: "{{ .Release.Namespace }}"
    spec:
      minAvailable: {{ .Values.extraMinAvailable }}

Configuration

OAuth2 / JWT authentication

Use this when the webhook and injected workloads should authenticate to Akeyless with a short-lived Kubernetes projected ServiceAccount token (oauth2/jwt auth method), instead of a static API key, cloud IAM, or the classic Kubernetes auth method.

When to use it

  • You want per-ServiceAccount identity (sub=system:serviceaccount:<ns>:<sa>) without storing long-lived credentials in the chart values.
  • Your cluster can issue projected tokens for a dedicated audience (not the Kubernetes API audience), and Akeyless can validate them via JWKS.

When not to use it

  • Existing installs that already use api_key, k8s, aws_iam, azure_ad, gcp, or universal_identity and do not need projected-token auth.
  • Clusters or policies that cannot mint projected SA tokens with a custom audience.

Requirements: injector image 0.42.0+ (Chart.appVersion). Image 0.41.0 and older reject AKEYLESS_ACCESS_TYPE=jwt. Leave image.tag empty to use Chart.appVersion, or set it explicitly to a JWT-capable tag.

Set env.AKEYLESS_ACCESS_TYPE to jwt (alias oauth2) and enable jwtProjectedToken with a required audience that matches the Akeyless auth method. Do not put a static JWT in env. The chart fails the render if access type is jwt/oauth2 while jwtProjectedToken.enabled is false.

env:
  AKEYLESS_ACCESS_TYPE: jwt
  AKEYLESS_ACCESS_ID: "<oauth2/jwt auth-method access id>"
  # AKEYLESS_API_GW_URL: "https://your-gateway"  # optional; set only to force a Gateway

jwtProjectedToken:
  enabled: true
  audience: akeyless.io   # dedicated audience; do not reuse the Kubernetes API audience

The chart mounts the projected token and sets AKEYLESS_JWT_FILE / AKEYLESS_JWT_AUDIENCE on the webhook Deployment. Workload pods receive their own projected token from the injector so init and sidecar refresh use the same identity. expirationSeconds, mountPath, and volumeName apply to the webhook pod only; workload tokens use a fixed 3600s mount at /var/run/secrets/akeyless/jwt.

Authorization

An oauth2/jwt auth method is not bound by Kubernetes namespace/SA lists. Scope it with --force-sub-claims and per-role sub associations (example):

akeyless auth-method create oauth2 --name k8s-injector-jwt \
  --jwks-uri <cluster-or-gateway-jwks> --issuer <cluster-issuer> \
  --audience akeyless.io --unique-identifier sub --force-sub-claims

# Webhook identity (registry creds / restart rollout / cert events)
akeyless assoc-role-am --role-name injector-webhook --am-name k8s-injector-jwt \
  --sub-claims sub=system:serviceaccount:<release-ns>:<webhook-sa>

# App workloads
akeyless assoc-role-am --role-name app-a --am-name k8s-injector-jwt \
  --sub-claims sub=system:serviceaccount:app-a:*

Without sub-claim associations, any service account that can mint a projected token with this audience can assume the linked role.

Webhook network access

/pods has no caller authentication. Use a NetworkPolicy (or equivalent) so only the control plane can reach the webhook Service.

Upgrade notes

Copy the bullets for a chart version into the matching GitHub Release notes when publishing that chart.

Chart 2.8.0

  • Adds opt-in jwtProjectedToken for AKEYLESS_ACCESS_TYPE=jwt/oauth2 (requires injector image 0.42.0+).

Upgrading to chart 2.0.0

The top-level webhookFailurePolicy value was removed. Move it under mutatingWebhook.failurePolicy:

# before
webhookFailurePolicy: Fail

# after
mutatingWebhook:
  failurePolicy: Fail

Webhook serving certificate (GitOps / cert-manager)

By default the chart generates a self-signed CA and serving certificate while rendering. That generation is non-deterministic, so every helm template or helm upgrade produces a different keypair. GitOps controllers such as ArgoCD render the chart on every sync cycle, so with auto-sync and self-heal enabled they continuously detect drift and push a new certificate. This produces tls: bad certificate handshake errors and rolls the webhook pods on every sync.

Set mutatingWebhook.tls.existingSecretName to a Secret you manage yourself to turn certificate generation off. The chart then stops emitting the Secret, and the rendered output becomes byte-for-byte stable across renders. The webhook server watches the Secret and reloads the certificate in place when it is rotated, so renewal does not require a pod restart.

Because the chart no longer owns a CA in this mode, you must also tell the API server which CA to trust, using either mutatingWebhook.tls.caBundle or mutatingWebhook.tls.caBundleAnnotations. Rendering fails if neither is set. Both belong to this mode only: rendering also fails if caBundleAnnotations is set without existingSecretName, since the chart writes its own generated CA into caBundle there and an injector would overwrite it with an unrelated one.

With cert-manager issuing the certificate and injecting the CA bundle:

mutatingWebhook:
  tls:
    existingSecretName: akeyless-injector-tls
    caBundleAnnotations:
      cert-manager.io/inject-ca-from: "akeyless/akeyless-injector-tls"
apiVersion: cert-manager.io/v1
kind: Certificate
metadata:
  name: akeyless-injector-tls
  namespace: akeyless
spec:
  secretName: akeyless-injector-tls
  dnsNames:
    - RELEASE_NAME-akeyless-secrets-injection.akeyless.svc
  issuerRef:
    name: my-issuer
    kind: Issuer

caBundleAnnotations leaves caBundle out of the rendered MutatingWebhookConfiguration and lets ca-injector write it into the live object. A GitOps controller renders the chart without that field, reads the live value as drift, and with self-heal enabled strips it on the next sync, leaving the API server unable to validate the webhook. Exclude the field from drift detection. ArgoCD:

syncPolicy:
  syncOptions:
    - RespectIgnoreDifferences=true
ignoreDifferences:
  - group: admissionregistration.k8s.io
    kind: MutatingWebhookConfiguration
    name: RELEASE_NAME-akeyless-secrets-injection
    jsonPointers:
      - /webhooks/0/clientConfig/caBundle

ignoreDifferences alone only affects how ArgoCD calculates the diff. Without RespectIgnoreDifferences=true the sync still applies the manifest without caBundle and removes the injected value.

Flux, on the HelmRelease:

driftDetection:
  mode: enabled
  ignore:
    - paths: ["/webhooks/0/clientConfig/caBundle"]
      target:
        kind: MutatingWebhookConfiguration

With a CA you manage outside the cluster, supply the PEM directly instead. The chart base64-encodes it:

mutatingWebhook:
  tls:
    existingSecretName: akeyless-injector-tls
    caBundle: |
      -----BEGIN CERTIFICATE-----
      ...
      -----END CERTIFICATE-----

The Secret must not be named after the chart's own generated full name, which is RELEASE_NAME-akeyless-secrets-injection by default and whatever you set in fullnameOverride otherwise. The chart stops emitting a Secret at that name in this mode, so helm upgrade on an existing release would delete the Secret the pods mount. The chart rejects that name at render time, including the fullnameOverride case.

The Secret must contain tls.crt and tls.key, and must exist before the webhook pods start. The three failure modes differ, and so does what you will see:

  • Secret absent. The kubelet cannot mount the volume, so the pod never starts and stays in ContainerCreating with a FailedMount event. There is no crash-loop, because no container runs.
  • Secret present but missing tls.crt or tls.key. The volume has no items list, so whatever keys exist are mounted and the container starts. The webhook then finds no certificate at /var/serving-cert and exits, so the pod crash-loops.
  • Secret present with invalid TLS data. The container starts and the webhook fails at handshake time, which surfaces as tls: bad certificate on the API server rather than as a pod failure.

The first two resolve on their own once the issuer populates the Secret; neither needs manual intervention.

The following tables lists configurable parameters of the vault-secrets-webhook chart and their default values.

ParameterDescriptionDefault
debugEnable debug logs for the webhookfalse
image.pullPolicyWebhook image pull policyIfNotPresent
image.repositoryImage repo that contains the admission serverakeyless/k8s-webhook-server
image.agentImageImage repo for the injected secrets sidecarakeyless/k8s-secrets-sidecar
replicaCountNumber of webhook replicas2
mutatingWebhookAdditional fields to render on the generated MutatingWebhook, such as failurePolicy, selectors, timeoutSeconds, matchPolicy, reinvocationPolicy, and matchConditions. Chart-owned fields like clientConfig and rules are not overridden here.See values.yaml
mutatingWebhook.failurePolicyFailure policy for the mutating webhookIgnore
mutatingWebhook.namespaceSelectorNamespace selector for the mutating webhook. Rendered with tpl, so values can reference release context.Excludes kube-system, kube-node-lease, and the release namespace
mutatingWebhook.objectSelectorObject selector for the mutating webhook. Rendered with tpl, so values can reference release context.Excludes the release name
mutatingWebhook.timeoutSecondsWebhook request timeout in seconds10
mutatingWebhook.matchConditionsCEL match conditions for the mutating webhook. Rendered with tpl, so values can reference release context.[]
mutatingWebhook.tls.existingSecretNameExisting Secret with tls.crt/tls.key for the webhook server. When set, the chart does not generate or manage a certificate.""
mutatingWebhook.tls.caBundlePEM CA certificate written to the MutatingWebhookConfiguration caBundle. Only used with `existingSecr

Deploy akeyless-secrets-injection with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has akeyless-secrets-injection 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 chartakeyless-secrets-injection is pinned at v2.8.0 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