Applying Tolerations to Akuity Agent Deployments Using Terraform

To create Tolerations to make sure that Akuity agent resources are scheduled on specific nodes

To ensure that Argo CD agents and Kargo agents are scheduled on specific node pools, tolerations can be applied to their deployments. This can be achieved declaratively via the Akuity Terraform provider using the kustomization block on both akp_cluster and akp_kargo_agent resources.

Toleration Specification:

tolerations:
  - key: "workload"
    operator: "Equal"
    value: "akpsystem"
    effect: "NoSchedule"

Terraform Example:

resource "akp_cluster" "example" {
  name      = "my-argocd-cluster"
  namespace = "akuity"

  data = {
    kustomization = jsonencode({
      apiVersion = "kustomize.config.k8s.io/v1beta1"
      kind       = "Kustomization"
      patches = [
        {
          target = {
            kind = "Deployment"
            name = "akuity-agent"
          }
          patch = <<-EOT
            apiVersion: apps/v1
            kind: Deployment
            metadata:
              name: akuity-agent
            spec:
              template:
                spec:
                  tolerations:
                    - key: "workload"
                      operator: "Equal"
                      value: "akpsystem"
                      effect: "NoSchedule"
          EOT
        }
      ]
    })
  }
}

resource "akp_kargo_agent" "kargo" {
  name      = "my-kargo-agent"
  namespace = "akuity-kargo"

  data = {
    kustomization = jsonencode({
      apiVersion = "kustomize.config.k8s.io/v1beta1"
      kind       = "Kustomization"
      patches = [
        {
          target = {
            kind = "Deployment"
            name = "kargo-agent"
          }
          patch = <<-EOT
            apiVersion: apps/v1
            kind: Deployment
            metadata:
              name: kargo-agent
            spec:
              template:
                spec:
                  tolerations:
                    - key: "workload"
                      operator: "Equal"
                      value: "akpsystem"
                      effect: "NoSchedule"
          EOT
        }
      ]
    })
  }
}

Notes

  • This example assumes the agent names are akuity-agent and kargo-agent.

  • Multiple patches can be added to the patches array if needed.

  • The Terraform provider documentation contains additional details for both akp_cluster and akp_kargo_agent.