kubernetes_daemon_set_v1

A DaemonSet ensures that all (or some) Nodes run a copy of a Pod. As nodes are added to the cluster, Pods are added to them. As nodes are removed from the cluster, those Pods are garbage collected. Deleting a DaemonSet will clean up the Pods it created.

Example Usage

resource "kubernetes_daemon_set_v1" "example" {
  metadata {
    name      = "terraform-example"
    namespace = "something"
    labels = {
      test = "MyExampleApp"
    }
  }

  spec {
    selector {
      match_labels = {
        test = "MyExampleApp"
      }
    }

    template {
      metadata {
        labels = {
          test = "MyExampleApp"
        }
      }

      spec {
        container {
          image = "nginx:1.21.6"
          name  = "example"

          resources {
            limits = {
              cpu    = "0.5"
              memory = "512Mi"
            }
            requests = {
              cpu    = "250m"
              memory = "50Mi"
            }
          }

          liveness_probe {
            http_get {
              path = "/"
              port = 80

              http_header {
                name  = "X-Custom-Header"
                value = "Awesome"
              }
            }

            initial_delay_seconds = 3
            period_seconds        = 3
          }

        }
      }
    }
  }
}

Argument Reference

The following arguments are supported:

Nested Blocks

metadata

Arguments

Attributes

spec

Arguments

strategy

Arguments

rolling_update

Arguments

template

Arguments

template metadata

These arguments are the same as the for the metadata block of a Pod with a few exceptions:

Please see the Pod resource for reference.

template spec

Arguments

affinity

Arguments

node_affinity

Arguments

required_during_scheduling_ignored_during_execution

Arguments

node_selector_term

Arguments

match_expressions / match_fields

Arguments

preferred_during_scheduling_ignored_during_execution

Arguments

preference

Arguments

match_expressions / match_fields

Arguments

pod_affinity

Arguments

pod_anti_affinity

Arguments

required_during_scheduling_ignored_during_execution (pod_affinity_term)

Arguments

preferred_during_scheduling_ignored_during_execution

Arguments

container

Arguments

aws_elastic_block_store

Arguments

azure_disk

Arguments

azure_file

Arguments

capabilities

Arguments

ceph_fs

Arguments

cinder

Arguments

config_map

Arguments

config_map_ref

Arguments

config_map_key_ref

Arguments

dns_config

Arguments

The option block supports the following:

downward_api

Arguments

empty_dir

Arguments

env

Arguments

env_from

Arguments

exec

Arguments

fc

Arguments

field_ref

Arguments

flex_volume

Arguments

flocker

Arguments

gce_persistent_disk

Arguments

git_repo

Arguments

glusterfs

Arguments

grpc

Arguments

host_aliases

Arguments

host_path

Arguments

http_get

Arguments

http_header

Arguments

image_pull_secrets

Arguments

iscsi

Arguments

items

Arguments

lifecycle

Arguments

liveness_probe

Arguments

nfs

Arguments

persistent_volume_claim

Arguments

photon_persistent_disk

Arguments

port

Arguments

post_start

Arguments

pre_stop

Arguments

quobyte

Arguments

rbd

Arguments

readiness_probe

Arguments

resources

Arguments

resources is a computed attribute and thus if it is not configured in terraform code, the value will be computed from the returned Kubernetes object. That causes a situation when removing resources from terraform code does not update the Kubernetes object. In order to delete resources from the Kubernetes object, configure an empty attribute in your code.

Please, look at the example below:

resources {
  limits   = {}
  requests = {}
}

resource_field_ref

Arguments

seccomp_profile

Attributes

se_linux_options

Arguments

secret

Arguments

The items block supports the following:

secret_ref

Arguments

secret_key_ref

Arguments

secret_ref

Arguments

container security_context

Arguments

capabilities

Arguments

pod security_context

Arguments

Sysctl

tcp_socket

Arguments

value_from

Arguments

toleration

Arguments

projected

Arguments

sources

Arguments

service_account_token

Arguments

volume

Arguments

volume_mount

Arguments

vsphere_volume

Arguments

ephemeral

Arguments

volume_claim_template

Arguments

Timeouts

The following Timeout configuration options are available for the kubernetes_daemon_set_v1 resource:

Import

DaemonSet can be imported using the namespace and name, e.g.

$ terraform import kubernetes_daemon_set_v1.example default/terraform-example