Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 🚀 External Secrets version 0.9.11 #18

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion _examples/basic/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
name = "helm-addons"
environment = "test"
region = "us-central1"
cluster_version = "latest"
cluster_version = "1.29.0-gke.1381000"
gcp_project_id = "dev-env-3b53"
cluster_name = "test-cluster1"

Check warning on line 7 in _examples/basic/locals.tf

View workflow job for this annotation

GitHub Actions / tf-lint / tflint

local.cluster_name is declared but not used
tags = {

Check warning on line 8 in _examples/basic/locals.tf

View workflow job for this annotation

GitHub Actions / tf-lint / tflint

local.tags is declared but not used
Name = local.name
Environment = local.environment
GithubRepo = "terraform-helm-gke-addons"
Expand Down
28 changes: 14 additions & 14 deletions _examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ module "gke" {
{
name = "general"
machine_type = "g1-small"
node_locations = "${local.region}-a"
node_locations = "${local.region}-c"
min_count = 1
max_count = 5
local_ssd_count = 0
Expand All @@ -117,6 +117,7 @@ module "gke" {
{
name = "critical"
machine_type = "g1-small"
node_locations = "${local.region}-a"
node_locations = "${local.region}-c"
min_count = 1
max_count = 3
Expand Down Expand Up @@ -167,12 +168,8 @@ module "gke" {
}

node_pools_tags = {
all = [
local.tags.Name,
local.tags.Environment,
local.tags.GithubRepo,
local.tags.GithubOrg,
]
all = []

default-node-pool = [
"default-node-pool",
]
Expand All @@ -189,14 +186,17 @@ module "addons" {

depends_on = [module.gke]
gke_cluster_name = module.gke.name
environment = local.environment
project_id = local.gcp_project_id
region = local.region

cluster_autoscaler = true
reloader = true
ingress_nginx = true
certification_manager = true
keda = true
kubeclarity = true
external_dns = true
cluster_autoscaler = true
reloader = true
ingress_nginx = true
certification_manager = true
keda = true
external_secret_enabled = true
kubeclarity = true
external_dns = true

}
21 changes: 21 additions & 0 deletions _examples/complete/config/override-externalsecret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: "cloud.google.com/gke-nodepool"
operator: In
values:
- "critical"

## Using limits and requests
resourc_helm_configes:
limits:
cpu: 100m
memory: 512Mi
requests:
cpu: 10m
memory: 128Mi

podAnnotations:
co.elastic.logs/enabled: "true"
3 changes: 2 additions & 1 deletion _examples/complete/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
name = "helm-addons"
environment = "test"
region = "us-central1"
cluster_version = "latest"
cluster_version = "1.29.0-gke.1381000"
gcp_project_id = "dev-env-3b53"
cluster_name = "test-cluster1"

Check warning on line 7 in _examples/complete/locals.tf

View workflow job for this annotation

GitHub Actions / tf-lint / tflint

local.cluster_name is declared but not used
tags = {
Name = local.name
Environment = local.environment
Expand Down
7 changes: 7 additions & 0 deletions _examples/complete/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -191,30 +191,37 @@ module "addons" {
gke_cluster_name = module.gke.name
project_id = local.gcp_project_id
region = local.region
environment = "test"

cluster_autoscaler = false
reloader = false
ingress_nginx = false
certification_manager = false
keda = false
external_secrets = false
external_dns = false
kubeclarity = false


# -- Path of override-values.yaml file
cluster_autoscaler_helm_config = { values = [file("./config/override-cluster-autoscaler.yaml")] }
reloader_helm_config = { values = [file("./config/reloader/override-reloader.yaml")] }
ingress_nginx_helm_config = { values = [file("./config/override-ingress-nginx.yaml")] }
certification_manager_helm_config = { values = [file("./config/override-certification-manager.yaml")] }
keda_helm_config = { values = [file("./config/keda/override-keda.yaml")] }
external_secrets_helm_config = { values = [file("./config/override-externalsecret.yaml")] }
external_dns_helm_config = { values = [file("./config/override-external-dns.yaml")] }
kubeclarity_helm_config = { values = [file("./config/override-kubeclarity.yaml")] }


# -- Override Helm Release attributes
cluster_autoscaler_extra_configs = var.cluster_autoscaler_extra_configs
reloader_extra_configs = var.reloader_extra_configs
ingress_nginx_extra_configs = var.ingress_nginx_extra_configs
certification_manager_extra_configs = var.certification_manager_extra_configs
keda_extra_configs = var.keda_extra_configs
external_secrets_extra_configs = var.external_secrets_extra_configs
external_dns_extra_configs = var.external_dns_extra_configs
kubeclarity_extra_configs = var.kubeclarity_extra_configs

}
10 changes: 9 additions & 1 deletion _examples/complete/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,14 @@ variable "keda_extra_configs" {
default = {}
}

# ------------------ EXTERNAL DNS --------------------------------------------------
# ------------------ EXTERNAL SECRET ------------------------------------------
variable "external_secrets_extra_configs" {
description = "Override attributes of helm_release terraform resource"
type = any
default = {}
}

# ------------------ EXTERNAL DNS ---------------------------------------------
variable "external_dns_extra_configs" {
type = any
default = {}
Expand All @@ -42,3 +49,4 @@ variable "kubeclarity_extra_configs" {
type = any
default = {}
}

20 changes: 20 additions & 0 deletions addons/external-secrets/config/externalsecret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: external-secrets.io/v1beta1
kind: ExternalSecret
metadata:
name: test
spec:
refreshInterval: 1h # rate SecretManager pulls GCPSM
secretStoreRef:
kind: SecretStore
name: gcp-store # name of the SecretStore (or kind specified)
target:
name: test # name of the k8s Secret to be created
creationPolicy: Owner
data:
dataFrom:
- extract:
key: test
property: cert.key # optional field Label to match exactly
- secretKey: test
remoteRef:
key: test # name of the GCPSM secret key
8 changes: 8 additions & 0 deletions addons/external-secrets/config/secretstore.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: external-secrets.io/v1beta1
kind: SecretStore
metadata:
name: gcp-store
spec:
provider:
gcpsm:
projectID: ""
61 changes: 61 additions & 0 deletions addons/external-secrets/config/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
replicaCount: 1

# -- If set, install and upgrade CRDs through helm chart.
installCRDs: true

resources: {}

podAnnotations:
co.elastic.logs/enabled: "true"

serviceAccount:
annotations:
iam.gke.io/gcp-service-account: ${service_account_email}

serviceMonitor:
enabled: ${enable_service_monitor}
namespace: "secrets"
additionalLabels:
release: "prometheus-operator"

affinity: {}


podDisruptionBudget:
enabled: true
minAvailable: 1


webhook:
create: true
certCheckInterval: "5m"
replicaCount: 1
affinity: {}
resources: {}
podAnnotations:
co.elastic.logs/enabled: "true"
serviceMonitor:
enabled: ${enable_service_monitor}
additionalLabels:
release: "prometheus-operator"
interval: 30s
scrapeTimeout: 25s
serviceAccount:
create: true
annotations:
iam.gke.io/gcp-service-account: ${service_account_email}



certController:
create: true
requeueInterval: "5m"
affinity: {}
resources: {}
podAnnotations:
co.elastic.logs/enabled: "true"
serviceMonitor:
enabled: ${enable_service_monitor}
additionalLabels:
release: "prometheus-operator"
interval: 30s
15 changes: 15 additions & 0 deletions addons/external-secrets/locals.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
locals {
name = "external-secrets"

Check warning on line 2 in addons/external-secrets/locals.tf

View workflow job for this annotation

GitHub Actions / tf-lint / tflint

local.name is declared but not used

default_helm_config = {
repository = try(var.external_secrets_extra_configs.repository, "https://charts.external-secrets.io/")
version = try(var.external_secrets_extra_configs.version, "0.9.11")
namespace = try(var.external_secrets_extra_configs.namespace, "secret")

}

helm_config = merge(

Check warning on line 11 in addons/external-secrets/locals.tf

View workflow job for this annotation

GitHub Actions / tf-lint / tflint

local.helm_config is declared but not used
local.default_helm_config,
var.helm_config,
)
}
46 changes: 46 additions & 0 deletions addons/external-secrets/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
resource "google_service_account" "external_secrets" {
project = var.project_id
account_id = format("%s-%s-%s", var.environment, var.GCP_GSA_NAME, var.name)
display_name = "Service Account for External Secrets"
}

resource "google_project_iam_member" "secretadmin" {
project = var.project_id
role = "roles/secretmanager.admin"
member = "serviceAccount:${google_service_account.external_secrets.email}"
}

resource "google_project_iam_member" "service_account_token_creator" {
project = var.project_id
role = "roles/iam.serviceAccountTokenCreator"
member = "serviceAccount:${google_service_account.external_secrets.email}"
}

resource "google_service_account_iam_member" "pod_identity" {
role = "roles/iam.workloadIdentityUser"
member = "serviceAccount:${var.project_id}.svc.id.goog[secrets/${var.GCP_KSA_NAME}]"
service_account_id = google_service_account.external_secrets.name
}

resource "kubernetes_namespace" "external_secrets" {
metadata {
name = "secrets"
}
}

resource "helm_release" "external_secrets" {

Check warning on line 31 in addons/external-secrets/main.tf

View workflow job for this annotation

GitHub Actions / tf-lint / tflint

Missing version constraint for provider "helm" in "required_providers"
depends_on = [kubernetes_namespace.external_secrets]
name = "external-secrets"
repository = "https://charts.external-secrets.io"
chart = "external-secrets"
namespace = "secrets"
timeout = 300
version = var.external_secrets_version

values = [
templatefile("${path.module}/config/values.yaml", {
enable_service_monitor = var.enable_service_monitor,
service_account_email = "${var.environment}-${var.GCP_GSA_NAME}-${var.name}@${var.project_id}.iam.gserviceaccount.com"
})
]
}
11 changes: 11 additions & 0 deletions addons/external-secrets/output.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
output "namespace" {
value = local.default_helm_config.namespace
}

output "chart_version" {
value = local.default_helm_config.version
}

output "repository" {
value = local.default_helm_config.repository
}
Loading
Loading