Skip to content

Commit

Permalink
Merge pull request #61 from pluralsh/cloud-up
Browse files Browse the repository at this point in the history
Templating for supporting cloud hosted consoles
  • Loading branch information
michaeljguarino authored Aug 21, 2024
2 parents adefa1f + b864cd3 commit 724c778
Show file tree
Hide file tree
Showing 20 changed files with 176 additions and 96 deletions.
24 changes: 24 additions & 0 deletions apps/services/cert-manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: deployments.plural.sh/v1alpha1
kind: ServiceDeployment
metadata:
name: cert-manager
namespace: infra
spec:
namespace: cert-manager
git:
folder: helm-values
ref: main
repositoryRef:
kind: GitRepository
name: infra
namespace: infra
helm:
version: "v1.x.x"
chart: cert-manager
url: https://charts.jetstack.io
valuesFiles:
- certmanager.yaml
clusterRef:
kind: Cluster
name: mgmt
namespace: infra
4 changes: 1 addition & 3 deletions apps/services/console.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@ spec:
helm:
version: "0.x.x"
chart: console
url: https://pluralsh.github.io/console
valuesFiles:
- console.yaml
repository:
namespace: infra
name: console
clusterRef:
kind: Cluster
name: mgmt
Expand Down
24 changes: 24 additions & 0 deletions apps/services/flux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: deployments.plural.sh/v1alpha1
kind: ServiceDeployment
metadata:
name: flux
namespace: infra
spec:
namespace: flux
git:
folder: helm-values
ref: main
repositoryRef:
kind: GitRepository
name: infra
namespace: infra
helm:
version: "2.12.2"
chart: flux2
url: https://fluxcd-community.github.io/helm-charts
valuesFiles:
- flux.yaml
clusterRef:
kind: Cluster
name: mgmt
namespace: infra
62 changes: 1 addition & 61 deletions apps/services/runtime.yaml
Original file line number Diff line number Diff line change
@@ -1,67 +1,9 @@

apiVersion: deployments.plural.sh/v1alpha1
kind: ServiceDeployment
metadata:
name: cert-manager
namespace: infra
spec:
version: 0.0.1
namespace: cert-manager
git:
folder: helm-values
ref: main
repositoryRef:
kind: GitRepository
name: infra
namespace: infra
helm:
version: "v1.13.3"
chart: cert-manager
valuesFiles:
- certmanager.yaml
repository:
namespace: infra
name: cert-manager
clusterRef:
kind: Cluster
name: mgmt
namespace: infra
---
apiVersion: deployments.plural.sh/v1alpha1
kind: ServiceDeployment
metadata:
name: flux
namespace: infra
spec:
version: 0.0.1
namespace: flux
git:
folder: helm-values
ref: main
repositoryRef:
kind: GitRepository
name: infra
namespace: infra
helm:
version: "2.12.2"
chart: flux2
valuesFiles:
- flux.yaml
repository:
namespace: infra
name: flux
clusterRef:
kind: Cluster
name: mgmt
namespace: infra
---
apiVersion: deployments.plural.sh/v1alpha1
kind: ServiceDeployment
metadata:
name: runtime
namespace: infra
spec:
version: 0.0.1
namespace: plural-runtime
git:
folder: helm-values
Expand All @@ -73,11 +15,9 @@ spec:
helm:
version: "0.x.x"
chart: runtime
url: https://pluralsh.github.io/bootstrap
valuesFiles:
- runtime.yaml
repository:
namespace: infra
name: runtime
clusterRef:
kind: Cluster
name: mgmt
Expand Down
23 changes: 23 additions & 0 deletions charts/runtime/values.yaml.tpl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{ if not .Cloud }}
external-dns:
extraArgs:
plural-cluster: {{ .Cluster }}
Expand All @@ -19,6 +20,28 @@ pluralToken: {{ .Config.Token }}
acmeEAB:
kid: {{ .Acme.KeyId }}
secret: {{ .Acme.HmacKey }}
{{ end }}

{{ if .Cloud }}

ownerEmail: {{ .Config.Email }}


external-dns:
enabled: false

plural-certmanager-webhook:
enabled: false

operator:
enabled: false

application:
enabled: false

plural:
enabled: false
{{ end }}

{{ if eq .Provider "aws" }}
ingress-nginx:
Expand Down
2 changes: 1 addition & 1 deletion templates/providers/apps/aws.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ terraform {
}
plural = {
source = "pluralsh/plural"
version = ">= 0.2.0"
version = ">= 0.2.16"
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion templates/providers/apps/azure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ terraform {
}
plural = {
source = "pluralsh/plural"
version = ">= 0.2.0"
version = ">= 0.2.16"
}
}
}
Expand Down
14 changes: 14 additions & 0 deletions templates/providers/apps/cloud.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_version = ">= 1.0"

required_providers {
plural = {
source = "pluralsh/plural"
version = ">= 0.2.16"
}
}
}

provider "plural" {
use_cli = true
}
2 changes: 1 addition & 1 deletion templates/providers/apps/gcp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ terraform {
}
plural = {
source = "pluralsh/plural"
version = ">= 0.2.0"
version = ">= 0.2.16"
}
}
required_version = ">= 0.13"
Expand Down
8 changes: 8 additions & 0 deletions templates/providers/bootstrap/aws.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ terraform {
source = "hashicorp/local"
version = "2.5.1"
}
plural = {
source = "pluralsh/plural"
version = ">= 0.2.16"
}
}
}

Expand Down Expand Up @@ -59,4 +63,8 @@ provider "helm" {
cluster_ca_certificate = base64decode(module.mgmt.cluster.cluster_certificate_authority_data)
token = data.aws_eks_cluster_auth.cluster.token
}
}

provider "plural" {
use_cli = true # If you want to have a Plural stack manage your console, comment this out and use the `actor` field
}
8 changes: 8 additions & 0 deletions templates/providers/bootstrap/azure.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ terraform {
source = "hashicorp/local"
version = "2.5.1"
}
plural = {
source = "pluralsh/plural"
version = ">= 0.2.16"
}
}
}

Expand Down Expand Up @@ -62,4 +66,8 @@ provider "helm" {
client_certificate = base64decode(module.mgmt.cluster.client_certificate)
client_key = base64decode(module.mgmt.cluster.client_key)
}
}

provider "plural" {
use_cli = true # If you want to have a Plural stack manage your console, comment this out and use the `actor` field
}
8 changes: 8 additions & 0 deletions templates/providers/bootstrap/gcp.tf
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ terraform {
source = "hashicorp/local"
version = "2.5.1"
}
plural = {
source = "pluralsh/plural"
version = ">= 0.2.16"
}
}
required_version = ">= 0.13"
}
Expand All @@ -36,4 +40,8 @@ provider "helm" {
cluster_ca_certificate = base64decode(module.mgmt.cluster.ca_certificate)
token = data.google_client_config.default.access_token
}
}

provider "plural" {
use_cli = true # If you want to have a Plural stack manage your console, comment this out and use the `actor` field
}
8 changes: 8 additions & 0 deletions templates/providers/bootstrap/linode.tf
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ terraform {
source = "hashicorp/local"
version = "2.5.1"
}
plural = {
source = "pluralsh/plural"
version = ">= 0.2.0"
}
}
}

Expand All @@ -45,4 +49,8 @@ provider "helm" {
cluster_ca_certificate = base64decode(module.parsed.cluster.certificate-authority-data)
token = module.parsed.user.token
}
}

provider "plural" {
use_cli = true # If you want to have a Plural stack manage your console, comment this out and use the `actor` field
}
31 changes: 2 additions & 29 deletions templates/setup/cd.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,15 @@ 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 = local.context.spec.configuration.console.repo_url
private_key = local.context.spec.configuration.console.private_key
decrypt = true
}

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

depends_on = [ kubernetes_namespace.infra ]
}

resource "plural_service_deployment" "apps" {
name = "apps"
namespace = kubernetes_namespace.infra.metadata[0].name
namespace = "infra"
repository = {
id = plural_git_repository.infra.id
ref = "main"
Expand All @@ -50,11 +27,7 @@ resource "plural_service_deployment" "apps" {
cluster = {
id = data.plural_cluster.mgmt.id
}
configuration = {
repoUrl = local.context.spec.configuration.console.repo_url
}

protect = true
templated = true

depends_on = [ kubernetes_namespace.infra ]
}
16 changes: 16 additions & 0 deletions templates/setup/mgmt/aws.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
resource "plural_cluster" "mgmt" {
handle = "mgmt"
name = "[[ .CloudCluster ]]"

kubeconfig = {
host = module.mgmt.cluster_endpoint
cluster_ca_certificate = base64decode(module.mgmt.cluster_certificate_authority_data)
token = data.aws_eks_cluster_auth.cluster.token
}

depends_on = [ module.mgmt ]
}

output "identity" {
value = module.mgmt.identity
}
17 changes: 17 additions & 0 deletions templates/setup/mgmt/azure.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "plural_cluster" "mgmt" {
handle = "mgmt"
name = "[[ .CloudCluster ]]"

kubeconfig = {
host = module.mgmt.cluster.cluster_fqdn
cluster_ca_certificate = base64decode(module.mgmt.cluster.cluster_ca_certificate)
client_certificate = base64decode(module.mgmt.cluster.client_certificate)
client_key = base64decode(module.mgmt.cluster.client_key)
}

depends_on = [ module.mgmt ]
}

output "identity" {
value = module.mgmt.identity
}
Loading

0 comments on commit 724c778

Please sign in to comment.