rancher / terraform-provider-rancher2

Terraform Rancher2 provider
https://www.terraform.io/docs/providers/rancher2/
Mozilla Public License 2.0
253 stars 217 forks source link

Improve Terraform/vSphere documentation #1340

Open rak-phillip opened 8 months ago

rak-phillip commented 8 months ago

The Terraform/vSphere docs could be improved by adding examples of how to write the credential and vSphere node template blocks in the TF config. This would help users get started with using Terraform to manage their vSphere infrastructure.

Acceptance Criteria

Example template

provider "rancher2" {
    api_url = {{API_URL}}
    access_key = {{ACCESS_KEY}}
    secret_key = {{SECRET_KEY}}
    insecure = true
}

resource "rancher2_cloud_credential" "foo" {
    name = "foo"
    description = "foo test"
    vsphere_credential_config {
        password = {{PASSWORD}}
        username = {{USERNAME}}
        vcenter = {{VCENTER}}
    }
}

# Create vsphere machine config v2
resource "rancher2_machine_config_v2" "foo" {
    generate_name = "test-foo"
    vsphere_config {
        clone_from = {{CLONE_FROM}}
        creation_type = "template"
        datacenter = {{DATACENTER}}
        folder = {{FOLDER}}
        pool = {{POOL}}
        vcenter = {{VCENTER}}
    }
}

# Create a new rancher v2 Cluster with multiple machine pools
resource "rancher2_cluster_v2" "foo-rke2" {
  name = "foo-rke2"
  kubernetes_version = "v1.22.17+k3s1"
  enable_network_policy = false
  default_cluster_role_for_project_members = "user"
  rke_config {
    machine_pools {
      name = "pool1"
      cloud_credential_secret_name = rancher2_cloud_credential.foo.id
      control_plane_role = true
      etcd_role = true
      worker_role = false
      quantity = 1
      drain_before_delete = true
      machine_config {
        kind = rancher2_machine_config_v2.foo.kind
        name = rancher2_machine_config_v2.foo.name
      }
    }
    # Each machine pool must be passed separately
    machine_pools {
      name = "pool2"
      cloud_credential_secret_name = rancher2_cloud_credential.foo.id
      control_plane_role = false
      etcd_role = false
      worker_role = true
      quantity = 2
      drain_before_delete = true
      machine_config {
        kind = rancher2_machine_config_v2.foo.kind
        name = rancher2_machine_config_v2.foo.name
      }
    }
  }
}
richard-cox commented 8 months ago

@rak-phillip is this one for https://github.com/rancher/rancher-docs?

rak-phillip commented 8 months ago

Perhaps, we really just need to get an accurate example in the right place so future developers will have a more complete reference to get started with.

nwmac commented 2 months ago

@rak-phillip Is this asking that we create for for rancher docs?

or is this our own developer docs?

rak-phillip commented 2 months ago

@nwmac the intent is to update docs for rancher/terraform-provider-rancher2 so that we would have a well documented example that everyone can reference moving forward.

richard-cox commented 2 months ago

If it's more developer targeted i'd vote an issue over at rancher/terraform-provider-rancher2

nwmac commented 2 months ago

FYI @gaktive

This is moved here from UI dashboard repo - ask is better docs - see above.