https://rancher.com/ logo
#terraform-provider-rancher2
Title
# terraform-provider-rancher2
b

blue-controller-9088

01/11/2023, 11:25 PM
Can somebody share an example of rke2_config to create a custom RKE2 cluster? Unfortunately, there is not much in resource documentation.
b

blue-controller-9088

01/20/2023, 6:30 PM
As I mentioned “Unfortunately, there is not much in resource documentation” for RKE2. For example, how to change service_cluster_ip_range and cluster_cidr (these are RKE1 settings). How to set max_pods for kubelet.
m

microscopic-diamond-94749

01/20/2023, 6:56 PM
Copy code
machine_global_config = <<-EOT
      cni: "cilium"
      disable-kube-proxy: true
      disable-cloud-controller: true
      etcd-expose-metrics: false
      cluster-cidr: ${var.k8s_cluster_cidr}
      service-cidr: ${var.k8s_service_cidr}
      cluster-dns: ${var.k8s_cluster_dns}
      tls-san: [${join(", ", var.k8s_tls_sans)}]
      EOT
the
machine_global_config
setting is what you're looking for.
I to understand how the Terraform settings work it's helpful to change settings in the Rancher UI and then switch to edit YAML to see what effect it had
b

blue-controller-9088

01/20/2023, 7:17 PM
Thanks, appreciate it. I think the last question is how to set max_pods for kubelet?
m

microscopic-diamond-94749

01/20/2023, 8:12 PM
no idea. Can you set than in the UI?
b

blue-controller-9088

01/20/2023, 9:59 PM
in “advanced” it exposes kubelet extra args wich becomes the following : machineSelectorConfig: - config: cloud-provider-name: flexpod kubelet-arg: - max-pods=500 protect-kernel-defaults: “false”
So I guess I could use it as machine_selector_config { config = { cloud-provider-name = “flexpod” protect-kernel-defaults = false kubelet-arg = [“max-pods=500"] }
will try if it works. But I also need to set node-cidr-mask-size = “23” somewhere
Not sure where, in RKE1 it was a part of kube_controller extra_args. I’m using cilium for CNI with disabled kube-proxy and cloud-controller. Somewhere in rke2-cilium chart_values?
Figured it out. This machine_global_config does the job
👍 1
137 Views