rancher / terraform-provider-rancher2

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

Question: customize the calico config? #1311

Closed matttrach closed 4 months ago

matttrach commented 4 months ago

Using the rancher2 terraform provider to deploy RKE clusters with calico CNI and wants to customize the calico config, in this case to add prometheusMetricsEnabled: true.

Is that possible?

matttrach commented 4 months ago

Here is the example from the docs explaining how to send the RKE cluster config:

# Create a new rancher2 cluster template
resource "rancher2_cluster_template" "foo" {
  name = "foo"
  members {
    access_type = "owner"
    user_principal_id = "local://user-XXXXX"
  }
  template_revisions {
    name = "V1"
    cluster_config {
      rke_config {
        network {
          plugin = "canal"
        }
        services {
          etcd {
            creation = "6h"
            retention = "24h"
          }
        }
      }
    }
    default = true
  }
  description = "Test cluster template v2"
}
# Create a new rancher2 RKE Cluster from template
resource "rancher2_cluster" "foo" {
  name = "foo"
  cluster_template_id = rancher2_cluster_template.foo.id
  cluster_template_revision_id = rancher2_cluster_template.foo.template_revisions.0.id
}
matttrach commented 4 months ago

I found that on this page: https://registry.terraform.io/providers/rancher/rancher2/latest/docs/resources/cluster

matttrach commented 4 months ago

The follow up on this is "ok, so how do I send the correct config options to RKE?"

matttrach commented 4 months ago

The answer to that is that it may not be possible at this time. The design of the network configuration options for RKE restricts which options are allowed to be set to a specific list. Limiting the options was a design choice so we will need to change the design to enable extensibility into the config, this would be a choice for our product management team.

In the mean time, a workaround would be to set the network config to none in RKE and install Calico separately with the config that works for you. Here is a tutorial by Tigera (the team that develops Calico) to do just that: https://docs.tigera.io/calico/latest/getting-started/kubernetes/rancher#before-you-begin