From 9e36a001120c2a12a54d131f9cb3bcd10d43fa3f Mon Sep 17 00:00:00 2001 From: Kilian Trosien <1645037+kilitr@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:30:41 +0100 Subject: [PATCH] feat(aws-eks-asg-rolling-update-handler): Add option to create PodMonitor --- .../Chart.yaml | 2 +- .../README.md | 1 + .../templates/deployment.yaml | 8 ++++++++ .../templates/podmonitor.yaml | 18 ++++++++++++++++++ .../values.yaml | 5 +++++ 5 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 charts/aws-eks-asg-rolling-update-handler/templates/podmonitor.yaml diff --git a/charts/aws-eks-asg-rolling-update-handler/Chart.yaml b/charts/aws-eks-asg-rolling-update-handler/Chart.yaml index 8b1371a..bae15c8 100644 --- a/charts/aws-eks-asg-rolling-update-handler/Chart.yaml +++ b/charts/aws-eks-asg-rolling-update-handler/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: aws-eks-asg-rolling-update-handler -version: 1.5.0 +version: 1.6.0 description: Handles rolling upgrades for AWS ASGs for EKS by replacing outdated nodes by new nodes. home: https://github.com/TwiN/aws-eks-asg-rolling-update-handler maintainers: diff --git a/charts/aws-eks-asg-rolling-update-handler/README.md b/charts/aws-eks-asg-rolling-update-handler/README.md index 3e55f19..9f8209d 100644 --- a/charts/aws-eks-asg-rolling-update-handler/README.md +++ b/charts/aws-eks-asg-rolling-update-handler/README.md @@ -14,3 +14,4 @@ The following table lists the configurable parameters of the aws-eks-asg-rolling | podLabels | Labels to add to the aws-eks-asg-rolling-update-handler pod configuration | no | `{}` | | securityContext | Pod security context | no | `{}` | | containerSecurityContext | Container security context | no | `{}` | +| podmonitor | Create a PodMonitor | no | `{"create": false, "labels": {}}` | diff --git a/charts/aws-eks-asg-rolling-update-handler/templates/deployment.yaml b/charts/aws-eks-asg-rolling-update-handler/templates/deployment.yaml index d3b7503..2cffc64 100644 --- a/charts/aws-eks-asg-rolling-update-handler/templates/deployment.yaml +++ b/charts/aws-eks-asg-rolling-update-handler/templates/deployment.yaml @@ -39,6 +39,14 @@ spec: securityContext: {{ toYaml .Values.containerSecurityContext | nindent 12 | trim }} {{- end }} + {{- range .Values.environmentVars }} + {{- if eq .name "METRICS_PORT" }} + ports: + - name: metrics + containerPort: {{ .value }} + protocol: TCP + {{- end }} + {{- end }} env: {{- toYaml .Values.environmentVars | nindent 12 }} {{- with .Values.resources }} diff --git a/charts/aws-eks-asg-rolling-update-handler/templates/podmonitor.yaml b/charts/aws-eks-asg-rolling-update-handler/templates/podmonitor.yaml new file mode 100644 index 0000000..a15bcfe --- /dev/null +++ b/charts/aws-eks-asg-rolling-update-handler/templates/podmonitor.yaml @@ -0,0 +1,18 @@ +{{- if .Values.podmonitor.create }} +{{- if .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" }} +apiVersion: monitoring.coreos.com/v1 +kind: PodMonitor +metadata: + name: {{ template "aws-eks-asg-rolling-update-handler.name" . }}-metrics + namespace: {{ template "aws-eks-asg-rolling-update-handler.namespace" . }} + {{- with .Values.podmonitor.labels }} + labels: {{ . | toYaml | nindent 4 }} + {{- end }} +spec: + selector: + matchLabels: + {{ template "aws-eks-asg-rolling-update-handler.labels" . }} + podMetricsEndpoints: + - port: metrics +{{- end }} +{{- end }} diff --git a/charts/aws-eks-asg-rolling-update-handler/values.yaml b/charts/aws-eks-asg-rolling-update-handler/values.yaml index d5c049d..dfcd566 100644 --- a/charts/aws-eks-asg-rolling-update-handler/values.yaml +++ b/charts/aws-eks-asg-rolling-update-handler/values.yaml @@ -49,3 +49,8 @@ containerSecurityContext: {} # capabilities: # drop: # - ALL + +podmonitor: + create: false + labels: {} + # prometheus: core