terraform { required_providers { rancher2 = { source = "rancher/rancher2" version = "3.1.1" } } } # ########## Config Manually ########## # Go to Account -> "Account and API Keys" -> "Create API Key" # ##################################### provider "rancher2" { api_url = "https://rancher.192.168.0.141.sslip.io/v3" access_key = "token-ndjbp" secret_key = "dxx9vr22mhzs97dbd8zm22gq5n2mwscfplbchrdj9s6jskzjxdwvmj" insecure = true } # Get imported harvester cluster info data "rancher2_cluster_v2" "myharvester" { name = "harvester131" } # Create a new Cloud Credential for an imported Harvester cluster resource "rancher2_cloud_credential" "myharvester" { name = "myharvester" harvester_credential_config { cluster_id = data.rancher2_cluster_v2.myharvester.cluster_v1_id cluster_type = "imported" kubeconfig_content = data.rancher2_cluster_v2.myharvester.kube_config } } # Create a new rancher2 machine config v2 using harvester node_driver # Ref. https://registry.terraform.io/providers/rancher/rancher2/latest/docs/resources/cluster_v2#creating-rancher-v2-harvester-cluster-v2-with-harvester-cloud-provider resource "rancher2_machine_config_v2" "rke2-terraform" { generate_name = "rke2-terraform" harvester_config { vm_namespace = "default" cpu_count = "2" memory_size = "4" # ########## Config Manually ########## # Go to "Virtualization Management" -> Click to enter Harvester # Get from image page url (e.g. https://192.168.123.1/x/x/x/default/image-sdrvr#detail) # ##################################### disk_info = < Click to enter Harvester # Get from network url (e.g. https://192.168.123.1/x/x/x/default/mgmt-vlan1#basics) # ##################################### network_info = <