Points to note about Terraform helm provider

The Metrics-Server helm chart as Terraform HCL

 1resource "helm_release" "metrics-server" {
 2    name       = "metrics-server"
 3    repository = "https://charts.bitnami.com/bitnami"
 4    chart      = "metrics-server"
 5    version    = "4.1.4"
 6    namespace  = "kube-system"
 7
 8    set {
 9      name = "extraArgs.kubelet-preferred-address-types"
10      value = "InternalIP\\,ExternalIP\\,Hostname"
11    }
12
13    set {
14      name = "resources.requests.memory"
15      value = "500Mi"
16    }
17
18    set {
19      name = "resources.limits.memory"
20      value = "1Gi"
21    }
22
23    set {
24      name = "apiService.create"
25      value = "true"
26    }
27
28}
  • The apiService.create always assign to true when in AWS EKS or other kubernetes distribution
  • The values include comma , muste be use escape in terraform
  • Any resources should be specific quota, like resource requests and limits

When Name includes dot annotations also escaped

1# set {
2#   type  = "string"
3#   name  = "ingress.web.annotations.alb\\.ingress\\.kubernetes\\.io/security-groups"
4#   value = "${var.office_sg_id}\\,${var.internal_sg_id}\\,${var.cluster_sg_id}"
5# }

terraform helm release use local charts

 1resource "helm_release" "fluentd_server" {
 2  name = "fluentd-server"
 3  # repository = "https://charts.bitnami.com/bitnami"
 4  chart     = "${path.module}/../../../../../charts/fluentd"
 5  version   = "3.1.0"
 6  namespace = "kube-system"
 7
 8  values = [
 9    <<-EOF
10    forwarder:
11      configMap: "fluentd-forwarder-config"
12      rbac:
13        pspEnabled: true
14      resources:
15        limits:
16          memory: 1Gi
17        requests:
18          memory: 512Mi
19    aggregator:
20      replicaCount: 1
21      configMap: "fluentd-elasticsearch-config"
22      resources:
23        limits:
24          memory: 1Gi
25        requests:
26          memory: 512Mi
27      extraEnv:
28        - name: ELASTICSEARCH_HOST
29          value: "${var.es_url}"
30        - name: ELASTICSEARCH_PORT
31          value: "80"
32        - name: ELASTICSEARCH_SCHEME
33          value: "http"        
34      persistence:
35        enabled: true
36        storageClass: gp2
37    EOF
38  ]
39
40  depends_on = [
41    kubernetes_config_map.fluentd_elasticsearch_output,
42    kubernetes_config_map.fluentd_forwarder_config
43  ]
44
45}