From d09a52eb7b2dbec52f8c0c099830e97831b18ca0 Mon Sep 17 00:00:00 2001 From: Khue Doan Date: Wed, 21 Jul 2021 00:19:39 +0700 Subject: [PATCH] Move Cluster API to infra and remove RKE and Terraform --- infra/Makefile | 21 ------ infra/README.md | 9 --- {bootstrap => infra}/bootstrap.sh | 0 infra/bootstrap.tf | 34 --------- infra/cluster.tf | 75 ------------------- {bootstrap => infra}/cluster/homelab.yaml | 0 {bootstrap => infra}/clusterctl.yaml | 0 {bootstrap => infra}/environment.yaml | 0 .../ephemeral-cluster/kind.yaml | 0 .../serverclasses/m5.xlarge.yaml | 0 infra/terraform.tf | 16 ---- infra/values/argocd.yaml | 5 -- 12 files changed, 160 deletions(-) delete mode 100644 infra/Makefile delete mode 100644 infra/README.md rename {bootstrap => infra}/bootstrap.sh (100%) delete mode 100644 infra/bootstrap.tf delete mode 100644 infra/cluster.tf rename {bootstrap => infra}/cluster/homelab.yaml (100%) rename {bootstrap => infra}/clusterctl.yaml (100%) rename {bootstrap => infra}/environment.yaml (100%) rename {bootstrap => infra}/ephemeral-cluster/kind.yaml (100%) rename {bootstrap => infra}/serverclasses/m5.xlarge.yaml (100%) delete mode 100644 infra/terraform.tf delete mode 100644 infra/values/argocd.yaml diff --git a/infra/Makefile b/infra/Makefile deleted file mode 100644 index 55897cc1..00000000 --- a/infra/Makefile +++ /dev/null @@ -1,21 +0,0 @@ -.POSIX: -.EXPORT_ALL_VARIABLES: - -TF_IN_AUTOMATION = true - -default: init apply - -init: - terraform init -input=false -backend-config=backend.tfvars - -plan: - terraform plan -input=false -out=/tmp/tfplan - -apply: plan - terraform apply -input=false /tmp/tfplan - -destroy: - terraform destroy - -lint: - terraform fmt -recursive -diff -check diff --git a/infra/README.md b/infra/README.md deleted file mode 100644 index a9a5d8ff..00000000 --- a/infra/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Private cloud infrastructure - -## Kubernetes cluster `./cluster.tf` - -Using Rancher Kubernetes Engine, with some config specific to CoreOS - -## Bootstrap `./bootstrap.tf` - -Install some essential Helm charts (network, storage,...) diff --git a/bootstrap/bootstrap.sh b/infra/bootstrap.sh similarity index 100% rename from bootstrap/bootstrap.sh rename to infra/bootstrap.sh diff --git a/infra/bootstrap.tf b/infra/bootstrap.tf deleted file mode 100644 index 5e57a93f..00000000 --- a/infra/bootstrap.tf +++ /dev/null @@ -1,34 +0,0 @@ -provider "helm" { - kubernetes { - host = rke_cluster.cluster.api_server_url - client_certificate = rke_cluster.cluster.client_cert - client_key = rke_cluster.cluster.client_key - cluster_ca_certificate = rke_cluster.cluster.ca_crt - } -} - -resource "helm_release" "argocd" { - name = "argocd" - repository = "https://argoproj.github.io/argo-helm" - chart = "argo-cd" - version = "3.6.8" - namespace = "argocd" - create_namespace = true - wait = true - timeout = 600 - - values = [ - file("${path.module}/values/argocd.yaml") - ] -} - -resource "helm_release" "longhorn" { - name = "longhorn" - repository = "https://charts.longhorn.io" - chart = "longhorn" - version = "1.1.1" - namespace = "longhorn" - create_namespace = true - wait = true - timeout = 600 -} diff --git a/infra/cluster.tf b/infra/cluster.tf deleted file mode 100644 index a4b4032c..00000000 --- a/infra/cluster.tf +++ /dev/null @@ -1,75 +0,0 @@ -provider "rke" { - debug = true -} - -locals { - hosts = yamldecode(file("../metal/hosts.yml")) - user = local.hosts.metal.vars.ansible_user - ssh_key_path = local.hosts.metal.vars.ansible_ssh_private_key_file -} - -resource "rke_cluster" "cluster" { - dynamic "nodes" { - for_each = [ - local.hosts.metal.hosts.metal0.ansible_host, - local.hosts.metal.hosts.metal1.ansible_host, - local.hosts.metal.hosts.metal2.ansible_host - ] - - content { - address = nodes.value - user = local.user - role = [ - "controlplane", - "etcd", - "worker" - ] - ssh_key_path = local.ssh_key_path - } - } - - dynamic "nodes" { - for_each = [ - local.hosts.metal.hosts.metal3.ansible_host - ] - - content { - address = nodes.value - user = local.user - role = [ - "worker" - ] - ssh_key_path = local.ssh_key_path - } - } - - ingress { - provider = "none" - } - - # For CoreOS - network { - plugin = "canal" - options = { - canal_flex_volume_plugin_dir = "/opt/kubernetes/kubelet-plugins/volume/exec/nodeagent~uds" - flannel_backend_type = "vxlan" - canal_flannel_backend_port = "8472" - canal_flannel_backend_type = "vxlan" - canal_flannel_backend_vni = "1" - } - } - - services { - kube_controller { - extra_args = { - flex-volume-plugin-dir = "/opt/kubernetes/kubelet-plugins/volume/exec/" - } - } - } -} - -resource "local_file" "kube_config_yaml" { - filename = "${path.root}/kube_config.yaml" - sensitive_content = rke_cluster.cluster.kube_config_yaml - file_permission = "0600" -} diff --git a/bootstrap/cluster/homelab.yaml b/infra/cluster/homelab.yaml similarity index 100% rename from bootstrap/cluster/homelab.yaml rename to infra/cluster/homelab.yaml diff --git a/bootstrap/clusterctl.yaml b/infra/clusterctl.yaml similarity index 100% rename from bootstrap/clusterctl.yaml rename to infra/clusterctl.yaml diff --git a/bootstrap/environment.yaml b/infra/environment.yaml similarity index 100% rename from bootstrap/environment.yaml rename to infra/environment.yaml diff --git a/bootstrap/ephemeral-cluster/kind.yaml b/infra/ephemeral-cluster/kind.yaml similarity index 100% rename from bootstrap/ephemeral-cluster/kind.yaml rename to infra/ephemeral-cluster/kind.yaml diff --git a/bootstrap/serverclasses/m5.xlarge.yaml b/infra/serverclasses/m5.xlarge.yaml similarity index 100% rename from bootstrap/serverclasses/m5.xlarge.yaml rename to infra/serverclasses/m5.xlarge.yaml diff --git a/infra/terraform.tf b/infra/terraform.tf deleted file mode 100644 index 1218d272..00000000 --- a/infra/terraform.tf +++ /dev/null @@ -1,16 +0,0 @@ -terraform { - backend "etcdv3" { - lock = true - } - - required_providers { - rke = { - source = "rancher/rke" - version = "1.2.2" - } - helm = { - source = "hashicorp/helm" - version = "2.2.0" - } - } -} diff --git a/infra/values/argocd.yaml b/infra/values/argocd.yaml deleted file mode 100644 index 0912b013..00000000 --- a/infra/values/argocd.yaml +++ /dev/null @@ -1,5 +0,0 @@ -server: - ingress: - enabled: true - hosts: - - argocd.khuedoan.com