complex

by Cookielab s.r.o.

Helm chartv1.15.0MITVerified publisher

For deploying applications with consumers and cronjobs

About this chart

complex

For deploying applications, consumers and cronjobs

Homepage: https://github.com/cookielab/helm-charts/tree/main/complex

Features

The complex Helm chart provides a comprehensive solution for deploying containerized applications with:

  • ConfigMap integration: Environment variables and file mounting from ConfigMaps
  • Secret integration: Environment variables and file mounting from Secrets
  • ExternalSecret integration: Generate External Secrets Operator resources
  • Volume mounts: Mount ConfigMaps and Secrets as files with custom paths
  • Persistent storage: Create new PVCs or reference existing ones for shared storage (EFS)
  • Consumer workloads: Support for consumer-type deployments
  • CronJob support: Scheduled job execution
  • Enterprise features: Immutable ConfigMaps, custom labels/annotations
  • GitLab integration: Built-in GitLab CI/CD support via lib-gitlab dependency
  • Kubernetes best practices: Following cloud-native patterns via lib-kubernetes
  • Prometheus monitoring: Integrated metrics and alerting via lib-prometheus

Component Types

The chart supports multiple component types for different workload patterns:

1. HTTP Components (type: http)

Web services and APIs with HTTP endpoints.

Creates: Deployment, Service, optionally Ingress, HPA, Target Groups

2. HTTP Internal Components (type: http-internal)

Internal web services and APIs that are not exposed externally.

Creates: Deployment, Service, optionally HPA (does not create Ingress or Target Groups)

3. Consumer Components (type: consumer)

Background workers that process messages from queues.

Creates: Deployment, optionally KEDA ScaledObject for auto-scaling

4. CronJob Components (type: cronjob)

Scheduled tasks that run periodically.

Creates: CronJob

5. Pre-Job Components (type: pre-job)

One-time jobs that run before the main application (e.g., migrations).

Creates: Job

Set activeDeadlineSeconds to give the Job a deadline. Kubernetes then terminates its pods and marks the Job failed when it is still active after that time, so a hung migration fails the release instead of blocking it. Without it the Job has no deadline.

components:
  migrate:
    type: pre-job
    command: ["bin/migrate"]
    activeDeadlineSeconds: 300

6. Ingress Components (type: ingress)

Standalone ingress resources that route to external services without creating deployments.

Creates: Ingress only (no Deployment or Service)

Use Cases:

  • API documentation aggregators
  • Reverse proxy configurations
  • Routing to services managed by other charts
  • Multiple ingress resources with different authentication

Key Features:

  • Route to external services using externalService field in paths
  • Create multiple independent ingress resources (one per component)
  • Full support for AWS ALB and NGINX ingress controllers
  • Custom annotations for authentication (OIDC, etc.)
  • Support for multiple hosts and TLS configurations

Example:

components:
  api-docs-aggregator:
    type: ingress
    ingress:
      className: alb
      annotations:
        alb.ingress.kubernetes.io/scheme: internet-facing
        alb.ingress.kubernetes.io/healthcheck-path: "/-/health"
      hosts:
        - host: docs.example.com
          paths:
            - path: /docs/service1
              pathType: Prefix
              externalService: service1-svc
              port: 80
            - path: /docs/service2
              pathType: Prefix
              externalService: service2-svc
              port: 8080

See testing-values/values-ingress-only.yaml for complete examples including:

  • Multiple ingress resources with different authentication
  • OIDC/SSO integration
  • Multi-domain routing
  • Path-based routing patterns

Service ports and workload settings

components.<name>.ports[].port remains the container port. HTTP components can set servicePort to expose a different Service port, and targetPort to select a numeric or named container port. Both default to port, preserving existing values. Set ingress paths' servicePort to the exposed Service port when using an override.

global.podSecurityContext provides Pod-level defaults for Deployments, consumers, CronJobs and pre-jobs. components.<name>.podSecurityContext merges over those defaults, with each component field replacing the corresponding global field, including nested objects such as seccompProfile. This is separate from the existing components.<name>.securityContext, which still configures only the application container.

Use components.<name>.annotations for annotations on that component's Deployment, Job or CronJob metadata. They merge over global.metadata.annotations at the workload root only. They do not propagate to Pod templates, inner CronJob Jobs, Services or other components. Global annotations keep their existing scope.

For example, expose a non-root worker on Service port 443, let it read a group-owned Secret volume, and opt only this Deployment into Infisical credential reloads:

components:
  worker:
    type: http-internal
    replicas: 1
    ports:
      - name: runner
        port: 3443
        servicePort: 443
        targetPort: runner
    podSecurityContext:
      fsGroup: 1000
    securityContext:
      runAsUser: 1000
      runAsNonRoot: true
    annotations:
      secrets.infisical.com/auto-reload: "true"
    # Configure the worker's image, probes and Secret imports as usual.

Traefik Middlewares

The chart supports defining Traefik Middleware resources at both global and component levels.

Note: To use this feature, the Traefik Custom Resource Definitions (CRDs) must be installed in the cluster. See Traefik CRD Documentation for details. See Traefik Middleware Documentation for details.

Defining Middlewares

Global Middlewares (global.traefikMiddlewares) are created once and can be referenced by any component:

global:
  traefikMiddlewares:
    - name: security-headers
      spec:
        headers:
          stsSeconds: 31536000
          stsIncludeSubdomains: true

Component Middlewares (components.<name>.traefikMiddlewares) are created for that specific component:

components:
  api:
    traefikMiddlewares:
      - name: strip-prefix
        spec:
          stripPrefix:
            prefixes:
              - /api

Referencing Middlewares in Ingress

Use ingress.traefikMiddlewareRefs to apply middlewares to an ingress (sets traefik.ingress.kubernetes.io/router.middlewares annotation):

components:
  api:
    ingress:
      className: traefik
      hosts:
        - host: api.example.com
          paths:
            - path: /
              pathType: Prefix
              servicePort: 8080
      traefikMiddlewareRefs:
        - global:security-headers    # Reference global middleware
        - strip-prefix               # Reference component middleware
        - auth@file                  # External middleware reference
    traefikMiddlewares:
      - name: strip-prefix
        spec:
          stripPrefix:
            prefixes:
              - /api

Reference formats:

  • global:<name> - Global middleware (e.g., global:security-headers), resolved to the <release>-<name> Middleware the chart renders
  • <name> - Component middleware (e.g., strip-prefix), resolved to <release>-<component>-<name>; a name that matches no middleware defined in the chart is taken as an existing Middleware resource called <name> in the release namespace
  • <name>@<provider> - External reference (e.g., auth@file, other-middleware@kubernetescrd), passed through unchanged

The chart translates the first two forms to the Traefik kubernetescrd address <namespace>-<Middleware name>@kubernetescrd.

Init Containers

The chart supports defining init containers that run before the main container starts. Init containers are useful for:

  • Running setup scripts or database migrations
  • Waiting for dependent services to be ready
  • Downloading configuration files or secrets
  • Setting up volumes with proper permissions

Defining Init Containers

Init containers are defined at the component level using initContainers:

components:
  api:
    type: http
    ports:
      - port: 3000
    initContainers:
      wait-for-db:
        image:
          repository: busybox
          tag: "1.36"
        command:
          - sh
          - -c
          - |
            until nc -z postgres-service 5432; do
              echo "Waiting for database..."
              sleep 2
            done
        resources:
          requests:
            cpu: "50m"
            memory: "64M"
          limits:
            cpu: "100m"
            memory: "128M"

Init Container Properties

Each init container supports the same properties as regular containers:

PropertyDescriptionRequired
image.repositoryContainer image repositoryYes
image.tagContainer image tagYes
image.pullPolicyImage pull policy (IfNotPresent, Always, Never)No
commandOverride container entrypointNo
argsArguments to the entrypointNo
envs.valuesEnvironment variables as key-value pairsNo
envs.from.configMapsLoad env vars from ConfigMapsNo
envs.from.secretsLoad env vars from SecretsNo
resourcesCPU/memory requests and limitsNo
volumeMountsMount ConfigMaps or Secrets as filesNo

Configuration Structure

Global vs Component-Specific Configuration

The chart uses a two-level configuration system:

  1. Global: Default settings applied to all components
  2. Component-specific: Overrides for individual components

Component-specific settings always override global settings.

Environment Variables Priority

Environment variables are merged in the following order (later overrides earlier):

  1. Global values (global.container.envs.values)
  2. Component-specific values (components.<n>.envs.values)
  3. Global envFrom (global.container.envs.from.configMaps/secrets)
  4. Component-specific envFrom (components.<n>.envs.from.configMaps/secrets)

Priority Examples

Example 1 - Component overrides Global:

global:
  container:
    envs:
      values:
        DATABASE_URL: "postgresql://global-db:5432/app"
        LOG_LEVEL: "info"

components:
  api:
    envs:
      values:
        DATABASE_URL: "postgresql://api-db:5432/api"  # Component value takes precedence
        API_KEY: "api-specific-key"

Result for api component:

  • DATABASE_URL=postgresql://api-db:5432/api ← Component-specific value
  • LOG_LEVEL=info ← Inherited from global configuration
  • API_KEY=api-specific-key ← Component-specific value

Example 2 - envFrom vs hardcoded values:

# ConfigMap contains: API_KEY=from-configmap
global:
  container:
    envs:
      values:
        API_KEY: "hardcoded-value"  # Applied first
      from:
        configMaps:
          - app-config              # Overrides hardcoded values

components:
  api:
    envs:
      values:
        API_KEY: "component-hardcoded"  # Has highest priority

Result for api component:

  • API_KEY=component-hardcoded ← Component-specific value has highest priority

Priority order (highest to lowest):

  1. Component hardcoded values (components.<n>.envs.values)
  2. Component envFrom (components.<n>.envs.from.*)
  3. Global envFrom (global.container.envs.from.*)
  4. Global hardcoded values (global.container.envs.values)

External Secrets

External secret resources can be declared under externalSecrets. Each entry renders a HashiCorp VaultStaticSecret by default, an External Secrets Operator ExternalSecret when kind: ExternalSecret is set, or an Infisical Kubernetes operator InfisicalSecret when kind: InfisicalSecret is set. The raw spec passes provider-specific and newer CRD fields through without chart changes. Helm templating is not applied inside spec, which keeps operator template expressions such as {{ .password }} intact.

global:
  container:
    envs:
      from:
        secrets:
          - name: app-admin-vault-envs
            optional: true

externalSecrets:
  app-admin-vault-envs:
    kind: ExternalSecret
    spec:
      dataFrom:
        - extract:
            conversionStrategy: Default
            decodingStrategy: None
            key: dev/admin/envs
            metadataPolicy: None
      refreshInterval: 60s
      secretStoreRef:
        kind: SecretStore
        name: vault-secret-store
      target:
        creationPolicy: Owner
        deletionPolicy: Retain
        name: app-admin-vault-envs
        template:
          engineVersion: v2
          mergePolicy: Replace
          metadata:
            annotations:
              managed: ExternalSecretsOperator

HashiCorp Vault Secrets Operator example:

externalSecrets:
  app-admin-vault-envs:
    spec:
      destination:
        create: true
        name: app-admin-vault-envs
        overwrite: false
      hmacSecretData: true
      mount: kv2/appio_dev1
      path: robe/xcc_admin
      refreshAfter: 300s
      type: kv-v2
      vaultAuthRef: vault-default-auth

Infisical Kubernetes operator example (Kubernetes Auth, so no Infisical credential is stored in the cluster; the referenced service account needs the system:auth-delegator ClusterRole when the

Deploy complex with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has complex 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 chartcomplex is pinned at v1.15.0 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