From 269f99327d0c34b336a2ecb4d0475797866afc97 Mon Sep 17 00:00:00 2001 From: Ariel Richtman <10679234+arichtman@users.noreply.github.com> Date: Wed, 22 Nov 2023 15:38:12 +1000 Subject: [PATCH 1/7] added first draft of Helm chart Signed-off-by: Richtman, Ariel <10679234+arichtman@users.noreply.github.com> --- examples/helm-chart/Chart.yaml | 9 ++ examples/helm-chart/templates/NOTES.txt | 0 examples/helm-chart/templates/_helpers.tpl | 62 ++++++++++ examples/helm-chart/templates/deployment.yaml | 109 ++++++++++++++++++ examples/helm-chart/templates/hpa.yaml | 32 +++++ examples/helm-chart/templates/ingress.yaml | 61 ++++++++++ examples/helm-chart/templates/secret.yaml | 9 ++ examples/helm-chart/templates/service.yaml | 17 +++ .../helm-chart/templates/serviceaccount.yaml | 13 +++ examples/helm-chart/values.yaml | 102 ++++++++++++++++ 10 files changed, 414 insertions(+) create mode 100644 examples/helm-chart/Chart.yaml create mode 100644 examples/helm-chart/templates/NOTES.txt create mode 100644 examples/helm-chart/templates/_helpers.tpl create mode 100644 examples/helm-chart/templates/deployment.yaml create mode 100644 examples/helm-chart/templates/hpa.yaml create mode 100644 examples/helm-chart/templates/ingress.yaml create mode 100644 examples/helm-chart/templates/secret.yaml create mode 100644 examples/helm-chart/templates/service.yaml create mode 100644 examples/helm-chart/templates/serviceaccount.yaml create mode 100644 examples/helm-chart/values.yaml diff --git a/examples/helm-chart/Chart.yaml b/examples/helm-chart/Chart.yaml new file mode 100644 index 0000000000..9387f4f557 --- /dev/null +++ b/examples/helm-chart/Chart.yaml @@ -0,0 +1,9 @@ +apiVersion: v2 +name: data-prepper +description: OpenSearch Data Prepper + +type: application + +version: 0.1.0 + +appVersion: 2.5.0 diff --git a/examples/helm-chart/templates/NOTES.txt b/examples/helm-chart/templates/NOTES.txt new file mode 100644 index 0000000000..e69de29bb2 diff --git a/examples/helm-chart/templates/_helpers.tpl b/examples/helm-chart/templates/_helpers.tpl new file mode 100644 index 0000000000..e5e11945ce --- /dev/null +++ b/examples/helm-chart/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "data-prepper.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "data-prepper.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "data-prepper.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "data-prepper.labels" -}} +helm.sh/chart: {{ include "data-prepper.chart" . }} +{{ include "data-prepper.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "data-prepper.selectorLabels" -}} +app.kubernetes.io/name: {{ include "data-prepper.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "data-prepper.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "data-prepper.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/examples/helm-chart/templates/deployment.yaml b/examples/helm-chart/templates/deployment.yaml new file mode 100644 index 0000000000..557fad6435 --- /dev/null +++ b/examples/helm-chart/templates/deployment.yaml @@ -0,0 +1,109 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "data-prepper.fullname" . }} + labels: + {{- include "data-prepper.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "data-prepper.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "data-prepper.labels" . | nindent 8 }} + {{- with .Values.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "data-prepper.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + env: + {{- if .Values.javaDebug }} + - name: JAVA_OPTS + value: -Dlog4j2.debug=true + {{- end }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + {{- range .Values.ports }} + - name: {{ .name }} + containerPort: {{ .port }} + protocol: TCP + {{- end }} + - name: server + containerPort: {{ (.Values.dataPrepperConfig).serverPort | default 4900 }} + protocol: TCP + livenessProbe: + httpGet: + path: /list + port: server + {{- if not ( empty (.Values.dataPrepperConfig).ssl ) }} + scheme: HTTPS + {{- end }} + periodSeconds: 10 + initialDelaySeconds: 2 + failureThreshold: 2 + readinessProbe: + httpGet: + path: /list + port: server + {{- if not ( empty (.Values.dataPrepperConfig).ssl ) }} + scheme: HTTPS + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: data-prepper-config + mountPath: /usr/share/data-prepper/config + readOnly: true + - name: data-prepper-pipelines + mountPath: /usr/share/data-prepper/pipelines + readOnly: true + {{- with .Values.volumeMounts }} + {{- toYaml . | nindent 12 }} + {{- end }} + volumes: + - name: data-prepper-config + secret: + secretName: {{ include "data-prepper.fullname" . }} + items: + - key: data-prepper-config + path: data-prepper-config.yaml + - name: data-prepper-pipelines + secret: + secretName: {{ include "data-prepper.fullname" . }} + items: + - key: pipelines + path: pipelines.yaml + {{- with .Values.volumes }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/examples/helm-chart/templates/hpa.yaml b/examples/helm-chart/templates/hpa.yaml new file mode 100644 index 0000000000..ae2a7731e5 --- /dev/null +++ b/examples/helm-chart/templates/hpa.yaml @@ -0,0 +1,32 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "data-prepper.fullname" . }} + labels: + {{- include "data-prepper.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "data-prepper.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/examples/helm-chart/templates/ingress.yaml b/examples/helm-chart/templates/ingress.yaml new file mode 100644 index 0000000000..facc89734a --- /dev/null +++ b/examples/helm-chart/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "data-prepper.fullname" . -}} +{{- $svcPort := .Values.service.port -}} +{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }} + {{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }} + {{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}} + {{- end }} +{{- end }} +{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1 +{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}} +apiVersion: networking.k8s.io/v1beta1 +{{- else -}} +apiVersion: extensions/v1beta1 +{{- end }} +kind: Ingress +metadata: + name: {{ $fullName }} + labels: + {{- include "data-prepper.labels" . | nindent 4 }} + {{- with .Values.ingress.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }} + ingressClassName: {{ .Values.ingress.className }} + {{- end }} + {{- if .Values.ingress.tls }} + tls: + {{- range .Values.ingress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + rules: + {{- range .Values.ingress.hosts }} + - host: {{ .host | quote }} + http: + paths: + {{- range .paths }} + - path: {{ .path }} + {{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }} + pathType: {{ .pathType }} + {{- end }} + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }} + service: + name: {{ $fullName }} + port: + number: {{ $svcPort }} + {{- else }} + serviceName: {{ $fullName }} + servicePort: {{ $svcPort }} + {{- end }} + {{- end }} + {{- end }} +{{- end }} diff --git a/examples/helm-chart/templates/secret.yaml b/examples/helm-chart/templates/secret.yaml new file mode 100644 index 0000000000..974965b3c8 --- /dev/null +++ b/examples/helm-chart/templates/secret.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +data: + data-prepper-config: {{ toYaml .Values.dataPrepperConfig | b64enc }} + pipelines: {{ toYaml .Values.pipelineConfig | b64enc }} +kind: Secret +metadata: + name: {{ include "data-prepper.fullname" . }} + labels: + {{- include "data-prepper.labels" . | nindent 4 }} diff --git a/examples/helm-chart/templates/service.yaml b/examples/helm-chart/templates/service.yaml new file mode 100644 index 0000000000..5a6e1860d5 --- /dev/null +++ b/examples/helm-chart/templates/service.yaml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "data-prepper.fullname" . }} + labels: + {{- include "data-prepper.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + ports: + {{- range .Values.ports }} + - name: {{ .name }} + port: {{ .port }} + targetPort: {{ .port }} + protocol: TCP + {{- end }} + selector: + {{- include "data-prepper.selectorLabels" . | nindent 4 }} diff --git a/examples/helm-chart/templates/serviceaccount.yaml b/examples/helm-chart/templates/serviceaccount.yaml new file mode 100644 index 0000000000..5a1f4ec520 --- /dev/null +++ b/examples/helm-chart/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "data-prepper.serviceAccountName" . }} + labels: + {{- include "data-prepper.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/examples/helm-chart/values.yaml b/examples/helm-chart/values.yaml new file mode 100644 index 0000000000..0075b94b25 --- /dev/null +++ b/examples/helm-chart/values.yaml @@ -0,0 +1,102 @@ +dataPreppereplicaCount: 1 + +image: + repository: opensearchproject/data-prepper + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: '' + +imagePullSecrets: [] +nameOverride: '' +fullnameOverride: '' + +serviceAccount: + # Specifies whether a service account should be created + create: false + # Automatically mount a ServiceAccount's API credentials? + automount: true + # Annotations to add to the service account + annotations: {} + # The name of the service account to use. + # If not set and create is true, a name is generated using the fullname template + name: '' + +podAnnotations: {} +podLabels: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 +service: + type: ClusterIP + +ports: +- name: http + port: 2021 +- name: otel-traces + port: 21890 +- name: otel-metrics + port: 21891 +- name: otel-logs + port: 21892 + +ingress: + enabled: false + className: '' + annotations: {} + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + # - secretName: chart-example-tls + # hosts: + # - chart-example.local + +resources: {} + # We usually recommend not to specify default resources and to leave this as a conscious + # choice for the user. This also increases chances charts run on environments with little + # resources, such as Minikube. If you do want to specify resources, uncomment the following + # lines, adjust them as necessary, and remove the curly braces after 'resources:'. + # limits: + # cpu: 100m + # memory: 128Mi + # requests: + # cpu: 100m + # memory: 128Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 20 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +# Additional volumes on the output Deployment definition. +volumes: [] +# - name: foo +# secret: +# secretName: mysecret +# optional: false + +# Additional volumeMounts on the output Deployment definition. +volumeMounts: [] +# - name: foo +# mountPath: "/etc/foo" +# readOnly: true + +nodeSelector: {} + +tolerations: [] + +affinity: {} From 62a3b562941f84f3741ca50d5d9fa73c3ce21f8c Mon Sep 17 00:00:00 2001 From: Ariel Richtman <10679234+arichtman@users.noreply.github.com> Date: Fri, 1 Dec 2023 10:44:47 +1000 Subject: [PATCH 2/7] added hashing to ensure redeploy of config changes Signed-off-by: Richtman, Ariel <10679234+arichtman@users.noreply.github.com> --- examples/helm-chart/templates/_helpers.tpl | 8 ++++++++ examples/helm-chart/templates/deployment.yaml | 2 +- examples/helm-chart/templates/secret.yaml | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/helm-chart/templates/_helpers.tpl b/examples/helm-chart/templates/_helpers.tpl index e5e11945ce..0d4a539802 100644 --- a/examples/helm-chart/templates/_helpers.tpl +++ b/examples/helm-chart/templates/_helpers.tpl @@ -60,3 +60,11 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Content-based name for configuration so it triggers a redeploy +*/}} +{{- define "data-prepper.secretName" -}} +{{- include "data-prepper.fullname" . }}-{{ trunc 253 (sha256sum (cat .Values.dataPrepperConfig .Values.pipelineConfig )) -}} +{{- end }} + diff --git a/examples/helm-chart/templates/deployment.yaml b/examples/helm-chart/templates/deployment.yaml index 557fad6435..5c27f92d3f 100644 --- a/examples/helm-chart/templates/deployment.yaml +++ b/examples/helm-chart/templates/deployment.yaml @@ -82,7 +82,7 @@ spec: volumes: - name: data-prepper-config secret: - secretName: {{ include "data-prepper.fullname" . }} + secretName: {{ include "data-prepper.secretName" . }} items: - key: data-prepper-config path: data-prepper-config.yaml diff --git a/examples/helm-chart/templates/secret.yaml b/examples/helm-chart/templates/secret.yaml index 974965b3c8..f313d16c1f 100644 --- a/examples/helm-chart/templates/secret.yaml +++ b/examples/helm-chart/templates/secret.yaml @@ -4,6 +4,6 @@ data: pipelines: {{ toYaml .Values.pipelineConfig | b64enc }} kind: Secret metadata: - name: {{ include "data-prepper.fullname" . }} + name: {{ include "data-prepper.secretName" . }} labels: {{- include "data-prepper.labels" . | nindent 4 }} From 9aed8242e7481950c7e8e19f8c62aec0a170cc48 Mon Sep 17 00:00:00 2001 From: Ariel Richtman <10679234+arichtman@users.noreply.github.com> Date: Fri, 1 Dec 2023 14:32:51 +1000 Subject: [PATCH 3/7] fixed mismatched secret name Signed-off-by: Richtman, Ariel <10679234+arichtman@users.noreply.github.com> --- examples/helm-chart/templates/deployment.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/helm-chart/templates/deployment.yaml b/examples/helm-chart/templates/deployment.yaml index 5c27f92d3f..7661f4e613 100644 --- a/examples/helm-chart/templates/deployment.yaml +++ b/examples/helm-chart/templates/deployment.yaml @@ -88,7 +88,7 @@ spec: path: data-prepper-config.yaml - name: data-prepper-pipelines secret: - secretName: {{ include "data-prepper.fullname" . }} + secretName: {{ include "data-prepper.secretName" . }} items: - key: pipelines path: pipelines.yaml From 47f098292691997572fd2477a151c670f0cf63f4 Mon Sep 17 00:00:00 2001 From: Ariel Richtman <10679234+arichtman@users.noreply.github.com> Date: Fri, 1 Dec 2023 17:27:20 +1000 Subject: [PATCH 4/7] tidying stuff up Signed-off-by: Richtman, Ariel <10679234+arichtman@users.noreply.github.com> --- examples/helm-chart/configmap.yaml | 10 ++++++++++ examples/helm-chart/templates/_helpers.tpl | 4 ++-- examples/helm-chart/templates/deployment.yaml | 13 ++++--------- examples/helm-chart/templates/secret.yaml | 6 +++--- examples/helm-chart/values.yaml | 4 ++++ 5 files changed, 23 insertions(+), 14 deletions(-) create mode 100644 examples/helm-chart/configmap.yaml diff --git a/examples/helm-chart/configmap.yaml b/examples/helm-chart/configmap.yaml new file mode 100644 index 0000000000..87cf43b672 --- /dev/null +++ b/examples/helm-chart/configmap.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +data: + # TODO: work out how to pass through the yaml + data-prepper-config.yaml: 'ssl: false' +kind: ConfigMap +metadata: + name: {{ include "data-prepper.configName" . }} + labels: + {{- include "data-prepper.labels" . | nindent 4 }} + diff --git a/examples/helm-chart/templates/_helpers.tpl b/examples/helm-chart/templates/_helpers.tpl index 0d4a539802..ead1a03966 100644 --- a/examples/helm-chart/templates/_helpers.tpl +++ b/examples/helm-chart/templates/_helpers.tpl @@ -64,7 +64,7 @@ Create the name of the service account to use {{/* Content-based name for configuration so it triggers a redeploy */}} -{{- define "data-prepper.secretName" -}} -{{- include "data-prepper.fullname" . }}-{{ trunc 253 (sha256sum (cat .Values.dataPrepperConfig .Values.pipelineConfig )) -}} +{{- define "data-prepper.configName" -}} +{{- include "data-prepper.fullname" . }}-{{ trunc 8 (sha256sum (cat .Values.dataPrepperConfig .Values.pipelineConfig )) -}} {{- end }} diff --git a/examples/helm-chart/templates/deployment.yaml b/examples/helm-chart/templates/deployment.yaml index 7661f4e613..8d470761c9 100644 --- a/examples/helm-chart/templates/deployment.yaml +++ b/examples/helm-chart/templates/deployment.yaml @@ -81,17 +81,11 @@ spec: {{- end }} volumes: - name: data-prepper-config - secret: - secretName: {{ include "data-prepper.secretName" . }} - items: - - key: data-prepper-config - path: data-prepper-config.yaml + configMap: + name: {{ include "data-prepper.configName" . }} - name: data-prepper-pipelines secret: - secretName: {{ include "data-prepper.secretName" . }} - items: - - key: pipelines - path: pipelines.yaml + secretName: {{ include "data-prepper.configName" . }} {{- with .Values.volumes }} {{- toYaml . | nindent 8 }} {{- end }} @@ -107,3 +101,4 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} + diff --git a/examples/helm-chart/templates/secret.yaml b/examples/helm-chart/templates/secret.yaml index f313d16c1f..a7f63e4868 100644 --- a/examples/helm-chart/templates/secret.yaml +++ b/examples/helm-chart/templates/secret.yaml @@ -1,9 +1,9 @@ apiVersion: v1 data: - data-prepper-config: {{ toYaml .Values.dataPrepperConfig | b64enc }} - pipelines: {{ toYaml .Values.pipelineConfig | b64enc }} + pipelines.yaml: {{ toYaml .Values.pipelineConfig | b64enc }} kind: Secret metadata: - name: {{ include "data-prepper.secretName" . }} + name: {{ include "data-prepper.configName" . }} labels: {{- include "data-prepper.labels" . | nindent 4 }} + diff --git a/examples/helm-chart/values.yaml b/examples/helm-chart/values.yaml index 0075b94b25..082e11b1ab 100644 --- a/examples/helm-chart/values.yaml +++ b/examples/helm-chart/values.yaml @@ -37,6 +37,9 @@ securityContext: {} service: type: ClusterIP +dataPrepperConfig: {} +pipelineConfig: {} + ports: - name: http port: 2021 @@ -100,3 +103,4 @@ nodeSelector: {} tolerations: [] affinity: {} + From baa1217b10d1d92147656a9268593845e86e247f Mon Sep 17 00:00:00 2001 From: Ariel Richtman <10679234+arichtman@users.noreply.github.com> Date: Tue, 12 Dec 2023 13:34:01 +1000 Subject: [PATCH 5/7] added servicemonitor Signed-off-by: Richtman, Ariel <10679234+arichtman@users.noreply.github.com> --- .../helm-chart/{ => templates}/configmap.yaml | 4 ++-- .../helm-chart/templates/servicemonitor.yaml | 17 +++++++++++++ examples/helm-chart/values.yaml | 24 +++++++++---------- 3 files changed, 31 insertions(+), 14 deletions(-) rename examples/helm-chart/{ => templates}/configmap.yaml (64%) create mode 100644 examples/helm-chart/templates/servicemonitor.yaml diff --git a/examples/helm-chart/configmap.yaml b/examples/helm-chart/templates/configmap.yaml similarity index 64% rename from examples/helm-chart/configmap.yaml rename to examples/helm-chart/templates/configmap.yaml index 87cf43b672..372ad2c3d0 100644 --- a/examples/helm-chart/configmap.yaml +++ b/examples/helm-chart/templates/configmap.yaml @@ -1,7 +1,7 @@ apiVersion: v1 data: - # TODO: work out how to pass through the yaml - data-prepper-config.yaml: 'ssl: false' + data-prepper-config.yaml: | + {{- toYaml .Values.dataPrepperConfig | nindent 6 }} kind: ConfigMap metadata: name: {{ include "data-prepper.configName" . }} diff --git a/examples/helm-chart/templates/servicemonitor.yaml b/examples/helm-chart/templates/servicemonitor.yaml new file mode 100644 index 0000000000..3589539b4d --- /dev/null +++ b/examples/helm-chart/templates/servicemonitor.yaml @@ -0,0 +1,17 @@ +{{- if .Values.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "data-prepper.fullname" . }} + labels: + {{- include "data-prepper.labels" . | nindent 4 }} + {{- range $key, $value := .Values.serviceMonitor.extraLabels }} + {{- printf "%s: %s" $key (tpl $value $ | quote) | nindent 4 }} + {{- end }} +spec: + selector: + {{- include "data-prepper.selectorLabels" . | nindent 4 }} + endpoints: + {{- toYaml .Values.serviceMonitor.metricsEndpoints | nindent 2 }} +{{- end }} + diff --git a/examples/helm-chart/values.yaml b/examples/helm-chart/values.yaml index 082e11b1ab..f598a09df1 100644 --- a/examples/helm-chart/values.yaml +++ b/examples/helm-chart/values.yaml @@ -25,24 +25,29 @@ podAnnotations: {} podLabels: {} podSecurityContext: {} - # fsGroup: 2000 securityContext: {} - # capabilities: - # drop: - # - ALL - # readOnlyRootFilesystem: true - # runAsNonRoot: true - # runAsUser: 1000 + service: type: ClusterIP dataPrepperConfig: {} pipelineConfig: {} +serviceMonitor: + enabled: false + extraLabels: {} + metricsEndpoints: + - port: server + path: /metrics/sys + - port: server + path: /metrics/prometheus + ports: - name: http port: 2021 +- name: server + port: 4900 - name: otel-traces port: 21890 - name: otel-metrics @@ -54,17 +59,12 @@ ingress: enabled: false className: '' annotations: {} - # kubernetes.io/ingress.class: nginx - # kubernetes.io/tls-acme: "true" hosts: - host: chart-example.local paths: - path: / pathType: ImplementationSpecific tls: [] - # - secretName: chart-example-tls - # hosts: - # - chart-example.local resources: {} # We usually recommend not to specify default resources and to leave this as a conscious From 4530f3699b3b69636dc2909ac03db9bb41def707 Mon Sep 17 00:00:00 2001 From: Ariel Richtman <10679234+arichtman@users.noreply.github.com> Date: Wed, 20 Dec 2023 13:43:24 +1000 Subject: [PATCH 6/7] updated servicemonitor selector to spec Signed-off-by: Richtman, Ariel <10679234+arichtman@users.noreply.github.com> --- examples/helm-chart/templates/servicemonitor.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/examples/helm-chart/templates/servicemonitor.yaml b/examples/helm-chart/templates/servicemonitor.yaml index 3589539b4d..6828db6c79 100644 --- a/examples/helm-chart/templates/servicemonitor.yaml +++ b/examples/helm-chart/templates/servicemonitor.yaml @@ -10,7 +10,8 @@ metadata: {{- end }} spec: selector: - {{- include "data-prepper.selectorLabels" . | nindent 4 }} + matchLabels: + {{- include "data-prepper.selectorLabels" . | nindent 6 }} endpoints: {{- toYaml .Values.serviceMonitor.metricsEndpoints | nindent 2 }} {{- end }} From edf34eacfd6b327cad5d7e0f479fa9578616e641 Mon Sep 17 00:00:00 2001 From: Ariel Richtman <10679234+arichtman@users.noreply.github.com> Date: Mon, 26 Feb 2024 15:23:48 +1000 Subject: [PATCH 7/7] fixed error on repeated server port and upgraded base app version --- examples/helm-chart/Chart.yaml | 2 +- examples/helm-chart/values.yaml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/examples/helm-chart/Chart.yaml b/examples/helm-chart/Chart.yaml index 9387f4f557..de3255e268 100644 --- a/examples/helm-chart/Chart.yaml +++ b/examples/helm-chart/Chart.yaml @@ -6,4 +6,4 @@ type: application version: 0.1.0 -appVersion: 2.5.0 +appVersion: 2.6.2 diff --git a/examples/helm-chart/values.yaml b/examples/helm-chart/values.yaml index f598a09df1..392dfe8407 100644 --- a/examples/helm-chart/values.yaml +++ b/examples/helm-chart/values.yaml @@ -46,8 +46,6 @@ serviceMonitor: ports: - name: http port: 2021 -- name: server - port: 4900 - name: otel-traces port: 21890 - name: otel-metrics