Skip to content

K8s Deployment

Andy Potanin edited this page Jun 21, 2026 · 1 revision

Creates a Kubernetes Deployment from a native manifest definition.

Use this module when a Rabbit service needs a Deployment with full control over pod spec, containers, volumes, and update strategy.

Supported Features

  • Deployment creation from a standard Kubernetes manifest.
  • Replica count configuration.
  • Rolling update strategy with configurable surge and unavailability.
  • Init containers and sidecar containers.
  • Volume mounts and volume definitions.
  • Environment variables from ConfigMaps, Secrets, and field references.
  • Liveness, readiness, and startup probes.
  • Resource requests and limits.
  • Service account assignment.
  • Security contexts.
  • Labels, annotations, and selectors.

Prerequisites

  • A kubeconfig secret created by the k8s-access module.
  • The target namespace must exist.
  • Container images must be accessible from the cluster (typically from us-central1-docker.pkg.dev/rabbit-cdmsqarskcacnbpe/).

Important Notes

  • The configurations key accepts a complete Kubernetes Deployment manifest (without apiVersion and kind).
  • On first deploy, if the rollout times out, the Terraform state may record null identity values. Subsequent runs fail with Unexpected Identity Change. Fix by deleting the deployment and running a destroy cycle (see CLAUDE.md failure modes).
  • Deploy production before develop-* branches to avoid TF state corruption.

Minimal Example

services:
  - name: "k8s Deployment"
    module: "k8s-deployment"
    id: "app-deployment"
    deployment_order: 100
    configurations:
      metadata:
        name: "www-example-com"
        namespace: "www-example-com"
        labels:
          app: "www-example-com"
      spec:
        replicas: 1
        selector:
          matchLabels:
            app: "www-example-com"
        template:
          metadata:
            labels:
              app: "www-example-com"
          spec:
            serviceAccountName: "www-example-com-sa"
            containers:
              - name: "worker-site"
                image: "us-central1-docker.pkg.dev/rabbit-cdmsqarskcacnbpe/worker-site/worker-site:latest"
                ports:
                  - containerPort: 80

Outputs

This module does not produce outputs.

Full Configuration Schema

The configurations key accepts a native Kubernetes Deployment manifest body. See the Kubernetes Deployment spec for the full schema.

configurations:
  metadata:
    name: ""
    namespace: ""
    labels: {}
    annotations: {}
  spec:
    replicas: 1
    selector:
      matchLabels: {}
    strategy:
      type: "RollingUpdate"
      rollingUpdate:
        maxSurge: 1
        maxUnavailable: 0
    template:
      metadata:
        labels: {}
      spec:
        serviceAccountName: ""
        containers: []
        initContainers: []
        volumes: []

Clone this wiki locally