Skip to content

Commit

Permalink
Adding bucket creation (#430)
Browse files Browse the repository at this point in the history
  • Loading branch information
pburgisser committed Feb 2, 2021
1 parent a7d19c2 commit 3e72a30
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 7 deletions.
13 changes: 12 additions & 1 deletion argocd/app-of-apps/values.tmpl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,12 @@ kube-prometheus-stack:
- ${prometheus.domain}
- prometheus.apps.${base_domain}
prometheusSpec:
%{ if can(metrics_archives.bucket_config) }
thanos:
objectStorageConfig:
key: thanos.yaml
name: thanos-objectstorage
%{ endif }
portName: proxy
containers:
- args:
Expand Down Expand Up @@ -277,7 +283,9 @@ kube-prometheus-stack:
- name: web
port: 9090
targetPort: 9090

%{ if can(metrics_archives.bucket_config) }
${ indent(4,yamlencode({"thanosObjectStorageConfig": metrics_archives.bucket_config})) }
%{ endif }
loki-stack: {}

metrics-server: {}
Expand Down Expand Up @@ -305,6 +313,9 @@ minio:
- name: ${loki.bucket_name}
policy: none
purge: false
- name: ${metrics_archives.bucket_name}
policy: none
purge: false
%{ endif }

secrets-store-csi-driver: {}
Expand Down
10 changes: 10 additions & 0 deletions argocd/kube-prometheus-stack/templates/thanos-storageconfig.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{{- if index $.Values "kube-prometheus-stack" "thanosObjectStorageConfig" }}
apiVersion: v1
kind: Secret
type: Opaque
metadata:
name: thanos-objectstorage
stringData:
thanos.yaml: |
{{- index .Values "kube-prometheus-stack" "thanosObjectStorageConfig" | toYaml | nindent 4 }}
{{- end }}
2 changes: 2 additions & 0 deletions argocd/kube-prometheus-stack/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
---
kube-prometheus-stack:
thanosObjectStorageConfig:

kubeControllerManager:
enabled: false

Expand Down
7 changes: 7 additions & 0 deletions modules/argocd-helm/local.tf
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,11 @@ locals {
local.minio_defaults,
var.minio,
)
metrics_archives_defaults = {
bucket_name = "thanos"
}
metrics_archives = merge(
local.metrics_archives_defaults,
var.metrics_archives,
)
}
1 change: 1 addition & 0 deletions modules/argocd-helm/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ resource "helm_release" "app_of_apps" {
grafana = local.grafana
prometheus = local.prometheus
alertmanager = local.alertmanager
metrics_archives = local.metrics_archives
}
)],
var.app_of_apps_values_overrides,
Expand Down
9 changes: 8 additions & 1 deletion modules/argocd-helm/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ variable "target_revision" {

variable "extra_apps" {
description = "Extra applications to deploy."
type = list
type = list(any)
default = []
}

Expand Down Expand Up @@ -94,3 +94,10 @@ variable "app_of_apps_values_overrides" {
type = list(string)
default = []
}

variable "metrics_archives" {
description = "Metrics archives settings"
type = any
default = {}
}

24 changes: 19 additions & 5 deletions modules/k3s/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ locals {
kubernetes_password = local.context.users.0.user.password
kubernetes_cluster_ca_certificate = base64decode(local.context.clusters.0.cluster.certificate-authority-data)
kubeconfig = module.cluster.kubeconfig
minio = {
access_key = var.enable_minio ? random_password.minio_accesskey.0.result : ""
secret_key = var.enable_minio ? random_password.minio_secretkey.0.result : ""
}
}

provider "helm" {
Expand Down Expand Up @@ -48,8 +52,8 @@ module "argocd" {
}
minio = {
enable = var.enable_minio
access_key = var.enable_minio ? random_password.minio_accesskey.0.result : ""
secret_key = var.enable_minio ? random_password.minio_secretkey.0.result : ""
access_key = local.minio.access_key
secret_key = local.minio.secret_key
}
keycloak = {
enable = true
Expand All @@ -58,16 +62,27 @@ module "argocd" {
loki = {
bucket_name = "loki"
}
metrics_archives = {
bucket_name = "thanos",
bucket_config = {
"type" = "S3",
"config" = {
"bucket" = "thanos",
"endpoint" = "minio.minio.svc:9000",
"insecure" = true,
"access_key" = local.minio.access_key,
"secret_key" = local.minio.secret_key
}
}
}
olm = {
enable = true
}

grafana = {
generic_oauth_extra_args = {
tls_skip_verify_insecure = true
}
}

app_of_apps_values_overrides = [
templatefile("${path.module}/../values.tmpl.yaml",
{
Expand All @@ -77,7 +92,6 @@ module "argocd" {
),
var.app_of_apps_values_overrides,
]

depends_on = [
module.cluster,
]
Expand Down

0 comments on commit 3e72a30

Please sign in to comment.