package observability import ( "kube-forge/internal/config" "kube-forge/internal/helm_client" "kube-forge/internal/templates" "time" go_helm_client "github.com/mittwald/go-helm-client" ) var HELM_REPOS = []config.RepoSettings{ { Name: "kube-forge", URL: "https://git.kvazaric.ru/api/v4/projects/41/packages/helm/stable", }, } func getFluentOperatorSpec() go_helm_client.ChartSpec { appConfig := config.GetConfig() return go_helm_client.ChartSpec{ ReleaseName: "fluent-operator", ChartName: appConfig.Modules.Observability.Logging.Operator.ChartRef, Version: appConfig.Modules.Observability.Logging.Operator.ChartVersion, Namespace: appConfig.Modules.Observability.Logging.Operator.Namespace, CreateNamespace: true, Atomic: true, UpgradeCRDs: true, Timeout: time.Second * 60, ValuesYaml: templates.GetHelmValuesByTemplate("templates/helm-apps/releases/observability/fluent-operator.yml.tmpl"), } } func getOpenTelemetryOperatorSpec() go_helm_client.ChartSpec { appConfig := config.GetConfig() return go_helm_client.ChartSpec{ ReleaseName: "opentelemetry-operator", ChartName: appConfig.Modules.Observability.Tracing.Operator.ChartRef, Version: appConfig.Modules.Observability.Tracing.Operator.ChartVersion, Namespace: appConfig.Modules.Observability.Tracing.Operator.Namespace, CreateNamespace: true, Atomic: true, UpgradeCRDs: true, Timeout: time.Second * 60, ValuesYaml: templates.GetHelmValuesByTemplate("templates/helm-apps/releases/observability/opentelemetry-operator.yml.tmpl"), } } func getMetricsServerSpec() go_helm_client.ChartSpec { appConfig := config.GetConfig() return go_helm_client.ChartSpec{ ReleaseName: "metrics-server", ChartName: appConfig.Modules.Observability.Monitoring.MetricsServer.ChartRef, Version: appConfig.Modules.Observability.Monitoring.MetricsServer.ChartVersion, Namespace: appConfig.Modules.Observability.Monitoring.MetricsServer.Namespace, CreateNamespace: true, Atomic: true, Timeout: time.Second * 60, ValuesYaml: templates.GetHelmValuesByTemplate("templates/helm-apps/releases/observability/metrics-server.yml.tmpl"), } } func getTempoSpec() go_helm_client.ChartSpec { appConfig := config.GetConfig() return go_helm_client.ChartSpec{ ReleaseName: "tempo", ChartName: appConfig.Modules.Observability.Tracing.Tempo.ChartRef, Version: appConfig.Modules.Observability.Tracing.Tempo.ChartVersion, Namespace: appConfig.Modules.Observability.Tracing.Tempo.Namespace, CreateNamespace: true, Atomic: true, Timeout: time.Second * 60, ValuesYaml: templates.GetHelmValuesByTemplate("templates/helm-apps/releases/observability/tempo.yml.tmpl"), } } func getLokiSpec() go_helm_client.ChartSpec { appConfig := config.GetConfig() return go_helm_client.ChartSpec{ ReleaseName: "loki", ChartName: appConfig.Modules.Observability.Logging.Loki.ChartRef, Version: appConfig.Modules.Observability.Logging.Loki.ChartVersion, Namespace: appConfig.Modules.Observability.Logging.Loki.Namespace, CreateNamespace: true, Atomic: true, Timeout: time.Second * 60, ValuesYaml: templates.GetHelmValuesByTemplate("templates/helm-apps/releases/observability/loki.yml.tmpl"), } } func getObservabilitySpec() go_helm_client.ChartSpec { appConfig := config.GetConfig() return go_helm_client.ChartSpec{ ReleaseName: "observability", ChartName: appConfig.Modules.Observability.ChartRef, Version: appConfig.Modules.Observability.ChartVersion, Namespace: appConfig.Modules.Observability.Namespace, CreateNamespace: true, Atomic: true, Timeout: time.Second * 600, ValuesYaml: templates.GetHelmValuesByTemplate("templates/helm-apps/releases/observability/observability.yml.tmpl"), } } func ApplyCharts() { appConfig := config.GetConfig() helm_client.AddHelmRepos(appConfig.Modules.Registry.Namespace, HELM_REPOS) if appConfig.Modules.Observability.Enabled { if appConfig.Modules.Observability.Logging.Enabled { helm_client.InstallChart(getFluentOperatorSpec()) helm_client.InstallChart(getLokiSpec()) } if appConfig.Modules.Observability.Tracing.Enabled { helm_client.InstallChart(getOpenTelemetryOperatorSpec()) helm_client.InstallChart(getTempoSpec()) } if appConfig.Modules.Observability.Monitoring.Enabled { helm_client.InstallChart(getMetricsServerSpec()) } helm_client.InstallChart(getObservabilitySpec()) } }