kubernetes_annotations

This resource allows Terraform to manage the annotations for a resource that already exists. This resource uses field management and server-side apply to manage only the annotations that are defined in the Terraform configuration. Existing annotations not specified in the configuration will be ignored. If an annotation specified in the config and is already managed by another client it will cause a conflict which can be overridden by setting force to true.

Example Usage

resource "kubernetes_annotations" "example" {
  api_version = "v1"
  kind        = "ConfigMap"
  metadata {
    name = "my-config"
  }
  annotations = {
    "owner" = "myteam"
  }
}

Example Usage: Patching resources which contain a pod template, e.g Deployment, Job

resource "kubernetes_annotations" "example" {
  api_version = "apps/v1"
  kind        = "Deployment"
  metadata {
    name = "my-config"
  }
  # These annotations will be applied to the Deployment resource itself
  annotations = {
    "owner" = "myteam"
  }
  # These annotations will be applied to the Pods created by the Deployment
  template_annotations = {
    "owner" = "myteam"
  }
}

Argument Reference

The following arguments are supported:

Nested Blocks

metadata

Arguments

Import

This resource does not support the import command. As this resource operates on Kubernetes resources that already exist, creating the resource is equivalent to importing it.