Skip to content

Latest commit

 

History

History
184 lines (126 loc) · 6.18 KB

File metadata and controls

184 lines (126 loc) · 6.18 KB
Title Description
Kustomization Resource
Creating the Kustomization resource.

Kustomization

The tanzu-mission-control_kustomization resource allows you to add, update, and delete Kustomization to a particular scope through Tanzu Mission Control.

To create a kustomization, you must be associated with the cluster.admin or clustergroup.admin role

In Creation of kustomization we must required to create Git Repository first, which we need to referenced in spec of kustomization, Git Repository can be created by using "tanzu-mission-control_git_repository" resource from terraform provider itself.

Kustomization Scope

In the Tanzu Mission Control resource hierarchy, there are two levels at which you can specify Kustomization resources:

  • object groups - cluster_group block under scope sub-resource
  • Kubernetes objects - cluster block under scope sub-resource

Note: The scope parameter is mandatory in the schema and the user needs to add one of the defined scopes to the script for the provider to function. Only one scope per resource is allowed.

Cluster group scoped Kustomization

Example Usage

# Create Tanzu Mission Control kustomization with attached set as default value.
resource "tanzu-mission-control_kustomization" "create_cluster_group_kustomization" {
  name = "tf-kustomization-name" # Required

  namespace_name = "tf-namespace" #Required

  scope {
    cluster_group {
      name = "default" # Required
    }
  }

  meta {
    description = "Create namespace through terraform"
    labels      = { "key" : "value" }
  }

  spec {
    path             = "testPath" # Required
    prune            = "testPrune"
    interval         = "10m" # Default: 5m
    target_namespace = "testTargetNamespace"
    source {
      name      = "testGitRepositoryName"      # Required
      namespace = "testGitRepositoryNamespace" # Required
    }
  }
}

Cluster scoped Kustomization

Example Usage

# Create Tanzu Mission Control kustomization with attached set as default value.
resource "tanzu-mission-control_kustomization" "create_cluster_kustomization" {
  name = "tf-kustomization-name" # Required

  namespace_name = "tf-namespace" #Required

  scope {
    cluster {
      name                    = "testcluster" # Required
      provisioner_name        = "attached"    # Default: attached
      management_cluster_name = "attached"    # Default: attached
    }
  }

  meta {
    description = "Create namespace through terraform"
    labels      = { "key" : "value" }
  }

  spec {
    path             = "testPath" # Required
    prune            = "testPrune"
    interval         = "10m" # Default: 5m
    target_namespace = "testTargetNamespace"
    source {
      name      = "testGitRepositoryName"      # Required
      namespace = "testGitRepositoryNamespace" # Required
    }
  }
}

Schema

Required

  • name (String) Name of the Kustomization.
  • namespace_name (String) Name of Namespace.
  • scope (Block List, Min: 1, Max: 1) Scope for the kustomization, having one of the valid scopes: cluster, cluster_group. (see below for nested schema)
  • spec (Block List, Min: 1, Max: 1) Spec for the Repository. (see below for nested schema)

Optional

Read-Only

  • id (String) The ID of this resource.
  • status (Map of String) Status for the Kustomization.

Nested Schema for scope

Optional:

Nested Schema for scope.cluster

Required:

  • name (String) Name of this cluster

Optional:

  • management_cluster_name (String) Name of the management cluster
  • provisioner_name (String) Provisioner of the cluster

Nested Schema for scope.cluster_group

Required:

  • name (String) Name of the cluster group

Nested Schema for spec

Required:

  • path (String) Path within the source from which configurations will be applied. The path must exactly match what is in the repository.
  • source (Block List, Min: 1, Max: 1) Reference to the source from which the configurations will be applied. Please select an existing repository. (see below for nested schema)

Optional:

  • interval (String) Interval defines the interval at which to reconcile kustomization.
  • prune (Boolean) If true, the workloads will be deleted when the kustomization CR is deleted. When prune is enabled, removing the kustomization will trigger a removal of all kubernetes objects previously applied on all clusters of this cluster group by this kustomization.
  • target_namespace (String) TargetNamespace sets or overrides the namespaces of resources/kustomization yaml while applying on cluster. Namespace specified here must exist on cluster. It won't be created as a result of specifying here. Enter the name of the namespace you want the kustomization to be synced to. Entering a target namespace removes the need to specify a namespace in your kustomization. If the namespace does not exist in the cluster, syncing the kustomization will fail.

Nested Schema for spec.source

Required:

  • name (String) Name of the repository.
  • namespace (String) Namespace of the repository.

Nested Schema for meta

Optional:

  • annotations (Map of String) Annotations for the resource
  • description (String) Description of the resource
  • labels (Map of String) Labels for the resource

Read-Only:

  • resource_version (String) Resource version of the resource
  • uid (String) UID of the resource