Skip to content

Commit

Permalink
add more setup for apps in cd
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljguarino committed Jan 1, 2024
1 parent cce153a commit 9999333
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 0 deletions.
16 changes: 16 additions & 0 deletions templates/providers/apps/aws.tf
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ terraform {
source = "hashicorp/kubernetes"
version = ">= 2.10"
}
plural = {
source = "pluralsh/plural"
version = ">= 0.1.0"
}
}
}

Expand All @@ -35,4 +39,16 @@ provider "kubernetes" {
host = data.aws_eks_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.aws_eks_cluster.cluster.certificate_authority.0.data)
token = data.aws_eks_cluster_auth.cluster.token
}

data "kubernetes_secret" "console-auth" {
metadata {
name = "console-auth-token"
namespace = "plrl-console"
}
}

provider "plural" {
console_url = "{{ .Console }}"
access_token = data.kubernetes_secret.console-auth.data.access-token
}
16 changes: 16 additions & 0 deletions templates/providers/apps/azure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ terraform {
source = "hashicorp/kubernetes"
version = ">= 2.10"
}
plural = {
source = "pluralsh/plural"
version = ">= 0.1.0"
}
}
}

Expand All @@ -41,3 +45,15 @@ provider "kubernetes" {
client_key = base64decode(data.azurerm_kubernetes_cluster.cluster.kube_config[0].client_key)
cluster_ca_certificate = base64decode(data.azurerm_kubernetes_cluster.cluster.kube_config[0].cluster_ca_certificate)
}

data "kubernetes_secret" "console-auth" {
metadata {
name = "console-auth-token"
namespace = "plrl-console"
}
}

provider "plural" {
console_url = "{{ .Console }}"
access_token = data.kubernetes_secret.console-auth.data.access-token
}
16 changes: 16 additions & 0 deletions templates/providers/apps/gcp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ terraform {
source = "hashicorp/kubernetes"
version = ">= 2.10"
}
plural = {
source = "pluralsh/plural"
version = ">= 0.1.0"
}
}
required_version = ">= 0.13"
}
Expand All @@ -27,4 +31,16 @@ provider "kubernetes" {
host = data.google_container_cluster.cluster.endpoint
cluster_ca_certificate = base64decode(data.google_container_cluster.cluster.master_auth.0.cluster_ca_certificate)
token = data.google_client_config.current.access_token
}

data "kubernetes_secret" "console-auth" {
metadata {
name = "console-auth-token"
namespace = "plrl-console"
}
}

provider "plural" {
console_url = "{{ .Console }}"
access_token = data.kubernetes_secret.console-auth.data.access-token
}
52 changes: 52 additions & 0 deletions templates/setup/cd.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
locals {
context = yamldecode(local_sensitive_file.context)
}

data "local_sensitive_file" "context" {
filename = "${path.module}/../context.yaml"
}

data "plural_cluster" "mgmt" {
handle = "mgmt"
}

// create the kubernetes namespace manually here so it can be used elsewhere w/in terraform w/o race conditions
resource "kubernetes_namespace" "infra" {
metadata {
name = "infra"
}
}

resource "plural_git_repository" "infra" {
url = context.configuration.console.repo_url
private_key = context.configuration.console.private_key
decrypt = true
}

resource "plural_service_deployment" "helm-repositories" {
name = "helm-repositories"
namespace = kubernetes_namespace.infra.metadata.name
repository {
id = plural_git_repository.infra.id
ref = "main"
folder = "apps/repositories"
}
cluster {
id = data.plural_cluster.mgmt.id
}
protect = true
}

resource "plural_service_deployment" "apps" {
name = "apps"
namespace = kubernetes_namespace.infra.metadata.name
repository {
id = plural_git_repository.infra.id
ref = "main"
folder = "apps/services"
}
cluster {
id = data.plural_cluster.mgmt.id
}
protect = true
}

0 comments on commit 9999333

Please sign in to comment.