Fetch details of an existing RKE cluster template:
data "rancher2_cluster_template" "hardened" {
name = "hardened-template"
}
or create a new RKE cluster template:
# Rancher cluster template
resource "rancher2_cluster_template" "template_hardened" {
name = "Hardened Cluster Template"
template_revisions {
name = "v1"
default = true
cluster_config {
cluster_auth_endpoint {
enabled = false
}
rke_config {
kubernetes_version = "v1.15.12-rancher2-3"
ignore_docker_version = false
network {
plugin = "flannel"
}
services {
etcd {
backup_config {
enabled = false
}
}
}
}
}
questions = [{
default = "v1.15.12-rancher2-3"
required = false
type = string
variable = "rancherKubernetesEngineConfig.kubernetesVersion"
}]
}
Provision a new RKE Cluster from the template and specify variable overrides:
resource "rancher2_cluster" "foo" {
name = "foo"
cluster_template_id = "${data.rancher2_cluster_template.hardened.id}"
cluster_template_revision_id = "${data.rancher2_cluster_template.hardened.default_revision_id}"
cluster_template_answers {
values = {
"rancherKubernetesEngineConfig.kubernetesVersion" = "v1.15.12-rancher2-3"
}
}
}