From c2ddf906c815928490fbbf269a64a1a32db4ee5c Mon Sep 17 00:00:00 2001 From: Khue Doan Date: Wed, 4 Nov 2020 22:46:38 +0700 Subject: [PATCH] Use RKE on bare metal instead of VM --- platform/main.tf | 42 +++++++++++++++++++++++++++++++++++++----- platform/providers.tf | 3 --- platform/versions.tf | 5 +++-- 3 files changed, 40 insertions(+), 10 deletions(-) delete mode 100644 platform/providers.tf diff --git a/platform/main.tf b/platform/main.tf index 3fc82ab8..4f7548f9 100644 --- a/platform/main.tf +++ b/platform/main.tf @@ -1,6 +1,38 @@ -resource "openstack_images_image_v2" "centos8" { - name = "CentOS_8" - image_source_url = "https://cloud.centos.org/centos/8/x86_64/images/CentOS-8-GenericCloud-8.2.2004-20200611.2.x86_64.qcow2" - container_format = "bare" - disk_format = "qcow2" +provider "rke" { + debug = true + } + +resource rke_cluster "cluster" { + nodes { + address = "192.168.1.21" + user = "root" + role = [ + "controlplane", + "etcd", + "worker" + ] + ssh_key = file("~/.ssh/id_rsa") + } + + dynamic "nodes" { + for_each = [ + "192.168.1.17", + "192.168.1.22", + "192.168.1.23" + ] + content { + address = nodes.value + user = "root" + role = [ + "worker", + "etcd" + ] + ssh_key = file("~/.ssh/id_rsa") + } + } +} + +resource "local_file" "kube_cluster_yaml" { + filename = "${path.root}/kube_config_cluster.yml" + content = rke_cluster.cluster.kube_config_yaml } diff --git a/platform/providers.tf b/platform/providers.tf deleted file mode 100644 index 4552a7bb..00000000 --- a/platform/providers.tf +++ /dev/null @@ -1,3 +0,0 @@ -provider "openstack" { - # source admin-openrc.sh -} diff --git a/platform/versions.tf b/platform/versions.tf index 76116996..3568e7b8 100644 --- a/platform/versions.tf +++ b/platform/versions.tf @@ -1,7 +1,8 @@ terraform { required_providers { - openstack = { - source = "terraform-provider-openstack/openstack" + rke = { + source = "rancher/rke" + version = "1.1.3" } } required_version = ">= 0.13"