Add init containers, shared namespaces, per-volume sizing, and user/label support #997

Merged
prathamesh merged 7 commits from feature/init-containers into main 2026-03-12 10:34:46 +00:00

7 Commits

Author SHA1 Message Date
6c00176048 Fix lint and deploy test failures
Some checks failed
Smoke Test / Run basic test suite (pull_request) Has been cancelled
Webapp Test / Run webapp test suite (pull_request) Has been cancelled
K8s Deployment Control Test / Run deployment control suite on kind/k8s (pull_request) Has been cancelled
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Has been cancelled
Deploy Test / Run deploy test suite (pull_request) Has been cancelled
Lint Checks / Run linter (pull_request) Has been cancelled
- Rename ambiguous variable 'l' to 'item' in cluster_info.py (flake8 E741)
- Use underscore in test config variable name (Docker Compose rejects
  hyphens in env var names)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-12 10:32:57 +00:00
a9bd110001 Support per-volume resource sizing in spec files
Some checks failed
Lint Checks / Run linter (pull_request) Failing after 1h23m55s
Deploy Test / Run deploy test suite (pull_request) Has been cancelled
K8s Deploy Test / Run deploy test suite on kind/k8s (pull_request) Has been cancelled
K8s Deployment Control Test / Run deployment control suite on kind/k8s (pull_request) Has been cancelled
Webapp Test / Run webapp test suite (pull_request) Has been cancelled
Smoke Test / Run basic test suite (pull_request) Has been cancelled
Add get_volume_resources_for(volume_name) to look up per-volume storage
sizes from the spec. Supports both the original global format and a new
per-volume format:

  # Global (unchanged, backwards compatible)
  resources:
    volumes:
      reservations:
        storage: 5Gi

  # Per-volume (new)
  resources:
    volumes:
      my-data:
        reservations:
          storage: 10Gi
      my-cache:
        reservations:
          storage: 1Gi

Fallback chain: per-volume -> global -> default (2Gi).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 09:12:14 +00:00
36385f065d Support compose user: directive as k8s runAsUser
Read the user: field from compose service definitions and map it to
securityContext.runAsUser on the k8s container spec. Needed for init
containers using images that run as non-root by default (e.g.
bitnami/kubectl runs as UID 1001).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 06:24:50 +00:00
577576fd69 Add app label to Deployment metadata for label-based cleanup
Deployments were the only resource type missing the `app` label on
their metadata. Services, ConfigMaps, PVCs, and Jobs all had it.
Without it, _delete_resources_by_label() in down() couldn't find
Deployments when cleaning up in a shared namespace.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 06:01:16 +00:00
da3850a727 fix(k8s): delete resources by label in shared namespaces
When the spec explicitly sets a namespace (shared with other stacks),
down() now deletes only this stack's resources by app label instead of
deleting the entire namespace. Prevents stopping one stack from wiping
all other stacks in the same namespace.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 05:28:08 +00:00
cfbede2ee8 Support namespace and kind-cluster-name overrides in spec
Add optional 'namespace' and 'kind-cluster-name' fields to spec
files. When 'namespace' is set, SO uses it instead of deriving one
from the cluster-id. When 'kind-cluster-name' is set, SO uses it
for the kube context instead of the cluster-id. Together these allow
multiple stacks with different cluster-ids (unique resource names)
to share a namespace and kind cluster.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 04:07:26 +00:00
dcba9e74d9 feat(k8s): support init containers via compose labels
Add support for k8s init containers defined in docker-compose files
using the `laconic.init-container` label. Services with this label
set to "true" are built as init containers instead of regular
containers in the pod spec.

This enables stacks to fetch runtime-created ConfigMaps (e.g. from
deployer jobs) before the main containers start, without requiring
manual operator steps between deployments.

Example compose usage:

  services:
    fetch-config:
      image: bitnami/kubectl:latest
      labels:
        laconic.init-container: "true"
      command: ["sh", "-c", "kubectl get configmap ..."]
      volumes:
        - shared-config:/config

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 04:07:26 +00:00