user3465651
user3465651

Reputation: 764

Installing elastic stack with opentofu

I am trying to setup monitoring in k8. I've setup prometheus and grafana using opentofu and the helm chart. I am trying to use the same mechanism for the elastic stack but I am receiving this error:

│ Error: could not download chart: chart "elastic/eck-stack" not found in https://helm.elastic.co repository
│ 
│   with helm_release.elastic,
│   on observability-services.tf line 64, in resource "helm_release" "elastic":
│   64: resource "helm_release" "elastic" {
│ 

Running helm search repo yields:

NAME                            CHART VERSION   APP VERSION DESCRIPTION                                       
elastic/apm-attacher            1.0.0                       A Helm chart installing the Elastic APM Kuberne...
elastic/apm-server              8.5.1           8.5.1       Official Elastic helm chart for Elastic APM Server
elastic/eck-agent               0.11.0                      Elastic Agent managed by the ECK operator         
elastic/eck-apm-server          0.11.0                      Elastic APM Server managed by the ECK operator    
elastic/eck-beats               0.11.0                      Elastic Beats managed by the ECK operator         
elastic/eck-elasticsearch       0.11.0                      Elasticsearch managed by the ECK operator         
elastic/eck-enterprise-search   0.11.0                      Elastic Enterprise Search managed by the ECK op...
elastic/eck-fleet-server        0.11.0                      Elastic Fleet Server as an Agent managed by the...
elastic/eck-kibana              0.11.0                      Kibana managed by the ECK operator                
elastic/eck-logstash            0.11.0                      Logstash managed by the ECK operator              
elastic/eck-operator            2.13.0          2.13.0      Elastic Cloud on Kubernetes (ECK) operator        
elastic/eck-operator-crds       2.13.0          2.13.0      ECK operator Custom Resource Definitions          
elastic/eck-stack               0.11.0                      Elastic Stack managed by the ECK Operator         
elastic/elasticsearch           8.5.1           8.5.1       Official Elastic helm chart for Elasticsearch     
elastic/filebeat                8.5.1           8.5.1       Official Elastic helm chart for Filebeat          
elastic/kibana                  8.5.1           8.5.1       Official Elastic helm chart for Kibana            
elastic/logstash                8.5.1           8.5.1       Official Elastic helm chart for Logstash          
elastic/metricbeat              8.5.1           8.5.1       Official Elastic helm chart for Metricbeat        
elastic/pf-host-agent           8.14.1          8.14.1      Hyperscaler software efficiency. For everybody.   
elastic/profiling-collector     8.14.1          8.14.1      Universal Profiling. Hyperscaler software effic...
elastic/profiling-symbolizer    8.14.1          8.14.1      Universal Profiling. Hyperscaler software effic...

From the above I am using the correct helm chart name.

My opentofu script looks like:

terraform {
  required_providers {
    grafana = {
      source = "grafana/grafana"
      version = "2.12.2"
    }
    kubernetes = {
      source = "hashicorp/kubernetes"
      version = "2.26.0"
    }
  }
}

variable "k8_cfg_file" {
  type = string
  default = "~/.kube/config"
}

variable "grafana_password" {
  type = string
  default = "toor"
}

variable "grafana_fqdn" {
  type = string
  default = "grafana.myhost.com"
}

provider "kubernetes" {
  config_path = var.k8_cfg_file
}

provider "helm" {
  kubernetes {
    config_path = var.k8_cfg_file
  }
}

resource "kubernetes_namespace" "monitoring" {
  metadata {
    name = "monitoring"
  }
}

resource "helm_release" "prometheus" {
  name        = "kube-prometheus-stack"
  namespace   = kubernetes_namespace.monitoring.metadata.0.name
  repository  = "https://prometheus-community.github.io/helm-charts"
  chart       = "kube-prometheus-stack"

  set {
    name  = "grafana.adminPassword"
    value = var.grafana_password
  }
  set {
    name  = "grafana.ingress.ingressClassName"
    value = "nginx"
  }
  set_list {
    name  = "grafana.ingress.hosts"
    value = [var.grafana_fqdn]
  }
}

resource "helm_release" "nginx" {
  name        = "kube-nginx"
  namespace   = kubernetes_namespace.monitoring.metadata.0.name
  repository  = "https://kubernetes.github.io/ingress-nginx"
  chart       = "ingress-nginx"

  set {
    name  = "controller.admissionWebhooks.enabled"
    value = "false"
  }
}

resource "helm_release" "elastic" {
  name       = "elastic"
  namespace  = kubernetes_namespace.monitoring.metadata.0.name
  repository = "https://helm.elastic.co"
  chart      = "elastic/eck-stack"
  dependency_update =  true

  set {
    name = "installCRDs"
    value = false
  }
  set {
    name = "managedNamespaces"
    value = "{}"
  }
  set {
    name = "createClusterScopedResources"
    value = false
  }
  set {
    name = "webhook.enabled"
    value = false
  }
  set {
    name = "config.validateStorageClass"
    value = false
  }
}

Prometheus does get setup, so I am rather confused why it's unable to find the helm chart.

Any help appreciated

X-Ubuntu: 24.04
Rancher: 1.14.2
k8: 1.30.2
opentofu: 1.7.2

Upvotes: 2

Views: 144

Answers (0)

Related Questions