From 381a75a42147c55cc0e8460b408d04517d696fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mustafa=20Ak=C4=B1n?= Date: Fri, 21 Jul 2023 10:48:17 +0300 Subject: [PATCH] try to fix helm --- charts/kubernetes-event-exporter/Chart.yaml | 15 ++++-- .../templates/NOTES.txt | 2 +- .../templates/_helpers.tpl | 7 +-- .../templates/configmap.yaml | 4 +- .../templates/deployment.yaml | 40 +++++++++++----- .../templates/role.yaml | 4 +- .../templates/rolebinding.yaml | 6 +-- .../templates/service.yaml | 2 +- .../templates/serviceaccount.yaml | 4 +- .../templates/servicemonitor.yaml | 46 ++++++++++++++----- charts/kubernetes-event-exporter/values.yaml | 34 ++------------ 11 files changed, 89 insertions(+), 75 deletions(-) diff --git a/charts/kubernetes-event-exporter/Chart.yaml b/charts/kubernetes-event-exporter/Chart.yaml index 64189d27..2bba8aad 100644 --- a/charts/kubernetes-event-exporter/Chart.yaml +++ b/charts/kubernetes-event-exporter/Chart.yaml @@ -2,6 +2,15 @@ apiVersion: v2 name: kubernetes-event-exporter description: Export Kubernetes events to multiple destinations with routing and filtering type: application -version: 0.3.0 -appVersion: "v1.1" -home: https://github.com/resmoio/kubernetes-event-exporter + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.4.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" +home: https://github.com/resmoio/kubernetes-event-exporter \ No newline at end of file diff --git a/charts/kubernetes-event-exporter/templates/NOTES.txt b/charts/kubernetes-event-exporter/templates/NOTES.txt index c1903d1f..1043003e 100644 --- a/charts/kubernetes-event-exporter/templates/NOTES.txt +++ b/charts/kubernetes-event-exporter/templates/NOTES.txt @@ -19,4 +19,4 @@ export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}") echo "Visit http://127.0.0.1:8080 to use your application" kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT -{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/kubernetes-event-exporter/templates/_helpers.tpl b/charts/kubernetes-event-exporter/templates/_helpers.tpl index 3e21e844..11745c72 100644 --- a/charts/kubernetes-event-exporter/templates/_helpers.tpl +++ b/charts/kubernetes-event-exporter/templates/_helpers.tpl @@ -39,12 +39,7 @@ helm.sh/chart: {{ include "kubernetes-event-exporter.chart" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} -app.kubernetes.io/component: metrics -app.kubernetes.io/part-of: {{ template "kubernetes-event-exporter.name" . }} app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- if .Values.additionalLabels }} -{{ toYaml .Values.additionalLabels }} -{{- end }} {{- end }} {{/* @@ -75,4 +70,4 @@ Allow the release namespace to be overridden for multi-namespace deployments in {{- else -}} {{- .Release.Namespace -}} {{- end -}} -{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/kubernetes-event-exporter/templates/configmap.yaml b/charts/kubernetes-event-exporter/templates/configmap.yaml index aafd3db2..a4e2b1ba 100644 --- a/charts/kubernetes-event-exporter/templates/configmap.yaml +++ b/charts/kubernetes-event-exporter/templates/configmap.yaml @@ -1,12 +1,10 @@ apiVersion: v1 kind: ConfigMap metadata: - labels: - {{- include "kubernetes-event-exporter.labels" . | nindent 4 }} name: {{ include "kubernetes-event-exporter.fullname" . }}-cfg namespace: {{ template "kubernetes-event-exporter.namespace" . }} labels: {{- include "kubernetes-event-exporter.labels" . | nindent 4 }} data: config.yaml: | -{{ .Values.config | indent 4 }} +{{ .Values.config | indent 4 }} \ No newline at end of file diff --git a/charts/kubernetes-event-exporter/templates/deployment.yaml b/charts/kubernetes-event-exporter/templates/deployment.yaml index e0277a7c..ba951062 100644 --- a/charts/kubernetes-event-exporter/templates/deployment.yaml +++ b/charts/kubernetes-event-exporter/templates/deployment.yaml @@ -1,10 +1,17 @@ apiVersion: apps/v1 kind: Deployment metadata: - labels: - {{- include "kubernetes-event-exporter.labels" . | nindent 4 }} + {{- with .Values.deploymentAnnotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} name: {{ include "kubernetes-event-exporter.fullname" . }} namespace: {{ include "kubernetes-event-exporter.namespace" . }} + labels: + {{- include "kubernetes-event-exporter.labels" . | nindent 4 }} + {{- with .Values.deploymentLabels }} + {{- toYaml . | nindent 4 }} + {{- end }} spec: replicas: {{ .Values.replicaCount }} selector: @@ -12,14 +19,15 @@ spec: {{- include "kubernetes-event-exporter.selectorLabels" . | nindent 6 }} template: metadata: - {{- with .Values.podAnnotations }} annotations: + checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + {{- with .Values.podAnnotations }} {{- toYaml . | nindent 8 }} {{- end }} labels: - {{- include "kubernetes-event-exporter.labels" . | nindent 8 }} + {{- include "kubernetes-event-exporter.selectorLabels" . | nindent 8 }} spec: - {{- with .Values.imagePullSecrets }} + {{- with .Values.global.imagePullSecrets }} imagePullSecrets: {{- toYaml . | nindent 8 }} {{- end }} @@ -30,25 +38,28 @@ spec: - name: {{ .Chart.Name }} securityContext: {{- toYaml .Values.securityContext | nindent 12 }} - image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + image: "{{ .Values.global.imageRegistry | default .Values.image.registry }}/{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - - name: metrics + - name: http containerPort: {{ .Values.service.port }} protocol: TCP livenessProbe: httpGet: - path: /metrics - port: metrics + path: /-/healthy + port: http readinessProbe: httpGet: - path: /metrics - port: metrics + path: /-/ready + port: http args: - -conf=/data/config.yaml volumeMounts: - mountPath: /data name: cfg + {{- with .Values.extraVolumeMounts }} + {{- toYaml . | nindent 12 }} + {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} {{- with .Values.nodeSelector }} @@ -63,7 +74,14 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + {{- with .Values.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml . | nindent 8 }} + {{- end }} volumes: - name: cfg configMap: name: {{ include "kubernetes-event-exporter.fullname" . }}-cfg + {{- with .Values.extraVolumes }} + {{- toYaml . | nindent 8 }} + {{- end }} \ No newline at end of file diff --git a/charts/kubernetes-event-exporter/templates/role.yaml b/charts/kubernetes-event-exporter/templates/role.yaml index f9b10b98..8b113771 100644 --- a/charts/kubernetes-event-exporter/templates/role.yaml +++ b/charts/kubernetes-event-exporter/templates/role.yaml @@ -3,11 +3,9 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: {{ .Values.rbac.namespaced | ternary "Role" "ClusterRole" }} metadata: - labels: - {{- include "kubernetes-event-exporter.labels" . | nindent 4 }} name: {{ include "kubernetes-event-exporter.fullname" . }} labels: {{- include "kubernetes-event-exporter.labels" . | nindent 4 }} rules: {{ toYaml .Values.rbac.rules }} -{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/kubernetes-event-exporter/templates/rolebinding.yaml b/charts/kubernetes-event-exporter/templates/rolebinding.yaml index 67047331..b609de5d 100644 --- a/charts/kubernetes-event-exporter/templates/rolebinding.yaml +++ b/charts/kubernetes-event-exporter/templates/rolebinding.yaml @@ -1,11 +1,11 @@ {{- if .Values.rbac.create }} --- apiVersion: rbac.authorization.k8s.io/v1 -kind: ClusterRoleBinding +kind: {{ .Values.rbac.namespaced | ternary "RoleBinding" "ClusterRoleBinding" }} metadata: + name: {{ include "kubernetes-event-exporter.fullname" . }} labels: {{- include "kubernetes-event-exporter.labels" . | nindent 4 }} - name: {{ include "kubernetes-event-exporter.fullname" . }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole @@ -14,4 +14,4 @@ subjects: - kind: ServiceAccount namespace: {{ include "kubernetes-event-exporter.namespace" . }} name: {{ include "kubernetes-event-exporter.fullname" . }} -{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/kubernetes-event-exporter/templates/service.yaml b/charts/kubernetes-event-exporter/templates/service.yaml index 63e420b8..ea31e8fc 100644 --- a/charts/kubernetes-event-exporter/templates/service.yaml +++ b/charts/kubernetes-event-exporter/templates/service.yaml @@ -11,4 +11,4 @@ spec: port: {{ .Values.service.port }} protocol: TCP selector: - {{- include "kubernetes-event-exporter.selectorLabels" . | indent 4 }} + {{- include "kubernetes-event-exporter.selectorLabels" . | indent 4 }} \ No newline at end of file diff --git a/charts/kubernetes-event-exporter/templates/serviceaccount.yaml b/charts/kubernetes-event-exporter/templates/serviceaccount.yaml index ee6e2b29..56aeed8c 100644 --- a/charts/kubernetes-event-exporter/templates/serviceaccount.yaml +++ b/charts/kubernetes-event-exporter/templates/serviceaccount.yaml @@ -2,10 +2,8 @@ apiVersion: v1 kind: ServiceAccount metadata: - labels: - {{- include "kubernetes-event-exporter.labels" . | nindent 4 }} name: {{ include "kubernetes-event-exporter.serviceAccountName" . }} namespace: {{ include "kubernetes-event-exporter.namespace" . }} labels: {{- include "kubernetes-event-exporter.labels" . | nindent 4 }} -{{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/kubernetes-event-exporter/templates/servicemonitor.yaml b/charts/kubernetes-event-exporter/templates/servicemonitor.yaml index d8a58963..25f96da0 100644 --- a/charts/kubernetes-event-exporter/templates/servicemonitor.yaml +++ b/charts/kubernetes-event-exporter/templates/servicemonitor.yaml @@ -1,25 +1,47 @@ {{- if .Values.serviceMonitor.enabled }} ---- apiVersion: monitoring.coreos.com/v1 kind: ServiceMonitor metadata: + name: {{ template "kubernetes-event-exporter.fullname" . }} + {{- if .Values.serviceMonitor.namespace }} + namespace: {{ . }} + {{- else }} + namespace: {{ include "kubernetes-event-exporter.namespace" . }} + {{- end }} labels: {{- include "kubernetes-event-exporter.labels" . | nindent 4 }} - {{- if .Values.serviceMonitor.additionalLabels }} - {{ toYaml .Values.serviceMonitor.additionalLabels }} - {{- end }} - name: {{ include "kubernetes-event-exporter.fullname" . }} - namespace: {{ include "kubernetes-event-exporter.namespace" . }} spec: - jobLabel: {{ template "kubernetes-event-exporter.fullname" . }} endpoints: - - port: http + - port: metrics + {{- if .Values.serviceMonitor.interval }} interval: {{ .Values.serviceMonitor.interval }} + {{- end }} + {{- if .Values.serviceMonitor.scheme }} + scheme: {{ .Values.serviceMonitor.scheme }} + {{- end }} + {{- if .Values.serviceMonitor.bearerTokenFile }} + bearerTokenFile: {{ .Values.serviceMonitor.bearerTokenFile }} + {{- end }} + {{- if .Values.serviceMonitor.tlsConfig }} + tlsConfig: {{ toYaml .Values.serviceMonitor.tlsConfig | nindent 6 }} + {{- end }} + {{- if .Values.serviceMonitor.scrapeTimeout }} scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }} - {{- if .Values.serviceMonitor.honorLabels }} - honorLabels: true - {{- end }} + {{- end }} + path: /metrics + honorLabels: {{ .Values.serviceMonitor.honorLabels }} + {{- if .Values.serviceMonitor.metricRelabelings }} + metricRelabelings: + {{- tpl (toYaml .Values.serviceMonitor.metricRelabelings | nindent 4) . }} + {{- end }} + {{- if .Values.serviceMonitor.relabelings }} + relabelings: + {{ toYaml .Values.serviceMonitor.relabelings | nindent 4 }} + {{- end }} + namespaceSelector: + matchNames: + - {{ template "kubernetes-event-exporter.namespace" . }} selector: matchLabels: {{- include "kubernetes-event-exporter.selectorLabels" . | nindent 6 }} -{{- end }} +{{- end -}} \ No newline at end of file diff --git a/charts/kubernetes-event-exporter/values.yaml b/charts/kubernetes-event-exporter/values.yaml index af44195c..bf7bd2d6 100644 --- a/charts/kubernetes-event-exporter/values.yaml +++ b/charts/kubernetes-event-exporter/values.yaml @@ -14,10 +14,6 @@ imagePullSecrets: [] nameOverride: "" fullnameOverride: "" -# -- Additional labels to add to all resources -additionalLabels: {} - # app: kubernetes-events-exporter - serviceAccount: # Specifies whether a service account should be created create: true @@ -33,7 +29,7 @@ podAnnotations: prometheus.io/path: '/metrics' podSecurityContext: {} - # fsGroup: 2000 +# fsGroup: 2000 securityContext: {} # capabilities: @@ -41,7 +37,7 @@ securityContext: {} # - ALL # readOnlyRootFilesystem: true # runAsNonRoot: true - # runAsUser: 1000 +# runAsUser: 1000 service: type: ClusterIP @@ -52,7 +48,7 @@ ingress: className: "" annotations: {} # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" + # kubernetes.io/tls-acme: "true" hosts: - host: chart-example.local paths: @@ -80,7 +76,7 @@ resources: {} # memory: 128Mi # requests: # cpu: 100m - # memory: 128Mi +# memory: 128Mi nodeSelector: {} @@ -97,24 +93,4 @@ config: | - receiver: "dump" receivers: - name: "dump" - stdout: {} - -serviceMonitor: - # -- Enable this if you're using https://github.com/coreos/prometheus-operator - enabled: false - # -- Namespace to deploy the ServiceMonitor - namespace: "" - - # -- Fallback to the prometheus default unless specified - interval: 30s - - # -- Add custom labels to the ServiceMonitor resource - additionalLabels: {} - # prometheus: kube-prometheus - - honorLabels: false - - # -- Path to scrape metrics - path: /metrics - # -- Timeout for scrape metrics request - scrapeTimeout: 10s + stdout: {} \ No newline at end of file