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

[FEATURE] terraform-provider-rancher2 to support to add additional NIC and disks #2733

Closed
guangbochen opened this issue Sep 5, 2022 · 3 comments
Assignees
Labels
area/rancher Rancher related including internal and external area/terraform-provider Harvester Terraform provider for manage Harvester resources highlight Highlight issues/features kind/enhancement Issues that improve or augment existing functionality not-require/test-plan Skip to create a e2e automation test issue priority/0 Must be fixed in this release
Milestone

Comments

@guangbochen
Copy link
Contributor

guangbochen commented Sep 5, 2022

Is your feature request related to a problem? Please describe.

  • Allow to add a second NIC in rancher2_machine_config_v2
  • Allow to add second disk in rancher2_machine_config_v2

Additional context

@guangbochen guangbochen added kind/enhancement Issues that improve or augment existing functionality priority/1 Highly recommended to fix in this release area/terraform-provider Harvester Terraform provider for manage Harvester resources area/rancher Rancher related including internal and external labels Sep 5, 2022
@guangbochen guangbochen added this to the v1.1.1 milestone Sep 5, 2022
@guangbochen guangbochen added priority/0 Must be fixed in this release and removed priority/1 Highly recommended to fix in this release labels Dec 8, 2022
@guangbochen guangbochen added the highlight Highlight issues/features label Jan 10, 2023
@futuretea futuretea added the not-require/test-plan Skip to create a e2e automation test issue label Feb 3, 2023
@harvesterhci-io-github-bot
Copy link
Collaborator

harvesterhci-io-github-bot commented Feb 3, 2023

Pre Ready-For-Testing Checklist

* [ ] If labeled: require/HEP Has the Harvester Enhancement Proposal PR submitted?
The HEP PR is at:

* [ ] Where is the reproduce steps/test steps documented?
The reproduce steps/test steps are at:

* [ ] Is there a workaround for the issue? If so, where is it documented?
The workaround is at:

* [ ] Have the backend code been merged (harvester, harvester-installer, etc) (including backport-needed/*)?
The PR is at:

* [ ] Does the PR include deployment change (YAML/Chart)? If so, where are the PRs for both YAML file and Chart?
The PR for the YAML change is at:
The PR for the chart change is at:

* [ ] If labeled: area/ui Has the UI issue filed or ready to be merged?
The UI issue/PR is at:

* [ ] If labeled: require/doc, require/knowledge-base Has the necessary document PR submitted or merged?
The documentation/KB PR is at:

* [ ] If NOT labeled: not-require/test-plan Has the e2e test plan been merged? Have QAs agreed on the automation test case? If only test case skeleton w/o implementation, have you created an implementation issue?
- The automation skeleton PR is at:
- The automation test case PR is at:

* [ ] If the fix introduces the code for backward compatibility Has a separate issue been filed with the label release/obsolete-compatibility?
The compatibility issue is filed at:

@lanfon72 lanfon72 self-assigned this Mar 21, 2023
@lanfon72
Copy link
Member

new version of terraform-provider-rancher2 not released yet.

@lanfon72 lanfon72 assigned lanfon72 and unassigned lanfon72 Mar 21, 2023
@lanfon72
Copy link
Member

Verified this feature has been implemented.

Test Information

  • Environment: qemu/KVM single node
  • Harvester Version: v1.1-e257df76-head
  • ui-source Option: Auto
  • Rancher Version:
    • v2.6-a2423b17e80dfbc184cc6a8ead6680d802889979-head
    • v2.7-2b2ed443065a9f38c4c5764461be33823eb6fec3-head

Verify Steps

  1. Install Harvester with any nodes
  2. Install Rancher
  3. Login to Harvester dashboard, create an image (ubuntu) for VM creation
  4. Create a VM Network which able to access Rancher
  5. Import Harvester into Rancher named vm
  6. Install terraform-provider-rancher2 (Version > v1.25.0)
  7. Apply code snippet in Additional content
    • Update all UPPER_CASE info in the code snippet
  8. View RKE2 cluster config after It provisioned (configuration will not able to view before RKE2 provisioned)

Additional Context

ref to rancher/terraform-provider-rancher2#1051 (comment)

Code snippet as below:

terraform {
  required_providers {
    rancher2 = {
      source = "rancher/rancher2"
      version = "0.0.0-master"
    }
  }
}


provider "rancher2" {
  api_url    = "RANCHER_URL"
  access_key = "RANCHER_ACCESS_TOKEN"
  secret_key = "RANCHER_SECRET_KEY_FOR_TOKEN"
  insecure = true
}


data "rancher2_cluster_v2" "foo-harvester" {
  name = "vm"
}

# Create a new Cloud Credential for an imported Harvester cluster
resource "rancher2_cloud_credential" "foo-harvester" {
  name = "foo-harvester"
  harvester_credential_config {
    cluster_id = data.rancher2_cluster_v2.foo-harvester.cluster_v1_id
    cluster_type = "imported"
    kubeconfig_content = data.rancher2_cluster_v2.foo-harvester.kube_config
  }
}

# Create a new rancher2 machine config v2 using harvester node_driver
resource "rancher2_machine_config_v2" "foo-harvester-v2" {
  generate_name = "harv"
  harvester_config {
    vm_namespace = "default"
    cpu_count = "2"
    memory_size = "4"
    disk_info = <<EOF
    {
        "disks": [{
            "imageName": "IMAGE_ID",
            "size": 40,
            "bootOrder": 1
        },{
            "storageClassName": "harvester-longhorn",
            "size": 5,
            "bootOrder": 2
        }]
    }
    EOF
    network_info = <<EOF
    {
        "interfaces": [{
            "networkName": "VM_NETWORK_ID",
            "macAddress": ""
        },{
            "networkName": "VM_NETWORK_ID",
            "macAddress": ""
        }]
    }
    EOF
    ssh_user = "ubuntu"
    user_data = <<EOF
#cloud-config
package_update: true
packages:
  - qemu-guest-agent
runcmd:
  - - systemctl
    - enable
    - '--now'
    - qemu-guest-agent.service
password: password
chpasswd: {expire: False}
sshpwauth: True
EOF
    network_data = <<EOF
version: 1
config:
  - type: physical
    name: enp1s0
    subnets:
      - type: dhcp
  - type: physical
    name: enp2s0
    subnets:
      - type: dhcp
EOF
  }
}

resource "rancher2_cluster_v2" "foo-harvester-v2" {
  name = "harv2"
  kubernetes_version = "v1.24.9+rke2r2"
  rke_config {
    machine_pools {
      name = "pool1"
      cloud_credential_secret_name = rancher2_cloud_credential.foo-harvester.id
      control_plane_role = true
      etcd_role = true
      worker_role = true
      quantity = 1
      machine_config {
        kind = rancher2_machine_config_v2.foo-harvester-v2.kind
        name = rancher2_machine_config_v2.foo-harvester-v2.name
      }
    }
    machine_selector_config {
      config = {
        cloud-provider-name = ""
      }
    }
    machine_global_config = <<EOF
cni: "calico"
disable-kube-proxy: false
etcd-expose-metrics: false
EOF
    upgrade_strategy {
      control_plane_concurrency = "10%"
      worker_concurrency = "10%"
    }
    etcd {
      snapshot_schedule_cron = "0 */5 * * *"
      snapshot_retention = 5
    }
    chart_values = ""
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rancher Rancher related including internal and external area/terraform-provider Harvester Terraform provider for manage Harvester resources highlight Highlight issues/features kind/enhancement Issues that improve or augment existing functionality not-require/test-plan Skip to create a e2e automation test issue priority/0 Must be fixed in this release
Projects
None yet
Development

No branches or pull requests

5 participants