Skip to content

Deploy ziti-management service and enable Ziti in the gateway #152

Description

@rowan-stein

User Request

Enable Ziti in the gateway. This issue covers the bootstrap Terraform changes to:

  1. Deploy the ziti-management service (currently not deployed)
  2. Provision a PostgreSQL database for ziti-management
  3. Enable Ziti in the gateway by passing env vars through the existing env list in Helm values

Specification

Current Behavior

  • The ziti-management service repo exists (agynio/ziti-management) with a Helm chart and container image, but no ArgoCD application deploys it.
  • The gateway ArgoCD application does not pass any Ziti configuration.
  • The Ziti infrastructure (controller, router, services, identities, policies) is fully provisioned in stacks/ziti/.

Target Behavior

Deploy ziti-management with its database, then enable Ziti in the gateway by passing env vars directly.

Changes Required

All changes are in stacks/platform/.

1. stacks/platform/variables.tf

Add these variables (follow existing patterns):

variable "ziti_management_chart_version" {
  type        = string
  description = "Version of the ziti-management Helm chart published to GHCR"
  default     = "0.1.0"
}

variable "ziti_management_image_tag" {
  type        = string
  description = "Optional override for the ziti-management container image tag"
  default     = ""
}

variable "ziti_management_db_password" {
  type        = string
  description = "Password for the ziti-management PostgreSQL database user"
  default     = "ziti_management"
  sensitive   = true
}

variable "ziti_management_db_pvc_size" {
  type        = string
  description = "Persistent volume claim size for the ziti-management PostgreSQL primary"
  default     = "5Gi"
}

2. stacks/platform/main.tf — locals block

Add to the locals block, following existing patterns:

Resolved image tag (in the resolved_* section):

  resolved_ziti_management_image_tag = trimspace(var.ziti_management_image_tag) != "" ? var.ziti_management_image_tag : var.ziti_management_chart_version

Chart name (in the chart name section):

  ziti_management_chart_name = "agynio/charts/ziti-management"

DB values (in the DB values section, follow agents_db_values pattern):

  ziti_management_db_values = yamlencode({
    fullnameOverride = "ziti-management-db"
    postgres = {
      database = "ziti_management"
      username = "ziti_management"
      password = var.ziti_management_db_password
      pgdata   = "/var/lib/postgresql/data/pgdata"
    }
    persistence = {
      size                    = var.ziti_management_db_pvc_size
      mountPath               = "/var/lib/postgresql/data"
      volumeClaimTemplateName = "data"
    }
    probes = {
      readiness = {
        execCommand = ["pg_isready", "-U", "ziti_management", "-d", "ziti_management"]
      }
      liveness = {
        execCommand = ["pg_isready", "-U", "ziti_management", "-d", "ziti_management"]
      }
    }
  })

Service values (in the service values section, follow agents_values pattern):

  ziti_management_values = yamlencode({
    fullnameOverride = "ziti-management"
    image = {
      repository = "ghcr.io/agynio/ziti-management"
      tag        = local.resolved_ziti_management_image_tag
      pullPolicy = "IfNotPresent"
    }
    env = [
      {
        name  = "DATABASE_URL"
        value = format("postgresql://ziti_management:%s@ziti-management-db:5432/ziti_management?sslmode=disable", var.ziti_management_db_password)
      },
      {
        name  = "ZITI_CONTROLLER_URL"
        value = format("https://ziti-mgmt.%s:%d/edge/management/v1", local.base_domain, local.ingress_port)
      },
    ]
  })

3. stacks/platform/main.tf — new ArgoCD applications

ziti-management DB (sync-wave "8", follow agents_db pattern):

resource "argocd_application" "ziti_management_db" {
  depends_on = [argocd_repository.litellm_repo]
  wait       = true

  metadata {
    name      = "ziti-management-db"
    namespace = "argocd"
    annotations = {
      "argocd.argoproj.io/sync-wave" = "8"
    }
  }

  spec {
    project = "default"
    source {
      repo_url        = local.postgres_chart_repo_host
      chart           = local.postgres_chart_name
      target_revision = var.postgres_chart_version
      helm {
        values = local.ziti_management_db_values
      }
    }
    destination {
      server    = var.destination_server
      namespace = var.platform_namespace
    }
    sync_policy {
      automated {
        prune       = false
        self_heal   = true
        allow_empty = false
      }
      sync_options = local.postgres_sync_options
    }
  }
}

ziti-management service (sync-wave "17", depends on its DB):

resource "argocd_application" "ziti_management" {
  depends_on = [
    argocd_repository.litellm_repo,
    argocd_application.ziti_management_db,
  ]

  metadata {
    name      = "ziti-management"
    namespace = "argocd"
    annotations = {
      "argocd.argoproj.io/sync-wave" = "17"
    }
  }

  spec {
    project = "default"
    source {
      repo_url        = local.platform_chart_repo_host
      chart           = local.ziti_management_chart_name
      target_revision = var.ziti_management_chart_version
      helm {
        values = local.ziti_management_values
      }
    }
    destination {
      server    = var.destination_server
      namespace = var.platform_namespace
    }
    sync_policy {
      dynamic "automated" {
        for_each = var.argocd_automated_sync_enabled ? [1] : []
        content {
          prune       = var.argocd_prune_enabled
          self_heal   = var.argocd_self_heal_enabled
          allow_empty = false
        }
      }
      sync_options = local.default_sync_options
    }
  }
}

4. stacks/platform/main.tf — update gateway ArgoCD application

Add argocd_application.ziti_management to depends_on and pass Ziti env vars through the existing env list (same pattern used by agents, users, etc.):

resource "argocd_application" "gateway" {
  depends_on = [argocd_application.llm, argocd_application.ziti_management]
  ...
      helm {
        values = yamlencode({
          replicaCount = 1
          image = {
            tag = local.resolved_gateway_image_tag
          }
          gateway = {
            oidcIssuerUrl   = var.oidc_issuer_url
            oidcClientId    = var.oidc_client_id
            usersGrpcTarget = "users:50051"
          }
          env = [
            {
              name  = "ZITI_ENABLED"
              value = "true"
            },
            {
              name  = "ZITI_MANAGEMENT_GRPC_TARGET"
              value = "ziti-management:50051"
            },
          ]
        })
      }

Prerequisites

  • The ziti-certs Kubernetes Secret must exist in the platform namespace with the enrolled TLS credentials for the ziti-management identity.

Notes

  • No changes to the gateway Helm chart are needed — the env list is supported by the service-base library chart used by all services.
  • ZITI_LEASE_RENEWAL_INTERVAL is intentionally omitted — the Go default of 2m is correct.
  • ZITI_MANAGEMENT_GRPC_TARGET is set explicitly for clarity even though ziti-management:50051 is the Go default.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions