<p>I created this simple Terraform script with Rancher to create namespace in imported Kubernetes cluster:</p>
<pre><code>terraform {
  required_providers {
    rancher2 = {
      source = &quot;rancher/rancher2&quot;
      version = &quot;1.24.1&quot;
    }
  }
}

provider &quot;rancher2&quot; {
  api_url   = &quot;https://192.168.1.128/v3&quot;
  token_key = &quot;token-n4fxx:4qcgctvph7qh2sdnn762zpzg889rgw8xpd2nvcnpnr4v4wpb9zljtd&quot;
  insecure = true
}

resource &quot;rancher2_namespace&quot; &quot;zone-1&quot; {
  name = &quot;zone-1&quot;
  project_id = &quot;c-m-xmhbjzdt:p-sd86v&quot;
  description = &quot;zone-1 namespace&quot;
  resource_quota {
    limit {
      limits_cpu = &quot;100m&quot;
      limits_memory = &quot;100Mi&quot;
      requests_storage = &quot;1Gi&quot;
    }
  }
  container_resource_limit {
    limits_cpu = &quot;20m&quot;
    limits_memory = &quot;20Mi&quot;
    requests_cpu = &quot;1m&quot;
    requests_memory = &quot;1Mi&quot;
  }
}
</code></pre>
<p>The question is how I can create Pods into the Kubernetes cluster using again Terraform script?</p>

Peter Penzov
<p>Terraform offers the <a href="https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs" rel="nofollow noreferrer">Kubernetes Provider</a> which allows you to create all kind of Kubernetes objects.</p>
<p>To quote the <a href="https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/pod#example-usage" rel="nofollow noreferrer">documentation of the &quot;kubernetes_pod&quot;-resource</a>:</p>
<pre><code>resource &quot;kubernetes_pod&quot; &quot;test&quot; {
metadata {
  name = &quot;terraform-example&quot;
}

spec {
  container {
    image = &quot;nginx:1.21.6&quot;
    name  = &quot;example&quot;

    env {
      name  = &quot;environment&quot;
      value = &quot;test&quot;
    }

    port {
      container_port = 80
    } 

    liveness_probe {
      http_get {
        path = &quot;/&quot;
        port = 80

        http_header {
          name  = &quot;X-Custom-Header&quot;
          value = &quot;Awesome&quot;
        }
      }

      initial_delay_seconds = 3
      period_seconds        = 3
    }
  }

  dns_config {
    nameservers = [&quot;1.1.1.1&quot;, &quot;8.8.8.8&quot;, &quot;9.9.9.9&quot;]
    searches    = [&quot;example.com&quot;]

    option {
      name  = &quot;ndots&quot;
      value = 1
    }

    option {
      name = &quot;use-vc&quot;
    }
  }

  dns_policy = &quot;None&quot;
}
</code></pre>
<p>}</p>
