From 0d9cf4ee8661a4ef0b67f2d9d29ba8850f9149f5 Mon Sep 17 00:00:00 2001 From: Khue Doan Date: Tue, 20 Apr 2021 17:56:03 +0700 Subject: [PATCH] Revert "Remove legacy bare metal cluster" This reverts commit 06a9936510ebe048adf20ed990b6729157c5ec67. --- infra/legacy/ingress.tf | 62 ++++++++++++++++++ infra/legacy/locals.tf | 3 + infra/legacy/main.tf | 132 +++++++++++++++++++++++++++++++++++++++ infra/legacy/versions.tf | 29 +++++++++ 4 files changed, 226 insertions(+) create mode 100644 infra/legacy/ingress.tf create mode 100644 infra/legacy/locals.tf create mode 100644 infra/legacy/main.tf create mode 100644 infra/legacy/versions.tf diff --git a/infra/legacy/ingress.tf b/infra/legacy/ingress.tf new file mode 100644 index 00000000..7307e91f --- /dev/null +++ b/infra/legacy/ingress.tf @@ -0,0 +1,62 @@ +resource "kubernetes_ingress" "grafana_ingress" { + metadata { + name = "grafana-ingress" + namespace = helm_release.prometheus.namespace + } + + spec { + rule { + host = "grafana.${local.domain}" + http { + path { + backend { + service_name = "kube-prometheus-stack-grafana" + service_port = 80 + } + } + } + } + } +} + +resource "kubernetes_ingress" "longhorn" { + metadata { + name = "longhorn-ingress" + namespace = helm_release.longhorn.namespace + } + + spec { + rule { + host = "longhorn.${local.domain}" + http { + path { + backend { + service_name = "longhorn-frontend" + service_port = 80 + } + } + } + } + } +} + +resource "kubernetes_ingress" "vault_ingress" { + metadata { + name = "vault-ingress" + namespace = helm_release.vault.namespace + } + + spec { + rule { + host = "vault.${local.domain}" + http { + path { + backend { + service_name = "vault" + service_port = 8200 + } + } + } + } + } +} diff --git a/infra/legacy/locals.tf b/infra/legacy/locals.tf new file mode 100644 index 00000000..427aa00f --- /dev/null +++ b/infra/legacy/locals.tf @@ -0,0 +1,3 @@ +locals { + domain = "khuedoan.com" +} diff --git a/infra/legacy/main.tf b/infra/legacy/main.tf new file mode 100644 index 00000000..4dc1bf6b --- /dev/null +++ b/infra/legacy/main.tf @@ -0,0 +1,132 @@ +provider "rke" { + debug = true +} + +provider "kubernetes" { + config_path = "${path.root}/kube_config.yaml" +} + +provider "helm" { + kubernetes { + config_path = "${path.root}/kube_config.yaml" + } +} + +resource rke_cluster "cluster" { + dynamic "nodes" { + for_each = [ + "192.168.1.110", + "192.168.1.111", + "192.168.1.112" + ] + content { + address = nodes.value + user = "root" + role = [ + "controlplane", + "etcd", + "worker" + ] + ssh_key = file("~/.ssh/id_rsa") + } + } + + dynamic "nodes" { + for_each = [ + "192.168.1.113" + ] + content { + address = nodes.value + user = "root" + role = [ + "worker" + ] + ssh_key = file("~/.ssh/id_rsa") + } + } + + ingress { + provider = "none" + } +} + +resource "local_file" "kube_config_yaml" { + filename = "${path.root}/kube_config.yaml" + content = rke_cluster.cluster.kube_config_yaml +} + +resource "helm_release" "metallb" { + name = "metallb" + repository = "https://charts.bitnami.com/bitnami" + chart = "metallb" + version = "1.0.1" + + namespace = "metallb-system" + create_namespace = true + + set { + name = "configInline" + value = <