Terraform RKE providers can easily deploy Kubernetes clusters with Rancher Kubernetes Engine.
- Terraform: v0.11+
- RKE: v0.1.7 (Kubernetes 1.8, 1.9 and 1.10)
- Install Terraform v0.11+
- Add the
terraform-provider-rke
plugin binary In~/.terraform.d/plugins/
It is same as the requirements of RKE
- Docker versions
1.11.2
up to1.13.1
and17.03.x
are validated for Kubernetes versions 1.8, 1.9 and 1.10- OpenSSH 7.0+ must be installed on each node for stream local forwarding to work.
- The SSH user used for node access must be a member of the
docker
group:- Ports 6443, 2379, and 2380 should be opened between cluster nodes.
- Swap disabled on worker nodes.
resource rke_cluster "cluster" {
nodes = [
{
address = "1.2.3.4"
user = "rancher"
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 = "${path.root}/kube_config_cluster.yml"
// content = "${rke_cluster.cluster.kube_config_yaml}"
//}
- default k8s version:
v1.10.1-rancher1
- default network plugin:
canal
You can view an example of using RKE provider and Kubernetes provider together, here.
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 Kazumichi Yamamoto.
This project is published under Apache 2.0 License.
- Kazumichi Yamamoto (@yamamoto-febc)