Terraform image bundled with RKE (Rancher Kubernetes Engine) provider plugin
2.3K
Terraform RKE providers can easily deploy Kubernetes clusters with Rancher Kubernetes Engine.
Current master is focusing on RKE v0.2.x. If you use RKE v0.1.x, please see rke/v0.1.x branch.
terraform-provider-rke plugin binary In ~/.terraform.d/plugins/Note: Following examples are compatible with Terraform v0.12.
It is same as the requirements of RKE.
resource rke_cluster "cluster" {
nodes {
address = "1.2.3.4"
user = "rancher"
role = ["controlplane", "worker", "etcd"]
}
}
###############################################################################
# If you need kubeconfig.yml for using kubectl, please uncomment follows.
###############################################################################
//resource "local_file" "kube_cluster_yaml" {
// filename = format("%s/%s" , path.root, "kube_config_cluster.yml")
// content = rke_cluster.cluster.kube_config_yaml
//}
###############################################################################
# If you need cluster.yml for using rke, please uncomment follows.
###############################################################################
//resource "local_file" "rke_cluster_yaml" {
// filename = format("%s/%s", path.root, "cluster.yml")
// content = rke_cluster.cluster.rke_cluster_yaml
//}
###############################################################################
# You can also use an output.
###############################################################################
// output "rke_cluster_yaml" {
// sensitive = true
// value = rke_cluster.cluster.rke_cluster_yaml
//}
v1.14.6-rancher1-1canalvariable "nodes" {
type = list(object({
address = string,
user = string,
}))
default = [
{
address = "192.2.0.1"
user = "ubuntu"
},
{
address = "192.2.0.2"
user = "ubuntu"
},
]
}
resource rke_cluster "cluster" {
dynamic nodes {
for_each = var.nodes
content {
address = nodes.value.address
user = nodes.value.user
role = ["controlplane", "worker", "etcd"]
ssh_key = file("~/.ssh/id_rsa")
}
}
}
###############################################################################
# If you need kubeconfig.yml for using kubectl, please uncomment follows.
###############################################################################
//resource "local_file" "kube_cluster_yaml" {
// filename = format("%s/%s" , path.root, "kube_config_cluster.yml")
// content = rke_cluster.cluster.kube_config_yaml
//}
You can use RKE provider and Kubernetes provider together.
resource rke_cluster "cluster" {
nodes {
address = "1.2.3.4"
user = "ubuntu"
role = ["controlplane", "worker", "etcd"]
ssh_key = file("~/.ssh/id_rsa")
}
}
provider "kubernetes" {
host = rke_cluster.cluster.api_server_url
username = rke_cluster.cluster.kube_admin_user
client_certificate = rke_cluster.cluster.client_cert
client_key = rke_cluster.cluster.client_key
cluster_ca_certificate = rke_cluster.cluster.ca_crt
# load_config_file = false
}
resource "kubernetes_namespace" "example" {
metadata {
name = "terraform-example-namespace"
}
}
You can view examples to deploying Rancher 2.0
You can view full example of tffile, here.
terraform-provider-rke Copyright (C) 2018-2019 Kazumichi Yamamoto.
This project is published under Apache 2.0 License.
Content type
Image
Digest
Size
40.8 MB
Last updated
almost 7 years ago
docker pull yamamotofebc/terraform-provider-rke