Skip to content

Commit

Permalink
Merge pull request #367 from vmware/feature/provisioner
Browse files Browse the repository at this point in the history
Management cluster provisioner resource support
  • Loading branch information
shobha2626 authored Jan 3, 2024
2 parents 001ba22 + 8e66181 commit 4a256e1
Show file tree
Hide file tree
Showing 26 changed files with 1,377 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- 'v*'

env:
BUILD_TAGS: 'akscluster cluster clustergroup credential ekscluster gitrepository iampolicy kustomization namespace custompolicy imagepolicy networkpolicy quotapolicy securitypolicy sourcesecret workspace tanzupackage tanzupackages packagerepository packageinstall clustersecret integration mutationpolicy backupschedule targetlocation dataprotection tanzukubernetescluster clusterclass managementcluster'
BUILD_TAGS: 'akscluster cluster clustergroup credential ekscluster gitrepository iampolicy kustomization namespace custompolicy imagepolicy networkpolicy quotapolicy securitypolicy sourcesecret workspace tanzupackage tanzupackages packagerepository packageinstall clustersecret integration mutationpolicy backupschedule targetlocation dataprotection tanzukubernetescluster clusterclass managementcluster provisioner'

jobs:
goreleaser:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Test and coverage
on: [pull_request, push]

env:
BUILD_TAGS: 'akscluster cluster clustergroup credential ekscluster gitrepository iampolicy kustomization namespace custompolicy imagepolicy networkpolicy quotapolicy securitypolicy sourcesecret workspace tanzupackage tanzupackages packagerepository packageinstall clustersecret integration mutationpolicy backupschedule targetlocation dataprotection tanzukubernetescluster clusterclass managementcluster'
BUILD_TAGS: 'akscluster cluster clustergroup credential ekscluster gitrepository iampolicy kustomization namespace custompolicy imagepolicy networkpolicy quotapolicy securitypolicy sourcesecret workspace tanzupackage tanzupackages packagerepository packageinstall clustersecret integration mutationpolicy backupschedule targetlocation dataprotection tanzukubernetescluster clusterclass managementcluster provisioner'
jobs:
build:
name: Test and coverage
Expand Down
1 change: 1 addition & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ run:
- helmfeature
- helmrelease
- managementcluster
- provisioner

linters-settings:
funlen:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ ifeq ($(TEST_FLAGS),)
endif

ifeq ($(BUILD_TAGS),)
BUILD_TAGS := 'akscluster cluster clustergroup credential ekscluster gitrepository iampolicy kustomization namespace custompolicy imagepolicy networkpolicy quotapolicy securitypolicy sourcesecret workspace tanzupackage tanzupackages packagerepository packageinstall clustersecret integration mutationpolicy helmfeature helmrelease backupschedule targetlocation dataprotection tanzukubernetescluster clusterclass managementcluster'
BUILD_TAGS := 'akscluster cluster clustergroup credential ekscluster gitrepository iampolicy kustomization namespace custompolicy imagepolicy networkpolicy quotapolicy securitypolicy sourcesecret workspace tanzupackage tanzupackages packagerepository packageinstall clustersecret integration mutationpolicy helmfeature helmrelease backupschedule targetlocation dataprotection tanzukubernetescluster clusterclass managementcluster provisioner'
endif

.PHONY: build clean-up test gofmt vet lint acc-test website-lint website-lint-fix
Expand Down
69 changes: 69 additions & 0 deletions docs/data-sources/provisioner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
---
Title: "Provisioner data source in a management cluster"
Description: |-
Provisioner data source in a management cluster.
---

# Management Cluster Provisioner

Read provisioner in a management cluster using this Terraform module.

### Tanzu Kubernetes Grid Service and Tanzu Kubernetes Grid vSphere
- Only provisioner read feature is enabled for Tanzu Kubernetes Grid Service and Tanzu Kubernetes Grid vSphere management clusters.
- For a Tanzu Kubernetes cluster running in vSphere, you add a provisioner by creating
a namespace in the management cluster, which you can do using kubectl.
For more information, see [Create Namespaces in the Management Cluster] in the VMware Tanzu Kubernetes Grid Product Documentation.
- For a Tanzu Kubernetes cluster running in vSphere with Tanzu, you add a provisioner by creating
a vSphere namespace in the Supervisor Cluster, which you can do in your vSphere environment.
For more information, see [Configuring and Managing vSphere Namespaces] in the vSphere with
Tanzu Configuration and Management documentation.

[Create Namespaces in the Management Cluster] : https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid/1.5/vmware-tanzu-kubernetes-grid-15/GUID-cluster-lifecycle-multiple-management-clusters.html#namespaces
[Configuring and Managing vSphere 7.x Namespaces] : https://docs.vmware.com/en/VMware-vSphere/7.0/vmware-vsphere-with-tanzu/GUID-1544C9FE-0B23-434E-B823-C59EFC2F7309.html
[Configuring and Managing vSphere 8.x Namespaces] : https://docs.vmware.com/en/VMware-vSphere/8.0/vsphere-with-tanzu-services-workloads/GUID-1544C9FE-0B23-434E-B823-C59EFC2F7309.html

### Example Usage

```terraform
# Read Tanzu Mission Control provisioner : fetch the given provisioner details
data "tanzu-mission-control_provisioner" "read_provisioner" {
name = "test-provisioner" # Optional
management_cluster = "eks" # Required
}
# Read Tanzu Mission Control provisioner : fetch all the provisioner details for the given management cluster
data "tanzu-mission-control_provisioner" "read_provisioner" {
management_cluster = "eks" # Required
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `management_cluster` (String) Name of the management cluster

### Optional

- `meta` (Block List, Max: 1) Metadata for the resource (see [below for nested schema](#nestedblock--meta))
- `name` (String) Name of the provisioner
- `org_id` (String) ID of the organization

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedblock--meta"></a>
### 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
74 changes: 74 additions & 0 deletions docs/resources/provisioner.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
Title: "Provisioner resource in a management cluster"
Description: |-
Provisioner resource lifecycle management.
---

# Management Cluster Provisioner

Lifecycle management of provisioner in a management cluster using this Terraform module.

Addition of a provisioner resource refers to creation of namespace in the management cluster.

### Tanzu Kubernetes Grid Service and Tanzu Kubernetes Grid vSphere
- Only provisioner read only feature is enabled for Tanzu Kubernetes Grid Service and Tanzu Kubernetes Grid vSphere management clusters.
- For a Tanzu Kubernetes cluster running in vSphere, you add a provisioner by creating
a namespace in the management cluster, which you can do using kubectl.
For more information, see [Create Namespaces in the Management Cluster] in the VMware Tanzu Kubernetes Grid Product Documentation.
- For a Tanzu Kubernetes cluster running in vSphere with Tanzu, you add a provisioner by creating
a vSphere namespace in the Supervisor Cluster, which you can do in your vSphere environment.
For more information, see [Configuring and Managing vSphere Namespaces] in the vSphere with
Tanzu Configuration and Management documentation.

[Create Namespaces in the Management Cluster] : https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid/1.5/vmware-tanzu-kubernetes-grid-15/GUID-cluster-lifecycle-multiple-management-clusters.html#namespaces
[Configuring and Managing vSphere 7.x Namespaces] : https://docs.vmware.com/en/VMware-vSphere/7.0/vmware-vsphere-with-tanzu/GUID-1544C9FE-0B23-434E-B823-C59EFC2F7309.html
[Configuring and Managing vSphere 8.x Namespaces] : https://docs.vmware.com/en/VMware-vSphere/8.0/vsphere-with-tanzu-services-workloads/GUID-1544C9FE-0B23-434E-B823-C59EFC2F7309.html

### Example Usage

```terraform
# Create provisioner resource
resource "tanzu-mission-control_provisioner" "create_provisioner" {
name = "demo-test" # Required
management_cluster = "eks" # Required
meta {
description = "Create provisioner through terraform"
labels = {
"key1" : "value1",
"key2" : "value2",
}
}
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `management_cluster` (String) Name of the management cluster. Edit operation such as create, update and delete is not supported for TKG vSphere & TKG service vSphere management cluster provisioners.
- `name` (String) Name of the provisioner

### Optional

- `meta` (Block List, Max: 1) Metadata for the resource (see [below for nested schema](#nestedblock--meta))
- `org_id` (String) ID of the organization

### Read-Only

- `id` (String) The ID of this resource.

<a id="nestedblock--meta"></a>
### 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
10 changes: 10 additions & 0 deletions examples/data-sources/provisioner/data_source_provisioner.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Read Tanzu Mission Control provisioner : fetch the given provisioner details
data "tanzu-mission-control_provisioner" "read_provisioner" {
name = "test-provisioner" # Optional
management_cluster = "eks" # Required
}

# Read Tanzu Mission Control provisioner : fetch all the provisioner details for the given management cluster
data "tanzu-mission-control_provisioner" "read_provisioner" {
management_cluster = "eks" # Required
}
13 changes: 13 additions & 0 deletions examples/resources/provisioner/provisioner_resource.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Create provisioner resource
resource "tanzu-mission-control_provisioner" "create_provisioner" {
name = "demo-test" # Required
management_cluster = "eks" # Required

meta {
description = "Create provisioner through terraform"
labels = {
"key1" : "value1",
"key2" : "value2",
}
}
}
3 changes: 3 additions & 0 deletions internal/client/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import (
helmchartsorgclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/organization/helmcharts"
iamorganizationclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/organization/iam_policy"
policyorganizationclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/organization/policy"
provisionerclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/provisioner"
"github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/proxy"
tanzukubernetesclusterclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/tanzukubernetescluster"
tanzupackageclusterclient "github.com/vmware/terraform-provider-tanzu-mission-control/internal/client/tanzupackage"
Expand Down Expand Up @@ -142,6 +143,7 @@ func newHTTPClient(httpClient *transport.Client) *TanzuMissionControl {
ManagementClusterRegistrationResourceService: managementclusterregistrationclient.New(httpClient),
ClusterClassResourceService: clusterclassclient.New(httpClient),
TanzuKubernetesClusterResourceService: tanzukubernetesclusterclient.New(httpClient),
ProvisionerResourceService: provisionerclient.New(httpClient),
}
}

Expand Down Expand Up @@ -199,4 +201,5 @@ type TanzuMissionControl struct {
ManagementClusterRegistrationResourceService managementclusterregistrationclient.ClientService
ClusterClassResourceService clusterclassclient.ClientService
TanzuKubernetesClusterResourceService tanzukubernetesclusterclient.ClientService
ProvisionerResourceService provisionerclient.ClientService
}
104 changes: 104 additions & 0 deletions internal/client/provisioner/provisioner_resource.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

42 changes: 42 additions & 0 deletions internal/models/provisioner/provisioner_create.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 4a256e1

Please sign in to comment.