Skip to main content

Terraform Deployment

Deploy Immich Memories to Kubernetes using Terraform. The module lives in deploy/terraform/.

Prerequisites

  1. Terraform >= 1.0
  2. Kubernetes cluster with:
    • NVIDIA GPU Operator installed
    • NVIDIA RuntimeClass configured
    • Storage class for PVCs
  3. kubeconfig configured and pointing at your cluster

Quick Start

Basic Deployment

cd deploy/terraform/examples/basic

cp terraform.tfvars.example terraform.tfvars
vim terraform.tfvars

terraform init
terraform plan
terraform apply

Production Deployment

cd deploy/terraform/examples/production

cp terraform.tfvars.example terraform.tfvars
vim terraform.tfvars

terraform init
terraform plan
terraform apply

Module Usage

module "immich_memories" {
source = "path/to/deploy/terraform"

# Required
immich_url = "https://photos.example.com"
immich_api_key = var.immich_api_key

# GPU Configuration
gpu_enabled = true
gpu_count = 1

# Storage
output_storage_size = "100Gi"
cache_storage_size = "50Gi"

# Ingress
ingress_enabled = true
ingress_host = "memories.example.com"
}

Variables

Required

NameDescriptionType
immich_urlURL of your Immich instancestring
immich_api_keyImmich API keystring

GPU Configuration

NameDescriptionTypeDefault
gpu_enabledEnable NVIDIA GPU supportbooltrue
gpu_countNumber of GPUs to requestnumber1
gpu_node_selectorNode selector for GPU nodesmap(string){"nvidia.com/gpu.present": "true"}
runtime_class_nameRuntimeClass for NVIDIAstring"nvidia"

Storage

NameDescriptionTypeDefault
output_storage_sizeSize of output PVCstring"50Gi"
cache_storage_sizeSize of cache PVCstring"20Gi"
storage_class_nameStorage class for PVCsstringnull (cluster default)

Ingress

NameDescriptionTypeDefault
ingress_enabledEnable ingressboolfalse
ingress_class_nameIngress classstring"nginx"
ingress_hostIngress hostnamestring"memories.example.com"
ingress_tls_enabledEnable TLSboolfalse
ingress_annotationsExtra ingress annotationsmap(string){}

Application

NameDescriptionTypeDefault
target_duration_secondsDefault video duration in secondsnumber600
output_orientationVideo orientation (landscape, portrait, square)string"landscape"
output_resolutionVideo resolution (720p, 1080p, 4k)string"1080p"
hardware_backendHW acceleration backend (nvidia, auto, none)string"nvidia"

Outputs

NameDescription
namespaceKubernetes namespace
service_nameService name for internal access
service_endpointInternal service endpoint (FQDN)
ingress_hostIngress hostname (if enabled)
port_forward_commandReady-to-run kubectl port-forward command
deployment_nameDeployment name
gpu_enabledWhether GPU support is enabled

Accessing the UI

After terraform apply:

# Use the output directly
$(terraform output -raw port_forward_command)

# Or manually
kubectl port-forward -n immich-memories svc/immich-memories 8080:80

# Open http://localhost:8080

Troubleshooting

GPU Not Detected

# Check GPU Operator pods are running
kubectl get pods -n gpu-operator

# Verify nodes have GPU labels
kubectl get nodes -L nvidia.com/gpu.present

# Verify RuntimeClass exists
kubectl get runtimeclass nvidia

Pod Stuck in Pending

# Check pod events for scheduling errors
kubectl describe pod -n immich-memories -l app.kubernetes.io/name=immich-memories

# Verify PVCs are bound
kubectl get pvc -n immich-memories

Common causes: no GPU nodes available, PVC storage class doesn't exist, or resource requests exceed what the cluster can provide.