Hello, looking for advice or others' experiences w...
# general
w
Hello, looking for advice or others' experiences with regards to setting up infra as code for Rancher cluster configurations. The goal: save rancher rke2 cluster configuration in git and have a CI/CD pipeline for applying the configuration. One option we considered is terraform-provider-rancher2. Another option I considered was using fleet and adding a git repo to
fleet-local
and having it apply
<http://clusters.provisioning.cattle.io|clusters.provisioning.cattle.io>
resources to the management server cluster. This worked except that it doesn't provide a straightforward way for fleet to "take over" a cluster that was instantiated in the UI.
c
have you looked at https://github.com/rancher/cluster-template-examples? it is basically using helm charts + values to deploy clusters.
w
Thanks for sharing. This is an interesting approach as it pairs well with the UI but also provides version control and more predictable changes.
The other problem we had was settings outside of the gui, like RKE2 settings and additional manifests were a challenge in the UI. For example, specifying a machineSelectorFiles value once resulted in rancher applying some bad config that caused our k8s workers to all start getting drained when we didn't want them to get drained. using these helm charts we could keep "values.yaml" very simple, just for the variations between clusters, but then put most of the config in the chart repo.
b
w
nice, thanks for sharing this. This gives a more comprehensive overview of how rancher/rancher2 TF provider can function. .
b
Yeah, I am working these examples into the provider right now, so if there is any use case you would like to add or anything that doesn't make sense please let me know.
There is also some information in the #C07M052K9D0 channel
w
I’ll take a look there. The import flow is what I just experimented with today. That would be a helpful example. I am not my company’s terragrunt expert but we have a staging and production rancher, each with clusters that conform to a pattern but obviously have different values. So a terragrunt, multi rancher example might help
b
Is the goal to move clusters from one Rancher to another? Are the clusters something like EKS? Why the import flow?
w
Our clusters are bare metal “custom” clusters. The goal of the import flow is because these clusters were provisioned in the rancher UI, but the UI has been unpredictable for making changes in production. Eg having to edit the YAML for machine selector configs, getting the indentation wrong, and rancher rolling the whole cluster (for our workload, that is unfortunately a problem). We just really need infra as code instead UI driven management for our downstream clusters.
b
Hmm, when you say "import" I think you are talking about importing the cluster into terraform state, not importing the clusters to Rancher then, right?
w
Sorry, that’s a good point. I’m talking about importing a rke2 cluster that was provisioned in the UI, then put it into terraform.
Overall, it’s pretty easy, it’s just worth noting that it’s possible.
b
Sorry for the late reply, yes, I will write a test showing how to preform terraform imports.
w
Nice, thanks!