From 5ab6bd71899f2b0600541818c7559dfbf3213a32 Mon Sep 17 00:00:00 2001 From: maxim Date: Mon, 26 Apr 2021 23:11:26 +0600 Subject: [PATCH 1/2] Set helm releases history size. Helm keeps releases history as k8s secrets. If we don't set max_history it will be unlimited. There is an opened issue related to that https://github.com/helm/helm/issues/7997. If count of secrets is huge then helm list/istall can be failed due to: ``` request.go:924] Unexpected error when reading response body: net/http: request canceled (Client.Timeout exceeded while reading body) Error: unable to build kubernetes objects from release manifest: unexpected error when reading response body. Please retry. Original error: net/http: request canceled (Client.Timeout exceeded while reading body ``` --- .../eks-aws-node-termination-handler.tf | 13 +++++----- terraform/layer2-k8s/eks-cert-manager.tf | 13 +++++----- terraform/layer2-k8s/eks-certificate.tf | 9 +++---- .../layer2-k8s/eks-cluster-autoscaler.tf | 11 +++++---- terraform/layer2-k8s/eks-cluster-issuer.tf | 9 +++---- terraform/layer2-k8s/eks-external-dns.tf | 11 +++++---- terraform/layer2-k8s/eks-external-secrets.tf | 24 ++++++++++--------- .../layer2-k8s/eks-kube-prometheus-stack.tf | 18 ++++++-------- terraform/layer2-k8s/eks-loki-stack.tf | 13 +++++----- .../eks-nginx-ingress-controller.tf | 13 +++++----- .../examples/eks-alb-ingress-controller.tf | 13 +++++----- .../layer2-k8s/examples/eks-apm-server.tf | 15 ++++++------ .../layer2-k8s/examples/eks-elasticsearch.tf | 15 ++++++------ terraform/layer2-k8s/examples/eks-elk.tf | 11 +++++---- terraform/layer2-k8s/examples/eks-filebeat.tf | 15 ++++++------ .../layer2-k8s/examples/eks-gitlab-runner.tf | 13 +++++----- terraform/layer2-k8s/examples/eks-istio.tf | 23 ++++++++++-------- terraform/layer2-k8s/examples/eks-kibana.tf | 15 ++++++------ .../layer2-k8s/examples/eks-metricbeat.tf | 15 ++++++------ .../examples/eks-mysql-backup-wp.tf | 15 ++++++------ .../layer2-k8s/examples/eks-oauth2-proxy.tf | 15 ++++++------ .../examples/eks-postgresql-backups.tf | 9 +++---- .../examples/eks-prometheus-mysql-exporter.tf | 15 ++++++------ .../eks-prometheus-postgresql-exporter.tf | 22 +++++++++-------- terraform/layer2-k8s/examples/eks-teamcity.tf | 4 +++- 25 files changed, 187 insertions(+), 162 deletions(-) diff --git a/terraform/layer2-k8s/eks-aws-node-termination-handler.tf b/terraform/layer2-k8s/eks-aws-node-termination-handler.tf index 48378526..b6fc0bd8 100644 --- a/terraform/layer2-k8s/eks-aws-node-termination-handler.tf +++ b/terraform/layer2-k8s/eks-aws-node-termination-handler.tf @@ -1,10 +1,11 @@ resource "helm_release" "aws_node_termination_handler" { - name = "aws-node-termination-handler" - chart = "aws-node-termination-handler" - version = var.aws_node_termination_handler_version - repository = local.helm_repo_eks - namespace = kubernetes_namespace.sys.id - wait = false + name = "aws-node-termination-handler" + chart = "aws-node-termination-handler" + version = var.aws_node_termination_handler_version + repository = local.helm_repo_eks + namespace = kubernetes_namespace.sys.id + wait = false + max_history = "3" values = [ file("${path.module}/templates/aws-node-termination-handler-values.yaml") diff --git a/terraform/layer2-k8s/eks-cert-manager.tf b/terraform/layer2-k8s/eks-cert-manager.tf index cb5f7bc2..8ad7aea3 100644 --- a/terraform/layer2-k8s/eks-cert-manager.tf +++ b/terraform/layer2-k8s/eks-cert-manager.tf @@ -15,12 +15,13 @@ data "template_file" "cert_manager" { } resource "helm_release" "cert_manager" { - name = "cert-manager" - chart = "cert-manager" - repository = local.helm_repo_certmanager - namespace = kubernetes_namespace.certmanager.id - version = var.cert_manager_version - wait = true + name = "cert-manager" + chart = "cert-manager" + repository = local.helm_repo_certmanager + namespace = kubernetes_namespace.certmanager.id + version = var.cert_manager_version + wait = true + max_history = "3" values = [ data.template_file.cert_manager.rendered, diff --git a/terraform/layer2-k8s/eks-certificate.tf b/terraform/layer2-k8s/eks-certificate.tf index a6ccb630..0bf5b5cb 100644 --- a/terraform/layer2-k8s/eks-certificate.tf +++ b/terraform/layer2-k8s/eks-certificate.tf @@ -8,10 +8,11 @@ data "template_file" "certificate" { } resource "helm_release" "certificate" { - name = "certificate" - chart = "../../helm-charts/certificate" - namespace = module.ing_namespace.name - wait = false + name = "certificate" + chart = "../../helm-charts/certificate" + namespace = module.ing_namespace.name + wait = false + max_history = "3" values = [ data.template_file.certificate.rendered, diff --git a/terraform/layer2-k8s/eks-cluster-autoscaler.tf b/terraform/layer2-k8s/eks-cluster-autoscaler.tf index c234b7c3..8f5e9be6 100644 --- a/terraform/layer2-k8s/eks-cluster-autoscaler.tf +++ b/terraform/layer2-k8s/eks-cluster-autoscaler.tf @@ -19,11 +19,12 @@ data "template_file" "cluster_autoscaler" { } resource "helm_release" "cluster_autoscaler" { - name = "cluster-autoscaler" - chart = "cluster-autoscaler" - repository = local.helm_repo_cluster_autoscaler - version = var.cluster_autoscaler_chart_version - namespace = kubernetes_namespace.sys.id + name = "cluster-autoscaler" + chart = "cluster-autoscaler" + repository = local.helm_repo_cluster_autoscaler + version = var.cluster_autoscaler_chart_version + namespace = kubernetes_namespace.sys.id + max_history = "3" values = [ data.template_file.cluster_autoscaler.rendered, diff --git a/terraform/layer2-k8s/eks-cluster-issuer.tf b/terraform/layer2-k8s/eks-cluster-issuer.tf index d5ed178c..c78c6611 100644 --- a/terraform/layer2-k8s/eks-cluster-issuer.tf +++ b/terraform/layer2-k8s/eks-cluster-issuer.tf @@ -9,10 +9,11 @@ data "template_file" "cluster_issuer" { } resource "helm_release" "cluster_issuer" { - name = "cluster-issuer" - chart = "../../helm-charts/cluster-issuer" - namespace = kubernetes_namespace.certmanager.id - wait = false + name = "cluster-issuer" + chart = "../../helm-charts/cluster-issuer" + namespace = kubernetes_namespace.certmanager.id + wait = false + max_history = "3" values = [ data.template_file.cluster_issuer.rendered, diff --git a/terraform/layer2-k8s/eks-external-dns.tf b/terraform/layer2-k8s/eks-external-dns.tf index cf3411b9..bf9121c8 100644 --- a/terraform/layer2-k8s/eks-external-dns.tf +++ b/terraform/layer2-k8s/eks-external-dns.tf @@ -19,11 +19,12 @@ data "template_file" "external_dns" { resource "helm_release" "external_dns" { - name = "external-dns" - chart = "external-dns" - repository = local.helm_repo_bitnami - version = var.external_dns_version - namespace = kubernetes_namespace.dns.id + name = "external-dns" + chart = "external-dns" + repository = local.helm_repo_bitnami + version = var.external_dns_version + namespace = kubernetes_namespace.dns.id + max_history = "3" values = [ data.template_file.external_dns.rendered, diff --git a/terraform/layer2-k8s/eks-external-secrets.tf b/terraform/layer2-k8s/eks-external-secrets.tf index 6f321c73..39503e90 100644 --- a/terraform/layer2-k8s/eks-external-secrets.tf +++ b/terraform/layer2-k8s/eks-external-secrets.tf @@ -16,11 +16,12 @@ data "template_file" "external_secrets" { } resource "helm_release" "external_secrets" { - name = "external-secrets" - chart = "kubernetes-external-secrets" - repository = local.helm_repo_external_secrets - version = var.external_secrets_version - namespace = kubernetes_namespace.sys.id + name = "external-secrets" + chart = "kubernetes-external-secrets" + repository = local.helm_repo_external_secrets + version = var.external_secrets_version + namespace = kubernetes_namespace.sys.id + max_history = "3" values = [ data.template_file.external_secrets.rendered, @@ -28,12 +29,13 @@ resource "helm_release" "external_secrets" { } resource "helm_release" "reloader" { - name = "reloader" - chart = "reloader" - repository = local.helm_repo_stakater - version = var.reloader_version - namespace = kubernetes_namespace.sys.id - wait = false + name = "reloader" + chart = "reloader" + repository = local.helm_repo_stakater + version = var.reloader_version + namespace = kubernetes_namespace.sys.id + wait = false + max_history = "3" } #module "aws_iam_wp_external_secrets" { diff --git a/terraform/layer2-k8s/eks-kube-prometheus-stack.tf b/terraform/layer2-k8s/eks-kube-prometheus-stack.tf index 709802f1..a5149487 100644 --- a/terraform/layer2-k8s/eks-kube-prometheus-stack.tf +++ b/terraform/layer2-k8s/eks-kube-prometheus-stack.tf @@ -35,17 +35,13 @@ module "aws_iam_grafana" { } resource "helm_release" "prometheus_operator" { - name = "kube-prometheus-stack" - chart = "kube-prometheus-stack" - repository = local.helm_repo_prometheus_community - namespace = kubernetes_namespace.monitoring.id - version = var.prometheus_operator_version - wait = false - - set { - name = "rbac.create" - value = "true" - } + name = "kube-prometheus-stack" + chart = "kube-prometheus-stack" + repository = local.helm_repo_prometheus_community + namespace = kubernetes_namespace.monitoring.id + version = var.prometheus_operator_version + wait = false + max_history = "3" values = [ local.kube_prometheus_stack_template diff --git a/terraform/layer2-k8s/eks-loki-stack.tf b/terraform/layer2-k8s/eks-loki-stack.tf index 89a1f025..6a21eecd 100644 --- a/terraform/layer2-k8s/eks-loki-stack.tf +++ b/terraform/layer2-k8s/eks-loki-stack.tf @@ -12,12 +12,13 @@ locals { } resource "helm_release" "loki_stack" { - name = "loki-stack" - chart = "loki-stack" - repository = local.helm_repo_grafana - namespace = kubernetes_namespace.monitoring.id - version = var.loki_stack - wait = false + name = "loki-stack" + chart = "loki-stack" + repository = local.helm_repo_grafana + namespace = kubernetes_namespace.monitoring.id + version = var.loki_stack + wait = false + max_history = "3" values = [ local.loki_stack_template diff --git a/terraform/layer2-k8s/eks-nginx-ingress-controller.tf b/terraform/layer2-k8s/eks-nginx-ingress-controller.tf index 1127c973..ad78abef 100644 --- a/terraform/layer2-k8s/eks-nginx-ingress-controller.tf +++ b/terraform/layer2-k8s/eks-nginx-ingress-controller.tf @@ -19,12 +19,13 @@ data "template_file" "nginx_ingress" { } resource "helm_release" "nginx_ingress" { - name = "ingress-nginx" - chart = "ingress-nginx" - repository = local.helm_repo_ingress_nginx - namespace = module.ing_namespace.name - version = var.nginx_ingress_controller_version - wait = false + name = "ingress-nginx" + chart = "ingress-nginx" + repository = local.helm_repo_ingress_nginx + namespace = module.ing_namespace.name + version = var.nginx_ingress_controller_version + wait = false + max_history = "3" values = [ data.template_file.nginx_ingress.rendered, diff --git a/terraform/layer2-k8s/examples/eks-alb-ingress-controller.tf b/terraform/layer2-k8s/examples/eks-alb-ingress-controller.tf index 2c43dfe6..9f14df6f 100644 --- a/terraform/layer2-k8s/examples/eks-alb-ingress-controller.tf +++ b/terraform/layer2-k8s/examples/eks-alb-ingress-controller.tf @@ -19,13 +19,14 @@ data "template_file" "alb_ingress_controller" { } resource "helm_release" "alb_ingress_controller" { - name = "aws-alb-ingress-controller" - chart = "aws-alb-ingress-controller" - repository = local.helm_repo_incubator - version = var.alb_ingress_chart_version - namespace = kubernetes_namespace.ing.id + name = "aws-alb-ingress-controller" + chart = "aws-alb-ingress-controller" + repository = local.helm_repo_incubator + version = var.alb_ingress_chart_version + namespace = kubernetes_namespace.ing.id + max_history = "3" values = [ - "${data.template_file.alb_ingress_controller.rendered}", + data.template_file.alb_ingress_controller.rendered ] } diff --git a/terraform/layer2-k8s/examples/eks-apm-server.tf b/terraform/layer2-k8s/examples/eks-apm-server.tf index e92f494f..f8355801 100644 --- a/terraform/layer2-k8s/examples/eks-apm-server.tf +++ b/terraform/layer2-k8s/examples/eks-apm-server.tf @@ -7,15 +7,16 @@ data "template_file" "apm-server" { } resource "helm_release" "apm-server" { - name = "apm-server" - chart = "apm-server" - repository = local.helm_repo_elastic - version = var.elk_version - namespace = kubernetes_namespace.elk.id - wait = false + name = "apm-server" + chart = "apm-server" + repository = local.helm_repo_elastic + version = var.elk_version + namespace = kubernetes_namespace.elk.id + wait = false + max_history = "3" values = [ - "${data.template_file.apm.rendered}", + data.template_file.apm.rendered, ] # This dep needs for correct apply diff --git a/terraform/layer2-k8s/examples/eks-elasticsearch.tf b/terraform/layer2-k8s/examples/eks-elasticsearch.tf index 2c99a7c0..06eb5ae2 100644 --- a/terraform/layer2-k8s/examples/eks-elasticsearch.tf +++ b/terraform/layer2-k8s/examples/eks-elasticsearch.tf @@ -8,15 +8,16 @@ data "template_file" "elasticsearch" { } resource "helm_release" "elasticsearch" { - name = "elasticsearch" - chart = "elasticsearch" - repository = local.helm_repo_elastic - version = var.elk_version - namespace = kubernetes_namespace.elk.id - wait = false + name = "elasticsearch" + chart = "elasticsearch" + repository = local.helm_repo_elastic + version = var.elk_version + namespace = kubernetes_namespace.elk.id + wait = false + max_history = "3" values = [ - "${data.template_file.elasticsearch.rendered}", + data.template_file.elasticsearch.rendered ] # This dep needs for correct apply diff --git a/terraform/layer2-k8s/examples/eks-elk.tf b/terraform/layer2-k8s/examples/eks-elk.tf index f3c73516..e88217af 100644 --- a/terraform/layer2-k8s/examples/eks-elk.tf +++ b/terraform/layer2-k8s/examples/eks-elk.tf @@ -21,13 +21,14 @@ data "template_file" "elk" { } resource "helm_release" "elk" { - name = "elk" - chart = "../../helm-charts/elk" - namespace = kubernetes_namespace.elk.id - wait = false + name = "elk" + chart = "../../helm-charts/elk" + namespace = kubernetes_namespace.elk.id + wait = false + max_history = "3" values = [ - "${data.template_file.elk.rendered}", + data.template_file.elk.rendered ] } diff --git a/terraform/layer2-k8s/examples/eks-filebeat.tf b/terraform/layer2-k8s/examples/eks-filebeat.tf index 2f65eb24..c41da2ad 100644 --- a/terraform/layer2-k8s/examples/eks-filebeat.tf +++ b/terraform/layer2-k8s/examples/eks-filebeat.tf @@ -3,15 +3,16 @@ data "template_file" "filebeat" { } resource "helm_release" "filebeat" { - name = "filebeat" - chart = "filebeat" - repository = local.helm_repo_elastic - version = var.elk_version - namespace = kubernetes_namespace.elk.id - wait = false + name = "filebeat" + chart = "filebeat" + repository = local.helm_repo_elastic + version = var.elk_version + namespace = kubernetes_namespace.elk.id + wait = false + max_history = "3" values = [ - "${data.template_file.filebeat.rendered}", + data.template_file.filebeat.rendered ] # This dep needs for correct apply diff --git a/terraform/layer2-k8s/examples/eks-gitlab-runner.tf b/terraform/layer2-k8s/examples/eks-gitlab-runner.tf index ffb41235..680375de 100644 --- a/terraform/layer2-k8s/examples/eks-gitlab-runner.tf +++ b/terraform/layer2-k8s/examples/eks-gitlab-runner.tf @@ -32,12 +32,13 @@ module "eks_rbac_gitlab_runner" { } resource "helm_release" "gitlab_runner" { - name = "gitlab-runner" - chart = "gitlab-runner" - repository = local.helm_repo_gitlab - version = var.gitlab_runner_version - namespace = kubernetes_namespace.ci.id - wait = false + name = "gitlab-runner" + chart = "gitlab-runner" + repository = local.helm_repo_gitlab + version = var.gitlab_runner_version + namespace = kubernetes_namespace.ci.id + wait = false + max_history = "3" values = [ local.gitlab_runner_template diff --git a/terraform/layer2-k8s/examples/eks-istio.tf b/terraform/layer2-k8s/examples/eks-istio.tf index efc94fa3..0e3a62b5 100644 --- a/terraform/layer2-k8s/examples/eks-istio.tf +++ b/terraform/layer2-k8s/examples/eks-istio.tf @@ -13,8 +13,9 @@ resource "helm_release" "istio_operator_resources" { name = "istio-operator-resources" chart = "../../helm-charts/istio/istio-operator-resources" - namespace = module.istio_system_namespace.name - wait = true + namespace = module.istio_system_namespace.name + wait = true + max_history = "3" values = [ file("${path.module}/templates/istio/istio-resources-values.yaml") @@ -33,8 +34,9 @@ resource "helm_release" "istio_resources" { name = "istio-resources" chart = "../../helm-charts/istio/istio-resources" - namespace = module.istio_system_namespace.name - wait = false + namespace = module.istio_system_namespace.name + wait = false + max_history = "3" values = [ file("${path.module}/templates/istio/istio-resources-values.yaml") @@ -44,12 +46,13 @@ resource "helm_release" "istio_resources" { } resource "helm_release" "kiali" { - name = "kiali-server" - chart = "kiali-server" - repository = local.helm_repo_kiali - namespace = module.kiali_namespace.name - version = var.kiali_version - wait = false + name = "kiali-server" + chart = "kiali-server" + repository = local.helm_repo_kiali + namespace = module.kiali_namespace.name + version = var.kiali_version + wait = false + max_history = "3" values = [ file("${path.module}/templates/istio/istio-kiali-values.yaml") diff --git a/terraform/layer2-k8s/examples/eks-kibana.tf b/terraform/layer2-k8s/examples/eks-kibana.tf index a7d787dd..6068b353 100644 --- a/terraform/layer2-k8s/examples/eks-kibana.tf +++ b/terraform/layer2-k8s/examples/eks-kibana.tf @@ -36,15 +36,16 @@ data "template_file" "kibana" { } resource "helm_release" "kibana" { - name = "kibana" - chart = "kibana" - repository = local.helm_repo_elastic - version = var.elk_version - namespace = kubernetes_namespace.elk.id - wait = false + name = "kibana" + chart = "kibana" + repository = local.helm_repo_elastic + version = var.elk_version + namespace = kubernetes_namespace.elk.id + wait = false + max_history = "3" values = [ - "${data.template_file.kibana.rendered}", + data.template_file.kibana.rendered ] # This dep needs for correct apply diff --git a/terraform/layer2-k8s/examples/eks-metricbeat.tf b/terraform/layer2-k8s/examples/eks-metricbeat.tf index fd57e967..d7786218 100644 --- a/terraform/layer2-k8s/examples/eks-metricbeat.tf +++ b/terraform/layer2-k8s/examples/eks-metricbeat.tf @@ -3,15 +3,16 @@ data "template_file" "metricbeat" { } resource "helm_release" "metricbeat" { - name = "metricbeat" - chart = "metricbeat" - repository = local.helm_repo_elastic - version = var.elk_version - namespace = kubernetes_namespace.elk.id - wait = false + name = "metricbeat" + chart = "metricbeat" + repository = local.helm_repo_elastic + version = var.elk_version + namespace = kubernetes_namespace.elk.id + wait = false + max_history = "3" values = [ - "${data.template_file.metricbeat.rendered}", + data.template_file.metricbeat.rendered ] # This dep needs for correct apply diff --git a/terraform/layer2-k8s/examples/eks-mysql-backup-wp.tf b/terraform/layer2-k8s/examples/eks-mysql-backup-wp.tf index 178171a4..c459fd89 100644 --- a/terraform/layer2-k8s/examples/eks-mysql-backup-wp.tf +++ b/terraform/layer2-k8s/examples/eks-mysql-backup-wp.tf @@ -34,15 +34,16 @@ data "template_file" "mysql_backup_wp" { } resource "helm_release" "mysql_backup_wp" { - name = "mysql-backup" - chart = "mysql-backup" - repository = local.helm_repo_softonic - version = "2.1.4" - namespace = kubernetes_namespace.wp.id - wait = false + name = "mysql-backup" + chart = "mysql-backup" + repository = local.helm_repo_softonic + version = "2.1.4" + namespace = kubernetes_namespace.wp.id + wait = false + max_history = "3" values = [ - "${data.template_file.mysql_backup_wp.rendered}", + data.template_file.mysql_backup_wp.rendered ] # This dep needs for correct apply diff --git a/terraform/layer2-k8s/examples/eks-oauth2-proxy.tf b/terraform/layer2-k8s/examples/eks-oauth2-proxy.tf index 26199e1a..ae47f015 100644 --- a/terraform/layer2-k8s/examples/eks-oauth2-proxy.tf +++ b/terraform/layer2-k8s/examples/eks-oauth2-proxy.tf @@ -27,15 +27,16 @@ data "template_file" "oauth2_proxy" { } resource "helm_release" "oauth2_proxy" { - name = "oauth2-proxy" - chart = "oauth2-proxy" - repository = local.helm_repo_stable - version = var.oauth2_proxy_version - namespace = kubernetes_namespace.elk.id - wait = false + name = "oauth2-proxy" + chart = "oauth2-proxy" + repository = local.helm_repo_stable + version = var.oauth2_proxy_version + namespace = kubernetes_namespace.elk.id + wait = false + max_history = "3" values = [ - "${data.template_file.oauth2_proxy.rendered}", + data.template_file.oauth2_proxy.rendered ] } diff --git a/terraform/layer2-k8s/examples/eks-postgresql-backups.tf b/terraform/layer2-k8s/examples/eks-postgresql-backups.tf index 3d9b690b..b780155e 100644 --- a/terraform/layer2-k8s/examples/eks-postgresql-backups.tf +++ b/terraform/layer2-k8s/examples/eks-postgresql-backups.tf @@ -6,10 +6,11 @@ locals { } resource "helm_release" "postgresql_backups" { - name = "postgresql-backups" - chart = "../../helm-charts/postgresql-backups" - namespace = kubernetes_namespace.prod.id - wait = false + name = "postgresql-backups" + chart = "../../helm-charts/postgresql-backups" + namespace = kubernetes_namespace.prod.id + wait = false + max_history = "3" values = [ local.postgresql_backups_template diff --git a/terraform/layer2-k8s/examples/eks-prometheus-mysql-exporter.tf b/terraform/layer2-k8s/examples/eks-prometheus-mysql-exporter.tf index 692af75c..2f72a205 100644 --- a/terraform/layer2-k8s/examples/eks-prometheus-mysql-exporter.tf +++ b/terraform/layer2-k8s/examples/eks-prometheus-mysql-exporter.tf @@ -3,15 +3,16 @@ data "template_file" "prometheus_mysql_exporter" { } resource "helm_release" "prometheus_mysql_exporter_wp" { - name = "prometheus-mysql-exporter" - chart = "prometheus-mysql-exporter" - version = var.prometheus_mysql_exporter_version - repository = local.helm_repo_prometheus_community - namespace = kubernetes_namespace.wp.id - wait = false + name = "prometheus-mysql-exporter" + chart = "prometheus-mysql-exporter" + version = var.prometheus_mysql_exporter_version + repository = local.helm_repo_prometheus_community + namespace = kubernetes_namespace.wp.id + wait = false + max_history = "3" values = [ - "${data.template_file.prometheus_mysql_exporter.rendered}", + data.template_file.prometheus_mysql_exporter.rendered ] # This dep needs for correct apply diff --git a/terraform/layer2-k8s/examples/eks-prometheus-postgresql-exporter.tf b/terraform/layer2-k8s/examples/eks-prometheus-postgresql-exporter.tf index aa1eb2fa..694fc8de 100644 --- a/terraform/layer2-k8s/examples/eks-prometheus-postgresql-exporter.tf +++ b/terraform/layer2-k8s/examples/eks-prometheus-postgresql-exporter.tf @@ -27,10 +27,11 @@ locals { } resource "helm_release" "postgresql_exporter_user" { - name = "pg-exporter-user" - chart = "../../helm-charts/pg-exporter-user" - namespace = kubernetes_namespace.monitoring.id - wait = false + name = "pg-exporter-user" + chart = "../../helm-charts/pg-exporter-user" + namespace = kubernetes_namespace.monitoring.id + wait = false + max_history = "3" values = [ local.postgresql_exporter_user_template @@ -38,12 +39,13 @@ resource "helm_release" "postgresql_exporter_user" { } resource "helm_release" "postgresql_exporter" { - name = "prometheus-postgres-exporter" - chart = "prometheus-postgres-exporter" - repository = local.helm_repo_prometheus_community - version = "1.4.0" - namespace = kubernetes_namespace.monitoring.id - wait = false + name = "prometheus-postgres-exporter" + chart = "prometheus-postgres-exporter" + repository = local.helm_repo_prometheus_community + version = "1.4.0" + namespace = kubernetes_namespace.monitoring.id + wait = false + max_history = "3" values = [ local.prometheus_postgresql_exporter_template diff --git a/terraform/layer2-k8s/examples/eks-teamcity.tf b/terraform/layer2-k8s/examples/eks-teamcity.tf index ddd80b14..a86ef815 100644 --- a/terraform/layer2-k8s/examples/eks-teamcity.tf +++ b/terraform/layer2-k8s/examples/eks-teamcity.tf @@ -43,8 +43,10 @@ resource "helm_release" "teamcity" { namespace = kubernetes_namespace.ci.id wait = false cleanup_on_fail = true + max_history = "3" + values = [ - "${data.template_file.teamcity.rendered}", + data.template_file.teamcity.rendered ] } From caaf034a3f5be56707a2adddc9d9583da4e51388 Mon Sep 17 00:00:00 2001 From: maxim Date: Tue, 27 Apr 2021 22:38:43 +0600 Subject: [PATCH 2/2] Use variable helm_release_history_size to set how much helm releases to store instead of hardcoding the value. --- .../layer2-k8s/eks-aws-node-termination-handler.tf | 2 +- terraform/layer2-k8s/eks-cert-manager.tf | 2 +- terraform/layer2-k8s/eks-certificate.tf | 2 +- terraform/layer2-k8s/eks-cluster-autoscaler.tf | 2 +- terraform/layer2-k8s/eks-cluster-issuer.tf | 2 +- terraform/layer2-k8s/eks-external-dns.tf | 2 +- terraform/layer2-k8s/eks-external-secrets.tf | 4 ++-- terraform/layer2-k8s/eks-kube-prometheus-stack.tf | 2 +- terraform/layer2-k8s/eks-loki-stack.tf | 2 +- terraform/layer2-k8s/eks-network-policy.tf | 13 +++++++------ .../layer2-k8s/eks-nginx-ingress-controller.tf | 2 +- .../examples/eks-alb-ingress-controller.tf | 2 +- terraform/layer2-k8s/examples/eks-apm-server.tf | 2 +- terraform/layer2-k8s/examples/eks-elasticsearch.tf | 2 +- terraform/layer2-k8s/examples/eks-elk.tf | 2 +- terraform/layer2-k8s/examples/eks-filebeat.tf | 2 +- terraform/layer2-k8s/examples/eks-gitlab-runner.tf | 2 +- terraform/layer2-k8s/examples/eks-istio.tf | 6 +++--- terraform/layer2-k8s/examples/eks-kibana.tf | 2 +- terraform/layer2-k8s/examples/eks-metricbeat.tf | 2 +- .../layer2-k8s/examples/eks-mysql-backup-wp.tf | 2 +- terraform/layer2-k8s/examples/eks-oauth2-proxy.tf | 2 +- .../layer2-k8s/examples/eks-postgresql-backups.tf | 2 +- .../examples/eks-prometheus-mysql-exporter.tf | 2 +- .../examples/eks-prometheus-postgresql-exporter.tf | 4 ++-- terraform/layer2-k8s/examples/eks-teamcity.tf | 2 +- terraform/layer2-k8s/variables.tf | 5 +++++ 27 files changed, 41 insertions(+), 35 deletions(-) diff --git a/terraform/layer2-k8s/eks-aws-node-termination-handler.tf b/terraform/layer2-k8s/eks-aws-node-termination-handler.tf index b6fc0bd8..4c0ef612 100644 --- a/terraform/layer2-k8s/eks-aws-node-termination-handler.tf +++ b/terraform/layer2-k8s/eks-aws-node-termination-handler.tf @@ -5,7 +5,7 @@ resource "helm_release" "aws_node_termination_handler" { repository = local.helm_repo_eks namespace = kubernetes_namespace.sys.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ file("${path.module}/templates/aws-node-termination-handler-values.yaml") diff --git a/terraform/layer2-k8s/eks-cert-manager.tf b/terraform/layer2-k8s/eks-cert-manager.tf index 8ad7aea3..252c0e77 100644 --- a/terraform/layer2-k8s/eks-cert-manager.tf +++ b/terraform/layer2-k8s/eks-cert-manager.tf @@ -21,7 +21,7 @@ resource "helm_release" "cert_manager" { namespace = kubernetes_namespace.certmanager.id version = var.cert_manager_version wait = true - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.cert_manager.rendered, diff --git a/terraform/layer2-k8s/eks-certificate.tf b/terraform/layer2-k8s/eks-certificate.tf index 0bf5b5cb..255c0741 100644 --- a/terraform/layer2-k8s/eks-certificate.tf +++ b/terraform/layer2-k8s/eks-certificate.tf @@ -12,7 +12,7 @@ resource "helm_release" "certificate" { chart = "../../helm-charts/certificate" namespace = module.ing_namespace.name wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.certificate.rendered, diff --git a/terraform/layer2-k8s/eks-cluster-autoscaler.tf b/terraform/layer2-k8s/eks-cluster-autoscaler.tf index 8f5e9be6..61ee0b2c 100644 --- a/terraform/layer2-k8s/eks-cluster-autoscaler.tf +++ b/terraform/layer2-k8s/eks-cluster-autoscaler.tf @@ -24,7 +24,7 @@ resource "helm_release" "cluster_autoscaler" { repository = local.helm_repo_cluster_autoscaler version = var.cluster_autoscaler_chart_version namespace = kubernetes_namespace.sys.id - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.cluster_autoscaler.rendered, diff --git a/terraform/layer2-k8s/eks-cluster-issuer.tf b/terraform/layer2-k8s/eks-cluster-issuer.tf index c78c6611..07e41c60 100644 --- a/terraform/layer2-k8s/eks-cluster-issuer.tf +++ b/terraform/layer2-k8s/eks-cluster-issuer.tf @@ -13,7 +13,7 @@ resource "helm_release" "cluster_issuer" { chart = "../../helm-charts/cluster-issuer" namespace = kubernetes_namespace.certmanager.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.cluster_issuer.rendered, diff --git a/terraform/layer2-k8s/eks-external-dns.tf b/terraform/layer2-k8s/eks-external-dns.tf index bf9121c8..3148cad0 100644 --- a/terraform/layer2-k8s/eks-external-dns.tf +++ b/terraform/layer2-k8s/eks-external-dns.tf @@ -24,7 +24,7 @@ resource "helm_release" "external_dns" { repository = local.helm_repo_bitnami version = var.external_dns_version namespace = kubernetes_namespace.dns.id - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.external_dns.rendered, diff --git a/terraform/layer2-k8s/eks-external-secrets.tf b/terraform/layer2-k8s/eks-external-secrets.tf index 39503e90..b007e7f8 100644 --- a/terraform/layer2-k8s/eks-external-secrets.tf +++ b/terraform/layer2-k8s/eks-external-secrets.tf @@ -21,7 +21,7 @@ resource "helm_release" "external_secrets" { repository = local.helm_repo_external_secrets version = var.external_secrets_version namespace = kubernetes_namespace.sys.id - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.external_secrets.rendered, @@ -35,7 +35,7 @@ resource "helm_release" "reloader" { version = var.reloader_version namespace = kubernetes_namespace.sys.id wait = false - max_history = "3" + max_history = var.helm_release_history_size } #module "aws_iam_wp_external_secrets" { diff --git a/terraform/layer2-k8s/eks-kube-prometheus-stack.tf b/terraform/layer2-k8s/eks-kube-prometheus-stack.tf index a5149487..0edc0df0 100644 --- a/terraform/layer2-k8s/eks-kube-prometheus-stack.tf +++ b/terraform/layer2-k8s/eks-kube-prometheus-stack.tf @@ -41,7 +41,7 @@ resource "helm_release" "prometheus_operator" { namespace = kubernetes_namespace.monitoring.id version = var.prometheus_operator_version wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ local.kube_prometheus_stack_template diff --git a/terraform/layer2-k8s/eks-loki-stack.tf b/terraform/layer2-k8s/eks-loki-stack.tf index 6a21eecd..daee8e84 100644 --- a/terraform/layer2-k8s/eks-loki-stack.tf +++ b/terraform/layer2-k8s/eks-loki-stack.tf @@ -18,7 +18,7 @@ resource "helm_release" "loki_stack" { namespace = kubernetes_namespace.monitoring.id version = var.loki_stack wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ local.loki_stack_template diff --git a/terraform/layer2-k8s/eks-network-policy.tf b/terraform/layer2-k8s/eks-network-policy.tf index 4da41218..63ba9956 100644 --- a/terraform/layer2-k8s/eks-network-policy.tf +++ b/terraform/layer2-k8s/eks-network-policy.tf @@ -3,12 +3,13 @@ data "template_file" "calico_daemonset" { } resource "helm_release" "calico_daemonset" { - name = "aws-calico" - chart = "aws-calico" - repository = local.helm_repo_eks - version = var.calico_daemonset - namespace = "kube-system" - wait = false + name = "aws-calico" + chart = "aws-calico" + repository = local.helm_repo_eks + version = var.calico_daemonset + namespace = "kube-system" + max_history = var.helm_release_history_size + wait = false values = [ data.template_file.calico_daemonset.rendered, diff --git a/terraform/layer2-k8s/eks-nginx-ingress-controller.tf b/terraform/layer2-k8s/eks-nginx-ingress-controller.tf index ad78abef..16c35d0c 100644 --- a/terraform/layer2-k8s/eks-nginx-ingress-controller.tf +++ b/terraform/layer2-k8s/eks-nginx-ingress-controller.tf @@ -25,7 +25,7 @@ resource "helm_release" "nginx_ingress" { namespace = module.ing_namespace.name version = var.nginx_ingress_controller_version wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.nginx_ingress.rendered, diff --git a/terraform/layer2-k8s/examples/eks-alb-ingress-controller.tf b/terraform/layer2-k8s/examples/eks-alb-ingress-controller.tf index 9f14df6f..4be7d404 100644 --- a/terraform/layer2-k8s/examples/eks-alb-ingress-controller.tf +++ b/terraform/layer2-k8s/examples/eks-alb-ingress-controller.tf @@ -24,7 +24,7 @@ resource "helm_release" "alb_ingress_controller" { repository = local.helm_repo_incubator version = var.alb_ingress_chart_version namespace = kubernetes_namespace.ing.id - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.alb_ingress_controller.rendered diff --git a/terraform/layer2-k8s/examples/eks-apm-server.tf b/terraform/layer2-k8s/examples/eks-apm-server.tf index f8355801..f37cd68d 100644 --- a/terraform/layer2-k8s/examples/eks-apm-server.tf +++ b/terraform/layer2-k8s/examples/eks-apm-server.tf @@ -13,7 +13,7 @@ resource "helm_release" "apm-server" { version = var.elk_version namespace = kubernetes_namespace.elk.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.apm.rendered, diff --git a/terraform/layer2-k8s/examples/eks-elasticsearch.tf b/terraform/layer2-k8s/examples/eks-elasticsearch.tf index 06eb5ae2..a4964d2b 100644 --- a/terraform/layer2-k8s/examples/eks-elasticsearch.tf +++ b/terraform/layer2-k8s/examples/eks-elasticsearch.tf @@ -14,7 +14,7 @@ resource "helm_release" "elasticsearch" { version = var.elk_version namespace = kubernetes_namespace.elk.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.elasticsearch.rendered diff --git a/terraform/layer2-k8s/examples/eks-elk.tf b/terraform/layer2-k8s/examples/eks-elk.tf index e88217af..a900fe67 100644 --- a/terraform/layer2-k8s/examples/eks-elk.tf +++ b/terraform/layer2-k8s/examples/eks-elk.tf @@ -25,7 +25,7 @@ resource "helm_release" "elk" { chart = "../../helm-charts/elk" namespace = kubernetes_namespace.elk.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.elk.rendered diff --git a/terraform/layer2-k8s/examples/eks-filebeat.tf b/terraform/layer2-k8s/examples/eks-filebeat.tf index c41da2ad..48f698f7 100644 --- a/terraform/layer2-k8s/examples/eks-filebeat.tf +++ b/terraform/layer2-k8s/examples/eks-filebeat.tf @@ -9,7 +9,7 @@ resource "helm_release" "filebeat" { version = var.elk_version namespace = kubernetes_namespace.elk.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.filebeat.rendered diff --git a/terraform/layer2-k8s/examples/eks-gitlab-runner.tf b/terraform/layer2-k8s/examples/eks-gitlab-runner.tf index 680375de..ebf7000b 100644 --- a/terraform/layer2-k8s/examples/eks-gitlab-runner.tf +++ b/terraform/layer2-k8s/examples/eks-gitlab-runner.tf @@ -38,7 +38,7 @@ resource "helm_release" "gitlab_runner" { version = var.gitlab_runner_version namespace = kubernetes_namespace.ci.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ local.gitlab_runner_template diff --git a/terraform/layer2-k8s/examples/eks-istio.tf b/terraform/layer2-k8s/examples/eks-istio.tf index 0e3a62b5..62296092 100644 --- a/terraform/layer2-k8s/examples/eks-istio.tf +++ b/terraform/layer2-k8s/examples/eks-istio.tf @@ -15,7 +15,7 @@ resource "helm_release" "istio_operator_resources" { namespace = module.istio_system_namespace.name wait = true - max_history = "3" + max_history = var.helm_release_history_size values = [ file("${path.module}/templates/istio/istio-resources-values.yaml") @@ -36,7 +36,7 @@ resource "helm_release" "istio_resources" { namespace = module.istio_system_namespace.name wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ file("${path.module}/templates/istio/istio-resources-values.yaml") @@ -52,7 +52,7 @@ resource "helm_release" "kiali" { namespace = module.kiali_namespace.name version = var.kiali_version wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ file("${path.module}/templates/istio/istio-kiali-values.yaml") diff --git a/terraform/layer2-k8s/examples/eks-kibana.tf b/terraform/layer2-k8s/examples/eks-kibana.tf index 6068b353..e953d3e2 100644 --- a/terraform/layer2-k8s/examples/eks-kibana.tf +++ b/terraform/layer2-k8s/examples/eks-kibana.tf @@ -42,7 +42,7 @@ resource "helm_release" "kibana" { version = var.elk_version namespace = kubernetes_namespace.elk.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.kibana.rendered diff --git a/terraform/layer2-k8s/examples/eks-metricbeat.tf b/terraform/layer2-k8s/examples/eks-metricbeat.tf index d7786218..b1b9c49b 100644 --- a/terraform/layer2-k8s/examples/eks-metricbeat.tf +++ b/terraform/layer2-k8s/examples/eks-metricbeat.tf @@ -9,7 +9,7 @@ resource "helm_release" "metricbeat" { version = var.elk_version namespace = kubernetes_namespace.elk.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.metricbeat.rendered diff --git a/terraform/layer2-k8s/examples/eks-mysql-backup-wp.tf b/terraform/layer2-k8s/examples/eks-mysql-backup-wp.tf index c459fd89..16ea526b 100644 --- a/terraform/layer2-k8s/examples/eks-mysql-backup-wp.tf +++ b/terraform/layer2-k8s/examples/eks-mysql-backup-wp.tf @@ -40,7 +40,7 @@ resource "helm_release" "mysql_backup_wp" { version = "2.1.4" namespace = kubernetes_namespace.wp.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.mysql_backup_wp.rendered diff --git a/terraform/layer2-k8s/examples/eks-oauth2-proxy.tf b/terraform/layer2-k8s/examples/eks-oauth2-proxy.tf index ae47f015..eeeb386c 100644 --- a/terraform/layer2-k8s/examples/eks-oauth2-proxy.tf +++ b/terraform/layer2-k8s/examples/eks-oauth2-proxy.tf @@ -33,7 +33,7 @@ resource "helm_release" "oauth2_proxy" { version = var.oauth2_proxy_version namespace = kubernetes_namespace.elk.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.oauth2_proxy.rendered diff --git a/terraform/layer2-k8s/examples/eks-postgresql-backups.tf b/terraform/layer2-k8s/examples/eks-postgresql-backups.tf index b780155e..2e44f2ed 100644 --- a/terraform/layer2-k8s/examples/eks-postgresql-backups.tf +++ b/terraform/layer2-k8s/examples/eks-postgresql-backups.tf @@ -10,7 +10,7 @@ resource "helm_release" "postgresql_backups" { chart = "../../helm-charts/postgresql-backups" namespace = kubernetes_namespace.prod.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ local.postgresql_backups_template diff --git a/terraform/layer2-k8s/examples/eks-prometheus-mysql-exporter.tf b/terraform/layer2-k8s/examples/eks-prometheus-mysql-exporter.tf index 2f72a205..a0da4a54 100644 --- a/terraform/layer2-k8s/examples/eks-prometheus-mysql-exporter.tf +++ b/terraform/layer2-k8s/examples/eks-prometheus-mysql-exporter.tf @@ -9,7 +9,7 @@ resource "helm_release" "prometheus_mysql_exporter_wp" { repository = local.helm_repo_prometheus_community namespace = kubernetes_namespace.wp.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.prometheus_mysql_exporter.rendered diff --git a/terraform/layer2-k8s/examples/eks-prometheus-postgresql-exporter.tf b/terraform/layer2-k8s/examples/eks-prometheus-postgresql-exporter.tf index 694fc8de..156b8d61 100644 --- a/terraform/layer2-k8s/examples/eks-prometheus-postgresql-exporter.tf +++ b/terraform/layer2-k8s/examples/eks-prometheus-postgresql-exporter.tf @@ -31,7 +31,7 @@ resource "helm_release" "postgresql_exporter_user" { chart = "../../helm-charts/pg-exporter-user" namespace = kubernetes_namespace.monitoring.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ local.postgresql_exporter_user_template @@ -45,7 +45,7 @@ resource "helm_release" "postgresql_exporter" { version = "1.4.0" namespace = kubernetes_namespace.monitoring.id wait = false - max_history = "3" + max_history = var.helm_release_history_size values = [ local.prometheus_postgresql_exporter_template diff --git a/terraform/layer2-k8s/examples/eks-teamcity.tf b/terraform/layer2-k8s/examples/eks-teamcity.tf index a86ef815..af198a8e 100644 --- a/terraform/layer2-k8s/examples/eks-teamcity.tf +++ b/terraform/layer2-k8s/examples/eks-teamcity.tf @@ -43,7 +43,7 @@ resource "helm_release" "teamcity" { namespace = kubernetes_namespace.ci.id wait = false cleanup_on_fail = true - max_history = "3" + max_history = var.helm_release_history_size values = [ data.template_file.teamcity.rendered diff --git a/terraform/layer2-k8s/variables.tf b/terraform/layer2-k8s/variables.tf index d8fbed6e..7f4cbd1a 100644 --- a/terraform/layer2-k8s/variables.tf +++ b/terraform/layer2-k8s/variables.tf @@ -146,3 +146,8 @@ variable "calico_daemonset" { description = "Version of calico helm chart" default = "0.3.4" } + +variable "helm_release_history_size" { + description = "How much helm releases to store" + default = 5 +}