Kubernetes

Install AnsibleForms and its MySQL database with the Helm chart

  1. Prerequisites
  2. 1. Get the chart values
  3. 2. Configure the storage
  4. 3. Set the credentials
  5. 4. Choose the RTE image
  6. 5. Install the chart
  7. 6. Check the install
  8. 7. Open AnsibleForms
  9. 8. Sign in
  10. A Runner on Kubernetes
  11. A Builder on Kubernetes
    1. Pod Security
  12. Uninstalling
  13. Next steps

The Helm chart deploys AnsibleForms with MySQL and the RTE that runs the playbooks (see the values reference). The installer installs the chart too, from a few questions, and upgrades a release it did not install. The same chart also installs a Runner or a Builder on its own, for an AnsibleForms that runs elsewhere (see A Runner on Kubernetes and A Builder on Kubernetes).


Prerequisites

Before you start, you need:

  • Kubernetes cluster : with kubectl configured to reach it
  • Helm 3 : to install and upgrade the chart
  • Storage : a StorageClass for dynamic provisioning, or pre-created PersistentVolumes
  • Ingress controller : only if you want to expose AnsibleForms through an ingress

1. Get the chart values

Fetch the chart’s default values into a file of your own, from the chart repository or from the OCI registry:

helm repo add ansibleforms https://ansibleforms.com/helm-charts/
helm repo update
helm show values ansibleforms/ansibleforms > my_values.yaml

2. Configure the storage

Both AnsibleForms and MySQL store their data on a persistent volume. Set the StorageClass and size of each:

storages:
  server:
    className: longhorn
    size: 5Gi
    accessMode: ReadWriteOnce
  mysql:
    className: longhorn
    size: 5Gi
    accessMode: ReadWriteOnce

An empty className uses the cluster’s default StorageClass. The access mode defaults to ReadWriteMany, which many storage classes do not offer; ReadWriteOnce is fine with a single replica. For pre-created PersistentVolumes, see the chart’s README.


3. Set the credentials

AnsibleForms needs an admin account, a database password and an ENCRYPTION_SECRET, the key that encrypts the credentials stored in AnsibleForms. To change that key later, set ENCRYPTION_SECRET_PREVIOUS to the old one for one start: every stored secret is then re-encrypted with the new key. Supply them in one of three ways:

Set them in my_values.yaml. The chart stores them in a Secret named <release>-secrets:

applications:
  server:
    env:
      ADMIN_USERNAME: admin
      ADMIN_PASSWORD: a-strong-password
      ENCRYPTION_SECRET: a-random-string-of-32-characters
  mysql:
    password: a-strong-database-password

4. Choose the RTE image

AnsibleForms 7 runs no playbook itself: the RTE (runtime environment) does. The chart runs it as a second container in the server pod and registers it as the default runner rte, so playbook forms work without any setup. Since 7.3.0 the app dials it on 127.0.0.1 and keeps one WebSocket open (RTE_MODE=inbound, see Modes): the RTE gets no database settings and no encryption key. The chart’s config seed declares an RTE credential with the token and that address, and the runner, mode inbound, that signs in with it.

That RTE is the RTE Runner written in Go, which runs each job in a pod of its own, in the release’s namespace and from the RTE image, removed once the job ends. The app sends the job’s files over the socket, so every job starts from a clean container and needs no shared volume. The chart adds the ServiceAccount, Role and RoleBinding the Runner needs (see The RTE Runner on Kubernetes), and only the RTE container gets their token, never the app.

The default image, ghcr.io/ansibleforms/ansibleforms-rte-full, holds ansible with its collections and the Python libraries the 6.5 image had. For more, or less, build your own on one of the three RTE layers (ansibleforms-rte-base, -rte-core or -rte-full, see The RTE images) and point the chart at it:

containers:
  rte:
    image: registry.example.com/my-rte:7       # the image the jobs' pods run
    podPerJob:
      enabled: true                             # false: the Node RTE, every job in its container
      image: ghcr.io/ansibleforms/ansibleforms-rte-runner:7
      mounts: []
applications:
  rte:
    env:
      ANSIBLE_PATH: /app/dist/persistent/playbooks

The volumes in the jobs. A job’s pod mounts no volume unless containers.rte.podPerJob.mounts lists one: its playbook sees the files the job brings (the playbook, its repository, its inventory) and what its image holds. Each entry gives every job’s pod a path of the RTE container, read-only unless readWrite:

containers:
  rte:
    podPerJob:
      mounts:
        - path: /home/node/.ssh              # in the RTE container
          mountPath: /home/node/.ssh         # in each job's pod
        - path: /app/dist/persistent/vars
          mountPath: /vars
          readWrite: true

The path is on one of the RTE container’s volumes: the app’s, at /app/dist/persistent and /home/node/.ssh, or a Secret or ConfigMap of extraVolumes mounted with containers.rte.extraVolumeMounts. A claim that is only ReadWriteOnce pins every job’s pod to the node of the RTE’s pod; ReadWriteMany lets them run on any node.

The Node RTE. containers.rte.podPerJob.enabled: false keeps the RTE in Node.js exactly as before: every job runs in the RTE’s own container, on the app’s volume, and the chart renders no ServiceAccount, Role or RoleBinding.

Upgrading from the Node RTE. A chart up to 7.8.0 ran the Node RTE. The jobs now run in pods of their own instead of in the RTE container on the app’s volume. A playbook that read files from that volume outside its repository, such as the SSH key at /home/node/.ssh or vars files under /app/dist/persistent, needs them in its repository or its image, as the form’s credentials, or listed in mounts. To keep the Node RTE, set containers.rte.podPerJob.enabled: false before you upgrade.

The token between the app and the RTE, and the key that signs the sessions, are generated on the first install into the <release>-keys Secret and kept on every upgrade. With a config seed of your own, add that credential and runner to it: the notes Helm prints after the install show how (see the chart’s README).


5. Install the chart

Install the chart into its own namespace with your values:

helm upgrade --install ansibleforms ansibleforms/ansibleforms \
  --namespace ansibleforms --create-namespace \
  --values my_values.yaml

With the OCI registry, use oci://ghcr.io/ansibleforms/charts/ansibleforms as the chart. In anything that runs unattended, pin the chart version with --version, so that a new release is never installed on its own.


6. Check the install

The chart includes a test that checks both the web server and the database connection:

helm test ansibleforms --namespace ansibleforms --logs

The test ends with OK when AnsibleForms answers and its database accepts connections.


7. Open AnsibleForms

How you reach AnsibleForms depends on how the server is exposed:

With the default ClusterIP service and no ingress, nothing is exposed outside the cluster. Forward a local port to have a look:

kubectl -n ansibleforms port-forward svc/ansibleforms-server 8080:80

Then open http://127.0.0.1:8080/.


8. Sign in

Sign in as the admin user, admin by default. To read the password from the Secret:

kubectl -n ansibleforms get secret ansibleforms-secrets \
  -o jsonpath='{.data.ADMIN_PASSWORD}' | base64 -d

With secrets.existingSecret, read it from your own Secret instead.


A Runner on Kubernetes

With runner.enabled, the chart installs only an RTE: a Runner for an AnsibleForms installed elsewhere, in another namespace, another cluster or on a VM. It dials the app and keeps one WebSocket open (RTE_MODE=outbound, see Modes), so it needs no database, no encryption key and no inbound port. It renders no app, no MySQL, no Service and no Ingress:

helm install runner1 ansibleforms/ansibleforms \
  --namespace runners --create-namespace \
  --set runner.enabled=true \
  --set runner.appUrl=https://forms.example.com \
  --set runner.name=zone-a \
  --set runner.joinToken=afj_...
Value What it does
runner.enabled Installs only the Runner: no app, no MySQL, no Service, no Ingress
runner.appUrl The app’s address as people open it, with its BASE_URL if any. Required
runner.name The runner name it joins as (RTE_NAME). Empty: the release name
runner.joinToken A join token made with the app’s API, read on the first start to approve the Runner at once
runner.appTlsVerify false accepts the app’s self-signed certificate (APP_TLS_VERIFY=0), inside one trusted network only
containers.rte.podPerJob.enabled true (the default) runs the RTE Runner in Go, a pod per job; false the Node RTE

Without a join token, the Runner asks to join and waits until an admin approves it under Connections > Runners. Once approved, it signs in with its own RTE_TOKEN, kept in the <release>-keys Secret: keep that Secret with the release. The installer installs this runner mode too, when you choose the Runner role and Kubernetes.

A pod per job. By default the pod runs the RTE Runner in Go (containers.rte.podPerJob.image), as the server pod does: each job runs in a pod of its own from containers.rte.image, and the Runner’s own pod keeps only its spool and its cache of the jobs’ files. The jobs mount no volume unless containers.rte.podPerJob.mounts lists one, and containers.rte.podPerJob.enabled: false runs the Node RTE instead, every job in its pod. Coming from the Node RTE, its playbooks’ files need the same care as for the server pod’s RTE. See The RTE Runner on Kubernetes for the Role and the rest.


A Builder on Kubernetes

With builder.enabled, the chart installs only the RTE builder, which builds the RTE images an AnsibleForms installed elsewhere defines, from 7.9.0 on, and pushes them to their registry. It dials the app as a Runner does and keeps one WebSocket open, so it needs no database, no encryption key and no inbound port, only its way out to the app and to the registries. Its pod needs a namespace at the privileged Pod Security level (see Pod Security below):

kubectl create namespace builders
kubectl label namespace builders pod-security.kubernetes.io/enforce=privileged
helm install builder1 ansibleforms/ansibleforms \
  --namespace builders \
  --set builder.enabled=true \
  --set builder.appUrl=https://forms.example.com \
  --set builder.joinToken=afj_...
Value What it does
builder.enabled Installs only the builder: no app, no MySQL, no RTE, no Service, no Ingress
builder.appUrl The app’s address as people open it, with its BASE_URL if any (CONTROLLER_URL). Required
builder.name The builder name it joins as (RTE_NAME). Empty: the release name
builder.joinToken A join token made with the app’s API, read on the first start to approve the builder at once
builder.appTlsVerify false accepts the app’s self-signed certificate (CONTROLLER_TLS_VERIFY=0), inside one trusted network only
builder.token, builder.existingTokenSecret Its own token, 16 characters or more, or a Secret that holds it. Empty: generated once and kept in <release>-keys
builder.buildkitHost Another BuildKit to build with (BUILDKIT_HOST). Empty: its own rootless buildkitd
builder.image The builder’s image, ghcr.io/ansibleforms/ansibleforms-rte-builder: keep it on the app’s release
builder.resources Its CPU and memory: 500m and 1Gi requested, 4 CPUs and 8Gi at most, as builds run inside it
builder.storage Its volume for its spool, its builds’ files and buildkitd’s cache: 50Gi, the default class, ReadWriteOnce
builder.env Its environment, such as HTTPS_PROXY, NO_PROXY, NODE_EXTRA_CA_CERTS or LOG_LEVEL

It renders one Deployment, <release>-builder, with one replica, its volume and the <release>-keys Secret. Under helm template, Argo CD or Flux, set builder.token or builder.existingTokenSecret: the chart cannot read a generated token back there. runner.enabled and builder.enabled are refused together: install a Runner and a builder as two releases. The values reference lists the rest.

Without a join token, the builder asks to join and waits until an admin approves it under Connections > Builders. Once approved, it signs in with its own RTE_TOKEN: keep the <release>-keys Secret with the release. The installer installs this builder mode too, when you choose the Builder role and Kubernetes.

To check it, kubectl logs deploy/<release>-builder says dialing the controller at ..., and the pod turns Ready once the app has welcomed it. helm test checks that the app at builder.appUrl answers from the builder’s namespace.

Pod Security

The builder builds with a rootless buildkitd of its own, which makes user namespaces. Its pod runs as uid 1000, never root and never privileged, but with these settings:

Setting Why
seccompProfile: Unconfined The default profile refuses the user namespace buildkitd makes
appArmorProfile: Unconfined The runtime’s AppArmor profile refuses its mounts, on nodes with AppArmor. Needs Kubernetes 1.30 or later
allowPrivilegeEscalation: true newuidmap and newgidmap get their file capabilities only with it
capabilities: drop ALL, add SETUID SETGID The two capabilities of those file capabilities, no other

They break the baseline and restricted Pod Security Standards, so only a namespace at privileged admits the pod; elsewhere its ReplicaSet reports violates PodSecurity and no pod starts. Nodes on Ubuntu 23.10 or later also restrict unprivileged user namespaces through AppArmor: set kernel.apparmor_restrict_unprivileged_userns=0 on the nodes that run the builder. With builder.buildkitHost naming a BuildKit it reaches instead, the builder starts no buildkitd, and its pod runs as restricted asks.


Uninstalling

helm uninstall removes the release but keeps its data, so that the same release installed again finds it:

helm uninstall ansibleforms --namespace ansibleforms

It leaves every PersistentVolumeClaim the chart made, the <release>-keys Secret, and the <release>-secrets Secret when the chart generated it (secrets.generate). Installing the same release into the same namespace again takes them back as they are: the same database, the same encryption key, and for a Runner or a builder the same RTE_TOKEN the app approved it with. This is keepOnUninstall, on by default; set it to false before installing and helm uninstall deletes them with the rest.

To delete what was kept, once you are sure the data can go:

kubectl delete pvc,secret -l app.kubernetes.io/instance=<release> -n <namespace>

Deleting the namespace takes everything in it too. A volume whose StorageClass has the Retain reclaim policy stays as a PersistentVolume after its claim goes: delete it with kubectl delete pv if you mean to.


Next steps

The chart’s README covers the rest of the configuration:

  • Your own database : set mysql.enabled: false and point AnsibleForms at an existing MySQL server
  • Forms from ConfigMaps : provide config.yaml and the form files through ConfigMaps
  • HTTPS behind an ingress, resources, node placement and private registries
  • The RTE : its token, an RTE image of your own, or no RTE at all

To move to a newer release, see Upgrading on Kubernetes.