From a722a1d783cdebac6c79d86936e0bcebf601ddc1 Mon Sep 17 00:00:00 2001 From: Adrien Reslinger Date: Fri, 25 Feb 2022 00:38:43 +0100 Subject: [PATCH] Use helm template values file --- tasks/main.yml | 42 +------------------ templates/traefik-helm-value.yaml.j2 | 62 ++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 40 deletions(-) create mode 100644 templates/traefik-helm-value.yaml.j2 diff --git a/tasks/main.yml b/tasks/main.yml index 2f4a0bc..def16fe 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -84,45 +84,7 @@ name: traefik chart_ref: traefik/traefik release_namespace: "{{ traefik_namespace }}" - values: - image: - tag: "{{ traefik_version }}" - additionalArguments: - - --configFile=/etc/traefik/traefik.yaml -# podSecurityPolicy: -# enabled: true - service: - enabled: false - ingressRoute: - dashboard: - enabled: false - ingressClass: - enabled: true - isDefaultClass: true -# ports: -# web: -# redirectTo: websecure -# hostPort: 80 -# websecure: -# hostPort: 443 -# tls: -# enabled: true -# options: default - volumes: - - mountPath: /etc/traefik - name: traefik-conf - type: configMap - - mountPath: /etc/traefik/file - name: traefik-files - type: configMap - - mountPath: /etc/traefik/basic-auth - name: basic-auth - type: secret - deployment: - replicas: 1 - podAnnotations: - prometheus.io/port: '9000' - prometheus.io/scrape: 'true' + values: "{{ lookup('template', 'traefik-helm-value.yaml.j2') | from_yaml }}" - name: Install traefik configuration k8s: @@ -139,6 +101,6 @@ - traefik-files.yml.j2 # - traefik-sa.yml.j2 - traefik-ingressroute.yml.j2 - - traefik-svc.yml.j2 +# - traefik-svc.yml.j2 tags: traefik diff --git a/templates/traefik-helm-value.yaml.j2 b/templates/traefik-helm-value.yaml.j2 new file mode 100644 index 0000000..f430e44 --- /dev/null +++ b/templates/traefik-helm-value.yaml.j2 @@ -0,0 +1,62 @@ +image: + tag: "{{ traefik_version }}" +additionalArguments: + - --configFile=/etc/traefik/traefik.yaml +#podSecurityPolicy: +# enabled: true +service: +{% if traefik_external_ips is defined %} + type: ClusterIP + externalIPs: +{% for external_ip in traefik_external_ips %} + - {{ external_ip }} +{% endfor %} +{% elseif %} + type: LoadBalancer +{% endif %} +ingressRoute: + dashboard: + enabled: false +podDisruptionBudget: + enabled: true + minAvailable: 1 +ingressClass: + enabled: true + isDefaultClass: true +autoscaling: + enabled: true + minReplicas: 1 + maxReplicas: 10 + metrics: + - type: Resource + resource: + name: cpu + targetAverageUtilization: 60 + - type: Resource + resource: + name: memory + targetAverageUtilization: 60 +#ports: +# web: +# redirectTo: websecure +# hostPort: 80 +# websecure: +# hostPort: 443 +# tls: +# enabled: true +# options: default +volumes: + - mountPath: /etc/traefik + name: traefik-conf + type: configMap + - mountPath: /etc/traefik/file + name: traefik-files + type: configMap + - mountPath: /etc/traefik/basic-auth + name: basic-auth + type: secret +deployment: + replicas: 1 + podAnnotations: + prometheus.io/port: '9000' + prometheus.io/scrape: 'true' \ No newline at end of file