Application example

Deploy FastAPI to Kubernetes

Ship a FastAPI image with migrations as an init container, secret env wiring, and a Gateway API route—without a per-service chart.

Chart fidelity

Examples below match Universal Helm Chart application 0.4.3 keys from values.yaml and docs/configuration.md. Replace ghcr.io/example-org/* images and hostnames with your own.

Chart 0.4.3 — args / multi-port / service.enabled

From application 0.4.3: main container args (default []); Deployment revisionHistoryLimit (default 10); multi-port via containerPorts and service.ports; optional chart-managed Service via service.enabled (default true). When service.ports is set, Ingress / simple HTTPRoute / NOTES use the first entry (templates/_helpers.tpl application.servicePort). Legacy single-port service.name / service.port / service.protocol / service.appProtocol remain supported. Set service.enabled: false when the workload does not need a chart-managed Service. Do not invent other port keys.

Install the chart once

helm repo add universal https://chaser100.github.io/u-helm-chart
helm repo update
helm search repo universal/application --versions

Package: Artifact Hub · universal-helm-chart/application.

values.yaml

Copy from the reference example, then replace the image registry and hostname. Keys below are valid chart values (see linked example page for the full file).

replicaCount: 2
image: ghcr.io/example-org/fastapi
imageTag: "1.0.0"
imagePullPolicy: IfNotPresent
service:
  port: 8080
securityContext:
  runAsNonRoot: true
  runAsUser: 10001
  runAsGroup: 10001
  allowPrivilegeEscalation: false
  readOnlyRootFilesystem: true
  capabilities:
    drop: ["ALL"]
podSecurityContext:
  seccompProfile:
    type: RuntimeDefault
env:
  - name: APP_ENV
    value: production
envFrom:
  - configMapRef:
      name: fastapi-config
envSecrets:
  enableEnv: true
  envs:
    - name: DATABASE_URL
      secretName: fastapi-secrets
      secretKey: DATABASE_URL
configMaps:
  - name: fastapi-config
    data:
      LOG_LEVEL: info
      OTEL_SERVICE_NAME: fastapi
initContainers:
  enabled: true
  containers:
    - name: migrations
      image: ghcr.io/example-org/fastapi
      imageTag: "1.0.0"
      command: ["python", "-m", "app.migrations"]
      securityContext:
        runAsNonRoot: true
        runAsUser: 10001
        runAsGroup: 10001
        allowPrivilegeEscalation: false
        capabilities:
          drop: ["ALL"]
resources:
  requests: {cpu: 100m, memory: 128Mi}
  limits: {cpu: 500m, memory: 512Mi}
readinessProbe:
  httpGet: {path: /health, port: http}
livenessProbe:
  httpGet: {path: /health, port: http}
route:
  enabled: true
  gateway: external
  gatewayNamespace: gateway-system
  sectionName: https
  hostname: fastapi.example.com

initContainers.enabled plus containers[] matches chart comments in values.yaml. Secrets are referenced (envSecrets), not inlined—create fastapi-secrets out of band (External Secrets / sealed secrets / operator).

Deploy

helm upgrade --install fastapi universal/application --version 0.4.3 \
  --namespace apps --create-namespace \
  --values values.yaml

Verify

helm status fastapi -n apps
kubectl get pods,svc,httproute -n apps -l app.kubernetes.io/instance=fastapi
kubectl get httproute -n apps
# After DNS/Gateway attachment:
# curl -fsS https://YOUR_HOSTNAME/health

GitOps: point an Argo CD Application at chart repo https://chaser100.github.io/u-helm-chart, chart application, and this values file.

Open the full reference example → · Gateway API guide → · Getting started →