Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a specific resource/data source to create, read, update and delete CSE Kubernetes clusters #1195

Merged
merged 160 commits into from
Mar 8, 2024

Conversation

adambarreiro
Copy link
Collaborator

@adambarreiro adambarreiro commented Jan 10, 2024

Context

While the generic Runtime Defined Entity resources and data sources (vcd_rde, vcd_rde_type, vcd_rde_interface, etc) to create and manage Kubernetes clusters is completely valid and usable, it causes some challenges to the final users, as the process can be cumbersome at certain stages, and prone to errors.

The idea of this PR is to provide a new resource and data source vcd_cse_kubernetes_cluster that abstracts users from that complexity.

Description

This PR adds the new data source and resource vcd_cse_kubernetes_cluster, which looks like this:

resource "vcd_cse_kubernetes_cluster" "my_cluster" {
  cse_version            = "4.2.0"
  name                   = "test"
  kubernetes_template_id = data.vcd_catalog_vapp_template.tkg_ova.id
  org                    = data.vcd_org_vdc.vdc.org
  vdc_id                 = data.vcd_org_vdc.vdc.id
  network_id             = data.vcd_network_routed_v2.routed.id
  api_token_file         = vcd_api_token.token.file_name

  control_plane {
    machine_count      = 1
    disk_size_gi       = 20
    sizing_policy_id   = data.vcd_vm_sizing_policy.tkg_small.id
    storage_profile_id = data.vcd_storage_profile.sp.id
  }

  worker_pool {
    name               = "pool-1"
    machine_count      = 1
    disk_size_gi       = 20
    sizing_policy_id   = data.vcd_vm_sizing_policy.tkg_small.id
    storage_profile_id = data.vcd_storage_profile.sp.id
  }

  default_storage_class {
    name               = "sc-1"
    storage_profile_id = data.vcd_storage_profile.sp.id
    reclaim_policy     = "delete"
    filesystem         = "ext4"
  }

  auto_repair_on_errors = true
  node_health_check     = true

  operations_timeout_minutes = 0
}

output "kubeconfig" {
  value = vcd_cse_kubernetes_cluster.my_cluster.kubeconfig
}

The resource allows to create the cluster with the given specs, to update the existing pools or add more, or set/unset the machine health check settings.

It supports CSE 4.1.x and 4.2.0

Extra features

This PR also adds the data source vcd_version that fetches the VCD version and allows to make some conditionals in HCL code with it.

Testing

Testing CSE methods

To run the CSE tests, one must set the TEST_VCD_CSE environment variable to any non-empty value. The reason is that CSE requires a very unique environment, and the tests take a long time to be executed.

The tests also require a special vcd_test_config.json file that is almost empty and contains the new cse section:

{
  "provider": {
    "user": "administrator",
    "password": "password",
    "url": "https://myvcd.com",
    "sysOrg": "System",
    "allowInsecure": true,
    "tfAcceptanceTests": true,
    "useVcdConnectionCache": true,
    "maxRetryTimeout": 600
  },
  "vcd": {
    "org": "tenant_org",
    "vdc": "tenant_vdc"
  },
  "cse": {
    "version": "4.2.0",
    "solutionsOrg": "solutions_org",
    "storageProfile": "*", 
    "tenantOrg": "tenant_org",
    "tenantVdc": "tenant_vdc",
    "routedNetwork": "tenant_net_routed",
    "edgeGateway": "tenant_edgegateway",
    "ovaCatalog": "tkgm_catalog",
    "ovaName": "ubuntu-2004-kube-v1.25.7+vmware.2-tkg.1-8a74b9f12e488c54605b3537acb683bc"
  }
}

abarreiro added 8 commits January 4, 2024 11:32
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
@adambarreiro adambarreiro self-assigned this Jan 10, 2024
abarreiro added 21 commits January 11, 2024 12:45
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
#
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
abarreiro added 14 commits March 6, 2024 12:58
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
nit
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Copy link
Collaborator

@lvirbalas lvirbalas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this big effort.

Copy link
Collaborator

@Didainius Didainius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not easy to grasp it all - great addition.
I provisioned like 5 clusters, modified worked pools, etc. 🤞🏻

Signed-off-by: abarreiro <abarreiro@vmware.com>
Copy link
Contributor

@dataclouder dataclouder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First pass

vcd/datasource_vcd_version.go Outdated Show resolved Hide resolved
vcd/datasource_vcd_version.go Show resolved Hide resolved
vcd/resource_vcd_cse_kubernetes_cluster.go Outdated Show resolved Hide resolved
website/docs/d/cse_kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved
website/docs/d/cse_kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved
website/docs/r/cse_kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved
website/docs/r/cse_kubernetes_cluster.html.markdown Outdated Show resolved Hide resolved
abarreiro added 7 commits March 8, 2024 09:40
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
Signed-off-by: abarreiro <abarreiro@vmware.com>
@adambarreiro adambarreiro merged commit 72a3677 into vmware:main Mar 8, 2024
3 checks passed
@adambarreiro adambarreiro deleted the add-cse-cluster-resource branch March 8, 2024 11:46
@adambarreiro adambarreiro mentioned this pull request Mar 8, 2024
adambarreiro added a commit that referenced this pull request Mar 12, 2024
* Fix 'TestAccDataSourceNotFound' so 'vcd_cse_kubernetes_cluster' (introduced in #1195) is ignored.
* Fix 'TestAccDataSourceNotFound' so 'vcd_version' (introduced in #1195) is ignored.
* Adds a specific ENF data source test for 'vcd_cse_kubernetes_cluster' data source, which requires the special 'cse' config block.
* Fix a hard-coded parameter in the data source template used by 'TestAccVcdCseKubernetesCluster'.
* Fix 'TestAccVcdNetworkRoutedV2NsxtRouteAdvertisement' and 'TestAccVcdVAppVmCopyDifferentVdc' to not to be run with org user.
* Fix changelog entry .changes/v3.12.0/1210-improvements.md which had an incorrect file name.
* Fix 'TestAccVcdVersion-step2' binary test (needs to be skipped).

Signed-off-by: abarreiro <abarreiro@vmware.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants