Terraform Kubernetes Provider

repository·main·Indexed 23 days ago

https://github.com/hashicorp/terraform-provider-kubernetes

A HashiCorp-maintained plugin that allows users to manage the full lifecycle of Kubernetes resources using Terraform configuration. The provider supports various environments including AKS, EKS, and GKE, and includes capabilities for OIDC authentication, cross-cluster management, and CertificateSigningRequest handling.

Tokens
227.1K
Snippets
386
Records
1.1K
Agent score
81%

What's inside terraform-provider-kubernetes

  1. Overview of Amazon Elastic Block Store (EBS) CSI driver

    main
    The Amazon Elastic Block Store (EBS) Container Storage Interface (CSI) Driver provides a CSI interface that allows Container Orchestrators (such as Kubernetes) to manage the lifecycle of Amazon EBS volumes. This driver is used to automate the provisioning, attaching, and managing of EBS volumes for containerized workloads.
  2. Overview of the Kubernetes Provider for Terraform

    main
    The Kubernetes provider for Terraform is a plugin that enables full lifecycle management of Kubernetes resources. It allows you to manage Kubernetes objects (such as Pods, Services, Deployments, etc.) using Terraform configuration files, integrating Kubernetes resource management into your existing Infrastructure as Code (IaC) workflows.
  3. Manage Kubernetes Ingress resources with kubernetes_ingress_v1

    main
    The kubernetes_ingress_v1 resource allows you to manage Kubernetes Ingress objects. Ingress provides a collection of rules that enable inbound connections to reach backend endpoints. It is used to configure externally-reachable URLs for services, load balance traffic, terminate SSL, and provide name-based virtual hosting.
  4. Manage Kubernetes CronJobs with kubernetes_cron_job

    main

    The kubernetes_cron_job resource allows you to create and manage Kubernetes CronJobs, which execute Jobs on a time-based schedule. Each CronJob object functions similarly to a line in a crontab file, running a job periodically based on a schedule written in Cron format.

    Important Considerations:

    • Timezone: All schedule times are based on the timezone of the Kubernetes master node where the job is initiated.
    • API Version Migration: For Kubernetes v1.25 and later, the batch/v1beta1 API has been removed. You should migrate to the batch/v1 API as per the Kubernetes migration guides.
  5. Configure a validating admission webhook with kubernetes_validating_webhook_configuration_v1

    main
    The kubernetes_validating_webhook_configuration_v1 resource is used to configure a validating admission webhook in Kubernetes. Validating admission webhooks are used to intercept requests to the Kubernetes API server and validate the objects being created or modified based on custom logic.
  6. Manage Horizontal Pod Autoscalers with kubernetes_horizontal_pod_autoscaler_v1

    main

    The kubernetes_horizontal_pod_autoscaler_v1 resource automatically scales the number of pods in a replication controller, deployment, or replica set based on observed CPU utilization.

    To use this resource, you must define a metadata block for identification and a spec block to define the scaling behavior and the target resource being scaled.

    resource "kubernetes_horizontal_pod_autoscaler_v1" "example" {
      metadata {
        name = "terraform-example"
      }
    
      spec {
        max_replicas = 10
        min_replicas = 8
    
        scale_target_ref {
          kind = "Deployment"
          name = "MyApp"
        }
      }
    }
  7. Manage Kubernetes IngressClass resources

    main

    The kubernetes_ingress_class resource allows you to define an IngressClass in Kubernetes. Ingresses use these classes to reference a specific controller and its configuration. This allows multiple controllers to coexist in a cluster, where each Ingress specifies which class it should use to be implemented.

    resource "kubernetes_ingress_class" "example" {
      metadata {
        name = "example"
      }
    
      spec {
        controller = "example.com/ingress-controller"
        parameters {
          api_group = "k8s.example.com"
          kind      = "IngressParameters"
          name      = "external-lb"
        }
      }
    }
  8. Manage Kubernetes Jobs with kubernetes_job_v1

    main
    The kubernetes_job_v1 resource allows you to create and manage Kubernetes Jobs. A Job ensures that one or more Pods successfully terminate. It tracks successful completions and will restart a Pod if it fails or is deleted (e.g., due to node failure). You can use Jobs to run a single task to completion or to run multiple Pods in parallel. Deleting the Job resource in Terraform will clean up the Pods it created.