terraform-openstack-rke
Terraform module to deploy Kubernetes with RKE on OpenStack.
Inspired by Marco Cappucini work, rewrited from scratch for Terraform 0.12+ and new terraform-rke-provider.
Table of contents
Prerequisites
- Terraform 0.12+
- terraform-provider-rke (waiting to be merged upstream).
- OpenStack environment properly sourced.
- A Openstack image fullfiling RKE requirements.
- At least one Openstack floating IP.
Examples
Minimal example with master node as egde node and two worker nodes
# Consider using 'export TF_VAR_os_auth_url=$OS_AUTH_URL'
variable "os_auth_url"{}
# Consider using 'export TF_VAR_os_password=$OS_AUTH_URL'
variable "os_password"{}
module "rke" {
source = "remche/rke/openstack"
image_name = "ubuntu-18.04-docker-x86_64"
public_net_name = "public"
master_flavor_name = "m1.small"
worker_flavor_name = "m1.small"
os_auth_url = var.os_auth_url
os_password = var.os_password
}
Minimal example with two egde nodes and one worker nodes
# Consider using 'export TF_VAR_os_auth_url=$OS_AUTH_URL'
variable "os_auth_url"{}
# Consider using 'export TF_VAR_os_password=$OS_AUTH_URL'
variable "os_password"{}
module "rke" {
source = "remche/rke/openstack"
image_name = "ubuntu-18.04-docker-x86_64"
public_net_name = "public"
master_flavor_name = "m1.small"
worker_flavor_name = "m1.small"
edge_count = 2
worker_count = 1
master_labels = {"node-role.kubernetes.io/master" = "true"}
edge_labels = {"node-role.kubernetes.io/edge" = "true"}
os_auth_url = var.os_auth_url
os_password = var.os_password
}
Documentation
See variables.tf for all available options, most of them are self-explanatory.
Secgroup
You can define your own rules (e.g. limiting port 22 and 6443 to admin box).
secgroup_rules = [ { "source" = "x.x.x.x", "protocol" = "tcp", "port" = 22 },
{ "source" = "x.x.x.x", "protocol" = "tcp", "port" = 6443 },
{ "source" = "0.0.0.0/0", "protocol" = "tcp", "port" = 80 },
{ "source" = "0.0.0.0/0", "protocol" = "tcp", "port" = 443}
]
Nodes
Default config will deploy one master and two worker nodes. It will use Traefik (nginx not supported in this case). You can define edge nodes (see above).
Terraform Kubernetes Provider
Usage withYou can use this module to populate Terraform Kubernetes Provider :
provider "kubernetes" {
host = module.rke.rke_cluster.api_server_url
username = module.rke.rke_cluster.kube_admin_user
client_certificate = module.rke.rke_cluster.client_cert
client_key = module.rke.rke_cluster.client_key
cluster_ca_certificate = module.rke.rke_cluster.ca_crt
}
resource "kubernetes_namespace" "ns" {
metadata {
name = "my-namespace"
}
}