agent-local
by Scalr
A Helm chart for deploying the Scalr Agent on a Kubernetes cluster. Deploys a static number of agents and executes runs in shared agent pods.
About this chart
agent-local
A Helm chart for deploying the Scalr Agent on a Kubernetes cluster. Deploys a static number of agents and executes runs in shared agent pods.
Table of Contents
- Prerequisites
- Installation
- Overview
- Architecture Diagram
- Versioning Policy
- Custom Certificate Authorities
- Mutual TLS (mTLS)
- Custom Agent Image
- Volumes
- Workload Selection
- Migrate to StatefulSet
- Security
- Metrics and Observability
- Provider Network Mirrors
- Network Requirements
- Termination
- Troubleshooting
- Configuration
- Maintainers
Prerequisites
- Kubernetes 1.33+
- Helm 3.5+
- A compatible StorageClass or existing persistent volumes for PVC storage (optional)
- Scalr Agent >= 0.45.0
Installation
To install the chart with the release name scalr-agent:
$ helm repo add scalr-charts https://scalr.github.io/agent-helm/
$ helm install scalr-agent scalr-charts/agent-local --set agent.token="<agent-token>"
See Configuration for chart settings and helm install for command options.
Overview
The agent-local chart runs Scalr agents in a Deployment by default. Each pod uses emptyDir
storage for temporary run data and its cache. You can also use a StatefulSet
and choose a storage mode for each volume.
The chart uses the local driver, which runs all tasks inside the agent container.
It uses the scalr/agent image instead of the scalr/runner image.
Each agent handles one task at a time. Increase replicaCount to run more tasks at once.
Pros
The chart is simple to deploy. Agents do not need access to the Kubernetes API. Provider and binary caching are enabled by default.
Cons
The chart does not configure autoscaling. Change replicaCount manually or configure a
Horizontal Pod Autoscaler. Pods keep their resources while idle, which can increase costs
during quiet periods.
Runs share the same container and storage. See Multi-tenant Isolation before using one agent pool across teams.
Architecture Diagram
Versioning Policy
This chart deploys the Scalr Agent using the scalr/agent image. The agent supports multiple runtimes beyond Kubernetes and is versioned independently from this chart.
Each new agent release triggers a new chart release with an updated appVersion. By default the chart deploys the matching agent image: image.tag is empty and falls back to .Chart.AppVersion. Upgrade the agent by upgrading the chart to a release that ships the agent version you want.
The Scalr Agent changelog covers agent and platform changes. The chart's CHANGELOG.md covers Kubernetes resources, values, and defaults.
[!WARNING] Setting
image.tagto an agent version other than the chart'sappVersionis not recommended. Each chart release is tested and coordinated with a specific agent version, and mismatched combinations may include breaking changes between the application and the chart's Kubernetes resources.
Custom Certificate Authorities
If your environment uses custom or self-signed certificates, configure a CA bundle for the agent. The agent uses this bundle for all HTTPS connections, including the Scalr API, VCS providers, and provider registries.
[!IMPORTANT] This replaces the system default CA certificates. If you need to trust both custom CAs and public CAs, include the complete certificate chain with both your custom certificates and standard root CAs in the bundle.
Provide the CA bundle inline:
agent:
tls:
caBundle: |
-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJAKZ...
-----END CERTIFICATE-----
-----BEGIN CERTIFICATE-----
MIIEFzCCAv+gAwIBAgIUDiCT...
-----END CERTIFICATE-----
Or reference an existing secret:
agent:
tls:
caBundleSecret:
name: "my-ca-bundle"
key: "ca-bundle.crt"
To create the secret:
kubectl create secret generic my-ca-bundle \
--from-file=ca-bundle.crt=/path/to/your/ca-bundle.crt \
-n scalr-agent
If both caBundleSecret.name and caBundle are set, caBundleSecret takes precedence.
Mutual TLS (mTLS)
[!IMPORTANT] mTLS is an upcoming Enterprise feature. See the Scalr mTLS documentation for details.
Mutual TLS (mTLS) adds transport-layer identity verification on top of the existing JWT authentication. With standard TLS only the server is verified; mTLS requires the agent to also present a client certificate during the TLS handshake, proving to Scalr that the request originates from a legitimate agent host. This means a stolen JWT alone is no longer sufficient — the attacker also needs the pool private key, which stays on operator-managed infrastructure.
The bootstrap certificate and private key are mounted read-only at /etc/scalr-agent/ssl/ and mapped to SCALR_AGENT_TLS_CERT_FILE and SCALR_AGENT_TLS_KEY_FILE.
To obtain an mTLS certificate, generate an EC P-256 private key and CSR (Certificate Signing Request):
openssl ecparam -genkey -name prime256v1 -noout -out scalr-agent.key
openssl req -new -key scalr-agent.key -out scalr-agent.csr -subj "/CN=agent-pool"
Then submit the CSR via the Agent Pool UI when registering a new agent, or via the Certificates tab on the Agent Pool page. Scalr signs the CSR and returns a certificate. The private key never leaves the operator host.
Once you have the private key and signed certificate, store them in a kubernetes.io/tls
or Opaque secret. A kubernetes.io/tls secret uses tls.crt and tls.key keys by default:
agent:
tls:
clientCertSecret:
name: "scalr-agent-mtls"
To create the secret:
kubectl create secret tls scalr-agent-mtls \
--cert=/path/to/scalr-agent.crt \
--key=/path/to/scalr-agent.key \
-n scalr-agent
For an Opaque secret with non-standard keys, specify the key names:
agent:
tls:
clientCertSecret:
name: "my-mtls-secret"
certKey: "client.crt"
keyKey: "client.key"
You can also pass the PEM files directly to Helm:
helm upgrade --install scalr-agent scalr-agent/agent-local \
--set-file agent.tls.clientCert=/path/to/scalr-agent.crt \
--set-file agent.tls.clientKey=/path/to/scalr-agent.key
Or in a values file:
agent:
tls:
clientCert: |
-----BEGIN CERTIFICATE-----
MIIDXTCCAkWgAwIBAgIJAKZ...
-----END CERTIFICATE-----
clientKey: |
-----BEGIN EC PRIVATE KEY-----
MHQCAQEEIIr...
-----END EC PRIVATE KEY-----
If both clientCertSecret.name and clientCert/clientKey are set, clientCertSecret takes precedence.
Custom Agent Image
This chart uses the local driver, meaning runs (Terraform/OpenTofu operations, OPA policies, shell hooks, etc.) execute directly inside the agent container. The image therefore needs to ship everything those runs depend on.
By default the chart uses the scalr/agent image, which includes the Scalr Agent service, the OpenTofu/Terraform runtime, and basic tooling (git, curl, openssl, ca-certificates, etc.).
If your workflows require additional software, you can build your own image on top of scalr/agent with the extra tools pre-installed. Follow the contract from the Scalr Build Custom Agent Image guide:
Base the image on scalr/agent and keep its ENTRYPOINT and CMD so it still runs the agent
service. You can add tools, files, configuration, certificates, and environment variables.
Changing existing module paths or replacing the entrypoint is not supported across agent updates.
Example:
FROM scalr/agent:<version>
USER root
RUN apt-get update && apt-get install -y --no-install-recommends \
awscli kubectl && \
rm -rf /var/lib/apt/lists/*
USER 1000
Then point the chart at the resulting image:
image:
repository: registry.example.com/my-scalr-agent
tag: "1.0.5"
Volumes
Each agent has two writable volumes. The data volume holds temporary run files at
agent.dataDir and defaults to a 4Gi emptyDir. The cache volume holds binaries, providers,
and modules at agent.cacheDir and defaults to a 20Gi emptyDir.
Storage modes
Enable storage with persistence.data.enabled or persistence.cache.enabled, then choose
the volume's mode. If mode is unset, Deployment uses persistentVolumeClaim and
StatefulSet uses volumeClaimTemplate.
| Mode | Workload | Storage |
|---|---|---|
persistentVolumeClaim | Either | One shared PVC per volume, created by Helm or supplied through claimName. |
ephemeral | Either | One PVC per pod, deleted with the pod. |
volumeClaimTemplate | StatefulSet | One PVC per replica, reused after pod replacement. |
To use emptyDir, keep enabled: false and leave mode unset.
Configure PVCs under persistence.data.persistentVolumeClaim or
persistence.cache.persistentVolumeClaim. All modes use these settings, except claimName,
which only applies to persistentVolumeClaim mode.
For replicas on different nodes, use per-pod storage or a shared ReadWriteMany claim.
The chart rejects multiple replicas with a chart-created shared ReadWriteOncePod claim.
Deployment rolling updates can stall with a shared ReadWriteOnce or ReadWriteOncePod claim.
Use strategy.type: Recreate or strategy.rollingUpdate.maxSurge: 0 to release the claim first.
Cache volume persistence
To use an existing shared cache:
persistence:
cache:
enabled: true
mode: persistentVolumeClaim
persistentVolumeClaim:
claimName: my-cache-pvc
See Provider Cache and Module Cache for cache configuration.
Data volume persistence
Keep the default emptyDir for temporary run data. Set persistence.data.enabled: true and
persistence.data.mode: ephemeral to give each pod a separate PVC, as in the
ephemeral cache example.
Generic ephemeral PVCs
Use generic ephemeral PVCs to give each Deployment pod a fresh cache:
replicaCount: 3
persistence:
cache:
enabled: true
mode: ephemeral
Workload selection
workload.kind defaults to Deployment.
Use StatefulSet and enable cache persistence to keep each replica's cache when its pod is
replaced:
replicaCount: 3
workload:
kind: StatefulSet
persistence:
cache:
enabled: true
Each replica gets its own 20Gi cache PVC.
StatefulSet agents append the first eight characters of the pod UID to the pod name, so a recreated pod connects under a new name.
Deployment uses strategy. StatefulSet uses workload.statefulSet.updateStrategy.
Changing workload.statefulSet.podManagementPolicy or claim templates requires recreating
the StatefulSet.
Per-replica StatefulSet PVCs are retained after scaling down or uninstalling. Configure this with
workload.statefulSet.persistentVolumeClaimRetentionPolicy.
Migrate to StatefulSet
Changing workload.kind from Deployment to StatefulSet replaces the controller and its
pods. Agents will be unavailable during the switch.
- Stop assigning work to the old agents, wait for active runs to finish, and upgrade with
replicaCount: 0. - Upgrade with
workload.kind: StatefulSet, your storage modes, and the desired replica count. New PVCs start empty. Switching from shared PVCs to claim templates can delete chart-managed shared claims. - Check that agents connect to Scalr and mount the expected claims before resuming work.
For a gradual migration, install a separate release. Check that the new agents work, then let the old agents finish their runs before removing them.
Security
Multi-tenant Isolation
Agents process runs one at a time in the same container. Runs can share files left by earlier runs, and they share the agent's filesystem. A run can change cached providers or modules that later runs use without verification.
Use separate agent pools for groups with different access permissions, such as teams or Scalr Environments. Give each pool access only to the resources its group needs.
If you want to manage a single agent deployment across different teams within your organization, consider using the agent-job chart.
Agent Security Context
Agent pods inherit their Linux user, group, seccomp, and capability settings from securityContext configuration. The defaults run the container as the non-root UID/GID 1000, drop all Linux capabilities, and enforce a read-only root filesystem.
The default is strict and compatibl
Deploy agent-local with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has agent-local 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.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartagent-local is pinned at v0.7.6 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- 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