dagster-code-location

by KvalitetsIT

Helm chartv0.0.6App 0.0.6Verified publisher

A single Dagster code location: a hardened gRPC code server (Deployment + Service) deployed as its own release into a per-project namespace. Carries the discovery labels the KDS workspace generator groups locations by, and the container context the tenant core's K8sRunLauncher uses to launch this location's run pods.

About this chart

dagster-code-location

A single Dagster code location: a hardened gRPC code server (Deployment + Service) deployed as its own release into a per-project namespace. Carries the discovery labels the KDS workspace generator groups locations by, and the container context the tenant core's K8sRunLauncher uses to launch this location's run pods.

Homepage: https://github.com/KvalitetsIT

Maintainers

NameEmailUrl
KvalitetsIT[email protected]https://github.com/KvalitetsIT/helm-repo

Source Code

Requirements

RepositoryNameVersion
https://raw.githubusercontent.com/KvalitetsIT/helm-repo/master/templates2.2.0

Values

Code location

KeyTypeDefaultDescription
imageobjectSee values.yamlCode server image. Set tag or digest (or both).
image.repositorystring""Image repository, e.g. ghcr.io/my-org/my-location. Required.
image.tagstring""Image tag. Required unless digest is set.
image.digeststring""Image digest (recommended). Required unless tag is set.
image.pullPolicystring"IfNotPresent"Pull policy for the code server.
modulestring""Python module passed as -m. Defaults to <release name, '-'->'_'>.definitions.
locationNamestring""Location name and discovery-label value. Defaults to the release name.
argslistSee values.yamlContainer args for the code server (native container args, templated). Default runs dagster api grpc on 4000 serving module. Override with the full arg list for a different entrypoint, e.g. dagster code-server start ... for hot reload.
resourcesobjectSee values.yamlCode-server resources (definition loading only). Run pods are sized via runPod.resources.
envlist[]Env for the code server and run pods. HOME, TMPDIR and PYTHONDONTWRITEBYTECODE default to /tmp but can be overridden by setting them here.
extraEnvslist[]Env appended after env, so an overlay values file extends rather than replaces it.
envFromlist[]envFrom sources for the code server and run pods, e.g. - secretRef: {name: x}.
extraEnvFromlist[]envFrom appended after envFrom, so an overlay values file extends rather than replaces it.
volumeslistSee values.yamlCode-server volumes: {name, mountPath, readOnly?, subPath?, volumeSpec}. Default is a writable /tmp the read-only root filesystem needs. Run-pod volumes come from the core runLauncher.
extraVolumeslist[]Volumes appended after volumes, so an overlay values file extends rather than replaces it.
imagePullSecretslist["ghcr-pull"]imagePullSecret names for the code server and run pods.
serviceAccountNamestring"default"ServiceAccount for the code server and run pods. The code location is unprivileged: the namespace default SA, token unmounted, no RBAC.
metadataSecretobjectSee values.yamlMetadata DB password secret the code server reads as DAGSTER_PG_PASSWORD. Schedule and sensor evaluation run in the code server and access the Dagster instance (Postgres), so it needs the password; run pods get it from the core runLauncher instead. The secret is reflected into the namespace by the tenant projectDefaults under this fixed name.
podSecurityContextobjectSee values.yamlPod securityContext for the code server (fsGroup lets the non-root uid write /tmp).
containerSecurityContextobjectSee values.yamlContainer securityContext for the code server.

Run pods

KeyTypeDefaultDescription
runPodobjectSee values.yamlPer-location run-pod overrides, deep-merged onto the core runLauncher baseline. Set only what differs; empty inherits the core (securityContext, /tmp, sidecars, resources floor).
runPod.resourcesobject{}Run-pod resources (sizes the data work). Empty inherits the core baseline.
runPod.podSecurityContextobject{}Pod securityContext override (e.g. a different runAsUser). Empty inherits the core baseline.
runPod.automountServiceAccountTokenboolfalseMount the ServiceAccount token in the run pods. The core baseline unmounts it, since run pods normally make no Kubernetes API calls; set true only for a location whose assets do (e.g. the WMTS seed, which creates a Job in the mapserver namespace). Pair it with a serviceAccountName of its own, so the grant does not ride on the namespace default SA.
runPod.labelsobject{}Run-pod labels, merged onto the core runLauncher's labels; a key set here wins. Mainly to opt a location out of a label-selected sidecar injection it does not need (e.g. a mesh sidecar whose profile selects on <mesh>/inject: "true", set to "false" here). Values are stringified, so an unquoted false still renders a valid label value. Empty inherits the core baseline.

Networking

KeyTypeDefaultDescription
networkPoliciesobjectSee values.yamlNetworkPolicies for this code location. Rendered by this chart (not the subchart) through the templates dependency's renderer with this chart as the root, so template expressions in the values resolve against this chart's helpers. Ships the ingress policy letting the tenant's dagster-core reach the code server; add per-location egress here too.

Templates

KeyTypeDefaultDescription
templatesobject{}Support resources rendered by the templates subchart: CiliumNetworkPolicy, SealedSecret, reflected Secret mirrors and generic resources. Plain NetworkPolicies live under networkPolicies above.

Deployment

This chart renders one Dagster code location (a single gRPC code server) as its own Helm release, deployed into its own project namespace, conventionally <tenant>-dagster-<location>. All chart resources are namespace-agnostic (they use Release.Namespace), so the deploy namespace is set by the ArgoCD Application resource in your environment repo.

The code location is unprivileged: the code server runs under the namespace default ServiceAccount with its token unmounted (no kube-config), and it makes no Kubernetes API calls. It serves definitions; the tenant core runs them.

ArgoCD Application example (multi-source)

Each code location combines two ArgoCD sources: this chart, pinned to a git tag of this repo, and a values file from the tenant/environment repo. Using the argocd-apps chart:

applications:
  my-location:
    namespace: tenant-a-dagster-my-location
    project: tenant-a-dagster-my-location
    sources:
      - repoURL: [email protected]:KvalitetsIT/kds-components.git
        targetRevision: <repo-tag>          # git tag from this repo
        path: dagster-code-location
        helm:
          releaseName: my-location
          valueFiles:
            - $values/dagster-my-location/code-location/values.yaml
            - $values/dagster-my-location/code-location/values-test.yaml
      - ref: values
        repoURL: [email protected]:my-org/tenant-a-apps.git
        targetRevision: main
    destination:
      server: https://kubernetes.default.svc
      namespace: tenant-a-dagster-my-location

Cross-chart contract

This chart's Service is how the dagster-workspace-generator discovers code locations and groups them under the right tenant core. The Service and Deployment carry two labels:

  • dagster.io/code-location: "true" - the generator's label selector for finding code-location Services cluster-wide.
  • dagster.io/location-name: <locationName> - the workspace location_name the generator writes into the core's dagster-workspace-yaml ConfigMap. Defaults to the release name; override via locationName for dev/prod parity with the module folder name.

There is deliberately no core-namespace label: the generator derives the target core namespace from the Service's own namespace (its tenant.kitkube.dk/name label, or the namespace's first hyphen segment, mapped to <tenant>-dagster-core). The Service exposes a port named grpc on 4000, the address the generator writes into the workspace entry (host: <service>.<namespace>, port: 4000) and the address the tenant core's webserver and daemon connect to.

Environment variables

env is the location's application config (settings and credentials via valueFrom.secretKeyRef), applied to both the code server and the launched run pods. extraEnvs is appended after env so an overlay values file (e.g. values-<env>.yaml) can extend it without replacing it - Helm replaces list values across files rather than merging them, so a single env key across two files would lose the base entries. envFrom (extended by extraEnvFrom) carries whole-secret / ConfigMap sources as standard envFrom entries ({secretRef}/{configMapRef}); the chart applies them verbatim to the code server and extracts their names into the run pods' container context (env_secrets/env_config_maps). The chart appends HOME=/tmp, TMPDIR=/tmp and PYTHONDONTWRITEBYTECODE=1 (the read-only root filesystem needs a writable HOME).

Container context and run pods

The code server sets DAGSTER_CLI_API_GRPC_CONTAINER_CONTEXT on its own container: a JSON blob the tenant core's K8sRunLauncher deep-merges into every run pod it launches for this location. It carries only per-location deltas - routing (namespace: <Release.Namespace> so runs launch into this location's own namespace, the default ServiceAccount, image pull secrets) and payload (the location env, env_secrets, and runPod.resources). Optionally it carries runPod.podSecurityContext when the location image needs a different uid, and runPod.labels when the location needs different run-pod labels than the core's.

All run-pod hardening is the core runLauncher baseline, configured once per core and inherited by every location: the container securityContext (drop ALL, read-only root filesystem, no privilege escalation), the pod-level securityContext (runAsNonRoot/runAsUser/runAsGroup/fsGroup/seccomp Kyverno's Restricted PSS requires), automountServiceAccountToken: false, the writable /tmp emptyDir, any sidecar-injection labels, DAGSTER_HOME, and DAGSTER_PG_PASSWORD (the metadata password). The Dagster instance is not mounted into run pods at all: the core daemon serializes the full instance into each run's execute_run args (instance_ref), so the run pod reads its storage config from there rather than from any dagster.yaml/ConfigMap in its own namespace.

Run-pod resources

The core runLauncher's resources are a baseline shared by every location of a tenant. To size a single location's runs, set runPod.resources; the chart puts them in this location's container context, which Dagster deep-merges onto the launcher baseline and uses for the run container. This is per location and does not touch the shared core. The top-level resources value is separate and applies only to the code server (definition loading). Other per-location run-pod overrides live under the same runPod key (e.g. runPod.podSecurityContext).

Run-pod labels

The core runLauncher labels every run pod it launches, and those labels are what sidecar injectors and admission policies select on. runPod.labels sets labels for this location's run pods only; Dagster merges them over the launcher's own labels, so a key set here wins. The usual reason to set it is to opt a location out of an injection it has no use for - a location that only reaches in-cluster services and the public internet does not need a mesh sidecar, and skipping it drops the sidecar's startup gate and its resource requests from every run. Set the injector's own selector key to "false" (or whatever value the selector does not match):

runPod:
  labels:
    example.com/mesh-inject: "false"

Values are stringified before they reach the container context, so an unquoted false is still a valid label value. Labels are the only per-location way to change injection: the label the core sets is a launcher-wide default, and a location cannot remove a key, only override its value.

Kubernetes API access from run pods

Run pods make no Kubernetes API calls, so the core runLauncher baseline unmounts their ServiceAccount token. A location whose assets do call the API - launching a Job in another namespace and following its logs, say - sets runPod.automountServiceAccountToken: true, which carries automount_service_account_token in this location's run_k8s_config.pod_spec_config and overrides the baseline for its run pods alone. The code server keeps its own token unmounted regardless; it never needs one.

serviceAccountName: my-location
runPod:
  automountServiceAccountToken: true

The token is only an identity: it grants nothing until something binds a Role to that ServiceAccount, and system:authenticated holds no rights in these namespaces. Give such a location a serviceAccountName of its own rather than leaving it on the namespace default SA, so the RoleBinding that grants the access covers this location and not every workload in the namespace. The binding itself belongs with whatever owns the resources being reache

Deploy dagster-code-location with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has dagster-code-location 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 chartdagster-code-location is pinned at v0.0.6 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