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

[DOP-2361] Fix for allowing disabling thanos #338

Merged
merged 12 commits into from
Nov 1, 2024
Merged
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
54 changes: 27 additions & 27 deletions azure/ipa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -470,33 +470,33 @@ resource "kubernetes_config_map" "azure_dns_credentials" {
}


resource "kubectl_manifest" "thanos-storage-secret" {
count = var.thanos_enabled ? 1 : 0
depends_on = [helm_release.ipa-crds, module.secrets-operator-setup]
yaml_body = <<YAML
apiVersion: "secrets.hashicorp.com/v1beta1"
kind: "VaultStaticSecret"
metadata:
name: vault-thanos-storage
namespace: default
spec:
type: "kv-v2"
namespace: default
mount: customer-Indico-Devops
path: thanos-storage
refreshAfter: 60s
rolloutRestartTargets:
- name: prometheus-monitoring-kube-prometheus-prometheus
kind: StatefulSet
destination:
annotations:
reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
create: true
name: thanos-storage
vaultAuthRef: default
YAML
}
# resource "kubectl_manifest" "thanos-storage-secret" {
# count = var.thanos_enabled ? 1 : 0
# depends_on = [helm_release.ipa-crds, module.secrets-operator-setup]
# yaml_body = <<YAML
# apiVersion: "secrets.hashicorp.com/v1beta1"
# kind: "VaultStaticSecret"
# metadata:
# name: vault-thanos-storage
# namespace: default
# spec:
# type: "kv-v2"
# namespace: default
# mount: customer-Indico-Devops
# path: thanos-storage
# refreshAfter: 60s
# rolloutRestartTargets:
# - name: prometheus-monitoring-kube-prometheus-prometheus
# kind: StatefulSet
# destination:
# annotations:
# reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
# reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
# create: true
# name: thanos-storage
# vaultAuthRef: default
# YAML
# }


resource "kubectl_manifest" "custom-cluster-issuer" {
Expand Down
2 changes: 1 addition & 1 deletion azure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ terraform {
}
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.12.1"
version = ">= 2.33.0"
}
kubectl = {
source = "gavinbunney/kubectl"
Expand Down
136 changes: 71 additions & 65 deletions azure/monitoring.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,25 @@ ingress-nginx:
EOT
) : ""

# thanos_config = var.thanos_enabled == true ? (<<EOT
# thanos: # this is the one being used
# blockSize: 5m
# objectStorageConfig:
# existingSecret:
# name: thanos-storage
# key: thanos_storage.yaml
# EOT
# ) : (<<EOT
# thanos: {}
# EOT
# )
thanos_config = var.thanos_enabled == true ? (<<EOT
thanos: # this is the one being used
blockSize: 5m
objectStorageConfig:
existingSecret:
name: thanos-storage
key: thanos_storage.yaml
thanos: {}
EOT
) : (<<EOT
thanos: {}
EOT
)

# )
alerting_configuration_values = var.alerting_enabled == false ? (<<EOT
noExtraConfigs: true
EOT
Expand Down Expand Up @@ -70,13 +76,13 @@ EOT
reloader.stakater.com/auto: "true"

thanosServiceMonitor:
enabled: ${var.thanos_enabled}
enabled: false #${var.thanos_enabled}

thanosService:
enabled: ${var.thanos_enabled}
enabled: false #${var.thanos_enabled}

prometheusSpec:
disableCompaction: ${var.thanos_enabled}
disableCompaction: false #${var.thanos_enabled}
externalLabels:
clusterAccount: ${var.account}
clusterRegion: ${var.region}
Expand Down Expand Up @@ -129,13 +135,13 @@ ${local.thanos_config}
reloader.stakater.com/auto: "true"

thanosServiceMonitor:
enabled: ${var.thanos_enabled}
enabled: false #${var.thanos_enabled}

thanosService:
enabled: ${var.thanos_enabled}
enabled: false #${var.thanos_enabled}

prometheusSpec:
disableCompaction: ${var.thanos_enabled}
disableCompaction: false #${var.thanos_enabled}
externalLabels:
clusterAccount: ${var.account}
clusterRegion: ${var.region}
Expand Down Expand Up @@ -300,57 +306,57 @@ ${local.private_dns_config}
]
}

resource "kubectl_manifest" "thanos-datasource-credentials" {
count = var.thanos_enabled ? 1 : 0
provider = kubectl.thanos-kubectl
yaml_body = <<YAML
apiVersion: v1
stringData:
admin-password: ${random_password.monitoring-password.result}
kind: Secret
metadata:
name: ${replace(local.dns_name, ".", "-")}
namespace: default
type: Opaque
YAML
}

resource "kubectl_manifest" "thanos-datasource" {
count = var.thanos_enabled ? 1 : 0
depends_on = [kubectl_manifest.thanos-datasource-credentials]
provider = kubectl.thanos-kubectl
yaml_body = <<YAML
apiVersion: grafana.integreatly.org/v1beta1
kind: GrafanaDatasource
metadata:
name: ${replace(local.dns_name, ".", "-")}
namespace: default
spec:
valuesFrom:
- targetPath: "secureJsonData.basicAuthPassword"
valueFrom:
secretKeyRef:
name: ${replace(local.dns_name, ".", "-")}
key: admin-password
datasource:
basicAuth: true
basicAuthUser: monitoring
editable: false
access: proxy
editable: true
jsonData:
timeInterval: 5s
tlsSkipVerify: true
name: ${local.dns_name}
secureJsonData:
basicAuthPassword: $${admin-password}
type: prometheus
url: https://prometheus.${local.dns_name}/prometheus
instanceSelector:
matchLabels:
dashboards: external-grafana
YAML
}
# resource "kubectl_manifest" "thanos-datasource-credentials" {
# count = var.thanos_enabled ? 1 : 0
# provider = kubectl.thanos-kubectl
# yaml_body = <<YAML
# apiVersion: v1
# stringData:
# admin-password: ${random_password.monitoring-password.result}
# kind: Secret
# metadata:
# name: ${replace(local.dns_name, ".", "-")}
# namespace: default
# type: Opaque
# YAML
# }

# resource "kubectl_manifest" "thanos-datasource" {
# count = var.thanos_enabled ? 1 : 0
# depends_on = [kubectl_manifest.thanos-datasource-credentials]
# provider = kubectl.thanos-kubectl
# yaml_body = <<YAML
# apiVersion: grafana.integreatly.org/v1beta1
# kind: GrafanaDatasource
# metadata:
# name: ${replace(local.dns_name, ".", "-")}
# namespace: default
# spec:
# valuesFrom:
# - targetPath: "secureJsonData.basicAuthPassword"
# valueFrom:
# secretKeyRef:
# name: ${replace(local.dns_name, ".", "-")}
# key: admin-password
# datasource:
# basicAuth: true
# basicAuthUser: monitoring
# editable: false
# access: proxy
# editable: true
# jsonData:
# timeInterval: 5s
# tlsSkipVerify: true
# name: ${local.dns_name}
# secureJsonData:
# basicAuthPassword: $${admin-password}
# type: prometheus
# url: https://prometheus.${local.dns_name}/prometheus
# instanceSelector:
# matchLabels:
# dashboards: external-grafana
# YAML
# }


resource "helm_release" "keda-monitoring" {
Expand Down
2 changes: 1 addition & 1 deletion azure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -642,7 +642,7 @@ variable "thanos_cluster_name" {

variable "thanos_enabled" {
type = bool
default = false
default = true
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we just remove this variable altogether?

}

variable "harness_delegate" {
Expand Down
54 changes: 27 additions & 27 deletions ipa.tf
Original file line number Diff line number Diff line change
Expand Up @@ -594,33 +594,33 @@ resource "time_sleep" "wait_1_minutes_after_crds" {
create_duration = "1m"
}

resource "kubectl_manifest" "thanos-storage-secret" {
count = var.thanos_enabled ? 1 : 0
depends_on = [helm_release.ipa-crds, module.secrets-operator-setup]
yaml_body = <<YAML
apiVersion: "secrets.hashicorp.com/v1beta1"
kind: "VaultStaticSecret"
metadata:
name: vault-thanos-storage
namespace: default
spec:
type: "kv-v2"
namespace: default
mount: customer-Indico-Devops
path: thanos-storage
refreshAfter: 60s
rolloutRestartTargets:
- name: prometheus-monitoring-kube-prometheus-prometheus
kind: StatefulSet
destination:
annotations:
reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
create: true
name: thanos-storage
vaultAuthRef: default
YAML
}
# resource "kubectl_manifest" "thanos-storage-secret" {
# count = var.thanos_enabled ? 1 : 0
# depends_on = [helm_release.ipa-crds, module.secrets-operator-setup]
# yaml_body = <<YAML
# apiVersion: "secrets.hashicorp.com/v1beta1"
# kind: "VaultStaticSecret"
# metadata:
# name: vault-thanos-storage
# namespace: default
# spec:
# type: "kv-v2"
# namespace: default
# mount: customer-Indico-Devops
# path: thanos-storage
# refreshAfter: 60s
# rolloutRestartTargets:
# - name: prometheus-monitoring-kube-prometheus-prometheus
# kind: StatefulSet
# destination:
# annotations:
# reflector.v1.k8s.emberstack.com/reflection-allowed: "true"
# reflector.v1.k8s.emberstack.com/reflection-auto-enabled: "true"
# create: true
# name: thanos-storage
# vaultAuthRef: default
# YAML
# }

resource "helm_release" "ipa-pre-requisites" {
depends_on = [
Expand Down
21 changes: 13 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ terraform {
}
kubernetes = {
source = "hashicorp/kubernetes"
version = ">= 2.23.0"
version = ">= 2.33.0"
}
kubectl = {
source = "gavinbunney/kubectl"
Expand Down Expand Up @@ -365,6 +365,16 @@ provider "argocd" {
password = var.argo_password
}

data "aws_eks_cluster" "local" {
depends_on = [ module.cluster.kubernetes_host ]
name = var.label
}

data "aws_eks_cluster_auth" "local" {
depends_on = [ module.cluster.kubernetes_host ]
name = var.label
}

provider "kubernetes" {
host = module.cluster.kubernetes_host
cluster_ca_certificate = module.cluster.kubernetes_cluster_ca_certificate
Expand All @@ -379,13 +389,8 @@ provider "kubernetes" {
provider "kubectl" {
host = module.cluster.kubernetes_host
cluster_ca_certificate = module.cluster.kubernetes_cluster_ca_certificate
#token = module.cluster.kubernetes_token
load_config_file = false
exec {
api_version = "client.authentication.k8s.io/v1beta1"
args = ["eks", "get-token", "--cluster-name", var.label]
command = "aws"
}
token = data.aws_eks_cluster_auth.local.token
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hope this is the permanent fix!

load_config_file = false
}


Expand Down
Loading