Skip to content

Commit

Permalink
upd(tf): #42 - add makefile + fix namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-delaloy committed May 4, 2022
1 parent 11abdaf commit e8c7832
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 5 deletions.
2 changes: 2 additions & 0 deletions deploy/terraform/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,5 @@ override.tf.json
# Ignore CLI configuration files
.terraformrc
terraform.rc

out.tf
13 changes: 13 additions & 0 deletions deploy/terraform/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'

setup: ## Copy sample files
cp terraform.tfvars.sample terraform.tfvars
terraform init

apply: ## Up the docker-compose without cache or orphans
terraform plan -out out.tfplan
terraform apply "out.tfplan"

.PHONY: help

4 changes: 2 additions & 2 deletions deploy/terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ resource "scaleway_rdb_instance" "rdb_instance" {
}

module "rdb" {
source = "./modules/rdb"
source = "./modules/rdb"

depends_on = [scaleway_rdb_instance.rdb_instance]
for_each = var.environments

Expand Down
8 changes: 6 additions & 2 deletions deploy/terraform/modules/k8s/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
output "cluster_cluster_id" {
output "cluster_id" {
value = scaleway_k8s_cluster.k8s_cluster.id
}

Expand All @@ -16,4 +16,8 @@ output "cluster_ca_certificate" {

output "cluster_pool_id" {
value = scaleway_k8s_pool.k8s_pool.id
}
}

output "cluster_kubeconfig" {
value = scaleway_k8s_cluster.k8s_cluster.kubeconfig[0].config_file
}
7 changes: 6 additions & 1 deletion deploy/terraform/modules/k8s/packages.tf
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
# Ingress controller ------------------------------------------------

resource "kubernetes_namespace" "ingress" {
depends_on = [scaleway_k8s_pool.k8s_pool]
count = var.install_ingress ? 1 : 0
metadata {
name = "ingress"
Expand All @@ -15,14 +18,16 @@ resource "helm_release" "ingress" {
repository = "https://kubernetes.github.io/ingress-nginx"
chart = "ingress-nginx"

// enable to avoid node forwarding
set {
name = "controller.service.externalTrafficPolicy"
value = "Local"
}
}

# Certificate manager -----------------------------------------------

resource "kubernetes_namespace" "cert_manager" {
depends_on = [scaleway_k8s_pool.k8s_pool]
count = var.install_cert_manager ? 1 : 0
metadata {
name = "cert-manager"
Expand Down

0 comments on commit e8c7832

Please sign in to comment.