Skip to content

Commit

Permalink
Attempt deployment of signoz through fluxcd
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanFauble committed Nov 7, 2024
1 parent 5e3e694 commit 8454113
Show file tree
Hide file tree
Showing 5 changed files with 2,711 additions and 0 deletions.
19 changes: 19 additions & 0 deletions deployments/stacks/dpe-k8s-deployments/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,25 @@ module "signoz" {
smtp_from = var.smtp_from
}

module "signoz-flux-deployment" {
depends_on = [module.argo-cd]
# source = "spacelift.io/sagebionetworks/postgres-cloud-native-database/aws"
# version = "0.5.0"
source = "../../../modules/signoz-fluxcd"
auto_deploy = var.auto_deploy
auto_prune = var.auto_prune
git_revision = var.git_revision
namespace = "signoz-fluxcd"
argo_deployment_name = "signoz-fluxcd"
enable_otel_ingress = var.enable_otel_ingress && var.enable_cluster_ingress
gateway_namespace = "envoy-gateway"
cluster_name = var.cluster_name
auth0_jwks_uri = var.auth0_jwks_uri
smtp_password = var.smtp_password
smtp_user = var.smtp_user
smtp_from = var.smtp_from
}

module "envoy-gateway" {
count = var.enable_cluster_ingress ? 1 : 0
depends_on = [module.argo-cd]
Expand Down
171 changes: 171 additions & 0 deletions modules/signoz-fluxcd/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
locals {
alertmanager_enabled = var.smtp_from != "" && var.smtp_user != "" && var.smtp_password != ""
}

resource "kubernetes_namespace" "signoz" {
metadata {
name = var.namespace
}
}

resource "kubectl_manifest" "signoz-helm-repo" {
depends_on = [kubernetes_namespace.signoz]

yaml_body = <<YAML
apiVersion: source.toolkit.fluxcd.io/v1
kind: HelmRepository
metadata:
name: signoz
namespace: ${var.namespace}
spec:
interval: 24h
url: https://charts.signoz.io
YAML
}

resource "kubernetes_config_map" "signoz-values" {
metadata {
name = "signoz-values"
}

data = {
"signoz_values.yaml" = "${file("modules/signoz-fluxcd/templates/values.yaml")}"
}

}

resource "kubectl_manifest" "signoz-helm-release" {
depends_on = [kubernetes_namespace.signoz]

yaml_body = <<YAML
apiVersion: helm.toolkit.fluxcd.io/v2
kind: HelmRelease
metadata:
name: signoz
namespace: ${var.namespace}
spec:
interval: 10m
chart:
spec:
chart: signoz
version: '0.55.1'
sourceRef:
kind: HelmRepository
name: signoz
namespace: ${var.namespace}
interval: 10m
values:
alertmanager:
enabled: false
valuesFrom:
- kind: Secret
name: clickhouse-admin-password
valuesKey: password
targetPath: clickhouse.password
YAML
}

# resource "kubectl_manifest" "signoz-deployment" {
# depends_on = [kubernetes_namespace.signoz]

# yaml_body = <<YAML
# apiVersion: argoproj.io/v1alpha1
# kind: Application
# metadata:
# name: signoz
# namespace: argocd
# spec:
# project: default
# %{if var.auto_deploy}
# syncPolicy:
# automated:
# prune: ${var.auto_prune}
# %{endif}
# sources:
# - repoURL: 'https://charts.signoz.io'
# chart: signoz
# targetRevision: 0.55.1
# helm:
# releaseName: signoz
# # Extra parameters to set (same as setting through values.yaml, but these take precedence)
# parameters:
# - name: "clickhouse.password"
# value: ${random_password.clickhouse-admin-password.result}
# %{if local.alertmanager_enabled}
# - name: "alertmanager.enabled"
# value: "true"
# - name: "alertmanager.additionalEnvs.ALERTMANAGER_SMTP_FROM"
# value: ${var.smtp_from}
# - name: "alertmanager.additionalEnvs.ALERTMANAGER_SMTP_AUTH_USERNAME"
# value: ${var.smtp_user}
# - name: "alertmanager.additionalEnvs.ALERTMANAGER_SMTP_AUTH_PASSWORD"
# value: ${var.smtp_password}
# %{else}
# - name: "alertmanager.enabled"
# value: "false"
# %{endif}
# valueFiles:
# - $values/modules/signoz/templates/values.yaml
# - repoURL: 'https://github.com/Sage-Bionetworks-Workflows/eks-stack.git'
# targetRevision: ${var.git_revision}
# ref: values
# %{if var.enable_otel_ingress}
# - repoURL: 'https://github.com/Sage-Bionetworks-Workflows/eks-stack.git'
# targetRevision: ${var.git_revision}
# path: modules/signoz/resources-otel-ingress
# kustomize:
# patches:
# - target:
# kind: ReferenceGrant
# patch: |-
# - op: replace
# path: /spec/from/0/namespace
# value: ${var.gateway_namespace}
# - target:
# kind: HTTPRoute
# patch: |-
# - op: replace
# path: /metadata/namespace
# value: ${var.gateway_namespace}
# - op: replace
# path: /spec/rules/0/backendRefs/0/namespace
# value: ${var.namespace}
# - target:
# kind: SecurityPolicy
# patch: |-
# - op: replace
# path: /metadata/namespace
# value: ${var.gateway_namespace}
# - op: replace
# path: /spec/jwt/providers
# value:
# - name: auth0
# remoteJWKS:
# uri: ${var.auth0_jwks_uri}
# audiences:
# - ${var.cluster_name}-telemetry
# %{endif}
# destination:
# server: 'https://kubernetes.default.svc'
# namespace: ${var.namespace}
# YAML
# }


resource "random_password" "clickhouse-admin-password" {
length = 32
special = false
}

resource "kubernetes_secret" "clickhouse-admin-password" {
metadata {
name = "clickhouse-admin-password"
namespace = var.namespace
}

data = {
"password" = random_password.clickhouse-admin-password.result
}

depends_on = [kubernetes_namespace.signoz]
}
Loading

0 comments on commit 8454113

Please sign in to comment.