PrefectHQ / prefect-recipes

Snippets and templates representing common Customer Success patterns
https://PrefectHQ.github.io/prefect-recipes/
Apache License 2.0
238 stars 29 forks source link

Add terraform helm prefect2 agent recipe #161

Closed jamiezieziula closed 1 year ago

jamiezieziula commented 1 year ago

Description

This recipe allows for the deployment of the prefect2 agent using terraform & the official helm chart. See below for terraform output when testing:

jamiedick in ~/src/prefecthq/prefect-recipes/devops/infrastructure-as-code/helm/prefect2-agent on terraform-helm-prefect2 ● λ tf apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # helm_release.agent will be created
  + resource "helm_release" "agent" {
      + atomic                     = false
      + chart                      = "prefect-agent"
      + cleanup_on_fail            = false
      + create_namespace           = false
      + dependency_update          = false
      + disable_crd_hooks          = false
      + disable_openapi_validation = false
      + disable_webhooks           = false
      + force_update               = false
      + id                         = (known after apply)
      + lint                       = false
      + manifest                   = (known after apply)
      + max_history                = 0
      + metadata                   = (known after apply)
      + name                       = "prefect-agent"
      + namespace                  = "prefect"
      + pass_credentials           = false
      + recreate_pods              = false
      + render_subchart_notes      = true
      + replace                    = false
      + repository                 = "https://prefecthq.github.io/prefect-helm/"
      + reset_values               = false
      + reuse_values               = false
      + skip_crds                  = false
      + status                     = "deployed"
      + timeout                    = 300
      + verify                     = false
      + version                    = "2022.10.6"
      + wait                       = true
      + wait_for_jobs              = false

      + set {
          + name  = "agent.cloudApiConfig.accountId"
          + value = “xxxxxxx”
        }
      + set {
          + name  = "agent.cloudApiConfig.apiKeySecret.key"
          + value = "key"
        }
      + set {
          + name  = "agent.cloudApiConfig.apiKeySecret.name"
          + value = "prefect-api-key"
        }
      + set {
          + name  = "agent.cloudApiConfig.workspaceId"
          + value = "xxxxxxx"
        }
    }

  # kubernetes_namespace.namespace will be created
  + resource "kubernetes_namespace" "namespace" {
      + id = (known after apply)

      + metadata {
          + generation       = (known after apply)
          + name             = "prefect"
          + resource_version = (known after apply)
          + uid              = (known after apply)
        }
    }

  # kubernetes_secret.api_key[0] will be created
  + resource "kubernetes_secret" "api_key" {
      + data                           = (sensitive value)
      + id                             = (known after apply)
      + type                           = "Opaque"
      + wait_for_service_account_token = true

      + metadata {
          + generation       = (known after apply)
          + name             = "prefect-api-key"
          + namespace        = "prefect"
          + resource_version = (known after apply)
          + uid              = (known after apply)
        }
    }

Plan: 3 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

kubernetes_namespace.namespace: Creating...
kubernetes_secret.api_key[0]: Creating...
kubernetes_namespace.namespace: Creation complete after 0s [id=prefect]
kubernetes_secret.api_key[0]: Creation complete after 0s [id=prefect/prefect-api-key]
helm_release.agent: Creating...
helm_release.agent: Creation complete after 3s [id=prefect-agent]

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.

What's cooking? If this PR references an issue, please attach to the existing issue.

Type of change

New Recipe Checklist