From be4dd64051b9ea36471788705676133e7449ae11 Mon Sep 17 00:00:00 2001 From: Sergiy Kulanov Date: Sun, 2 Jun 2024 09:02:41 +0300 Subject: [PATCH] feat: Add initial version of data-prepper helm chart Let's start with initial version of data-prepper. We can extend it later with more examples of configuration Related issue: #45 Signed-off-by: Sergiy Kulanov --- charts/data-prepper/.helmignore | 23 +++ charts/data-prepper/Chart.yaml | 37 ++++ charts/data-prepper/templates/NOTES.txt | 22 +++ charts/data-prepper/templates/_helpers.tpl | 62 +++++++ charts/data-prepper/templates/configmap.yaml | 9 + charts/data-prepper/templates/deployment.yaml | 112 ++++++++++++ charts/data-prepper/templates/hpa.yaml | 32 ++++ charts/data-prepper/templates/ingress.yaml | 61 +++++++ charts/data-prepper/templates/secret.yaml | 12 ++ charts/data-prepper/templates/service.yaml | 17 ++ .../templates/serviceaccount.yaml | 13 ++ charts/data-prepper/values.yaml | 169 ++++++++++++++++++ 12 files changed, 569 insertions(+) create mode 100644 charts/data-prepper/.helmignore create mode 100644 charts/data-prepper/Chart.yaml create mode 100644 charts/data-prepper/templates/NOTES.txt create mode 100644 charts/data-prepper/templates/_helpers.tpl create mode 100644 charts/data-prepper/templates/configmap.yaml create mode 100644 charts/data-prepper/templates/deployment.yaml create mode 100644 charts/data-prepper/templates/hpa.yaml create mode 100644 charts/data-prepper/templates/ingress.yaml create mode 100644 charts/data-prepper/templates/secret.yaml create mode 100644 charts/data-prepper/templates/service.yaml create mode 100644 charts/data-prepper/templates/serviceaccount.yaml create mode 100644 charts/data-prepper/values.yaml diff --git a/charts/data-prepper/.helmignore b/charts/data-prepper/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/data-prepper/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/charts/data-prepper/Chart.yaml b/charts/data-prepper/Chart.yaml new file mode 100644 index 00000000..236c623c --- /dev/null +++ b/charts/data-prepper/Chart.yaml @@ -0,0 +1,37 @@ +apiVersion: v2 +name: data-prepper +description: A Helm chart for Data Prepper + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# 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.1.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: "2.8.0" + +maintainers: + - name: DandyDeveloper + - name: gaiksaya + - name: peterzhuamazon + - name: prudhvigodithi + - name: sergk + - name: TheAlgo + +home: https://opensearch.org +sources: + - https://github.com/opensearch-project/data-prepper + - https://github.com/opensearch-project/helm-charts diff --git a/charts/data-prepper/templates/NOTES.txt b/charts/data-prepper/templates/NOTES.txt new file mode 100644 index 00000000..cae9ebaf --- /dev/null +++ b/charts/data-prepper/templates/NOTES.txt @@ -0,0 +1,22 @@ +1. Get the application URL by running these commands: +{{- if .Values.ingress.enabled }} +{{- range $host := .Values.ingress.hosts }} + {{- range .paths }} + http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} + {{- end }} +{{- end }} +{{- else if contains "NodePort" .Values.service.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "data-prepper.fullname" . }}) + export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}") + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.type }} + NOTE: It may take a few minutes for the LoadBalancer IP to be available. + You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "data-prepper.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "data-prepper.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") + echo http://$SERVICE_IP:{{ .Values.service.port }} +{{- else if contains "ClusterIP" .Values.service.type }} + export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "data-prepper.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") + 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 }} diff --git a/charts/data-prepper/templates/_helpers.tpl b/charts/data-prepper/templates/_helpers.tpl new file mode 100644 index 00000000..e5e11945 --- /dev/null +++ b/charts/data-prepper/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/charts/data-prepper/templates/configmap.yaml b/charts/data-prepper/templates/configmap.yaml new file mode 100644 index 00000000..7248e5a4 --- /dev/null +++ b/charts/data-prepper/templates/configmap.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "data-prepper.fullname" . }}-config + labels: + {{- include "data-prepper.labels" . | nindent 4 }} +data: + data-prepper-config.yaml: | + {{- toYaml .Values.config | nindent 4 }} diff --git a/charts/data-prepper/templates/deployment.yaml b/charts/data-prepper/templates/deployment.yaml new file mode 100644 index 00000000..3db562c7 --- /dev/null +++ b/charts/data-prepper/templates/deployment.yaml @@ -0,0 +1,112 @@ +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: + annotations: + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- if .Values.config }} + checksum/config: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum | trunc 63 }} + {{- end }} + {{- if .Values.pipelineConfig.enabled }} + checksum/pipelineconfig: {{ include (print .Template.BasePath "/secret.yaml") . | sha256sum | trunc 63 }} + {{- 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: + {{- with .Values.extraEnvs }} + {{- toYaml . | nindent 12 }} + {{- 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.config).serverPort | default 4900 }} + protocol: TCP + livenessProbe: + httpGet: + path: /list + port: server + {{- if not ( empty (.Values.config).ssl ) }} + scheme: HTTPS + {{- end }} + periodSeconds: 10 + initialDelaySeconds: 2 + failureThreshold: 2 + readinessProbe: + httpGet: + path: /list + port: server + {{- if not ( empty (.Values.config).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 + configMap: + name: {{ include "data-prepper.fullname" . }}-config + - name: data-prepper-pipelines + secret: + {{- if .Values.pipelineConfig.enabled }} + secretName: {{ include "data-prepper.fullname" . }}-pipeline + {{- else }} + secretName: {{ required "A valid .Values.pipelineConfig.existingSecret entry required!" .Values.pipelineConfig.existingSecret }} + {{- end }} + {{- 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/charts/data-prepper/templates/hpa.yaml b/charts/data-prepper/templates/hpa.yaml new file mode 100644 index 00000000..ae2a7731 --- /dev/null +++ b/charts/data-prepper/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/charts/data-prepper/templates/ingress.yaml b/charts/data-prepper/templates/ingress.yaml new file mode 100644 index 00000000..facc8973 --- /dev/null +++ b/charts/data-prepper/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/charts/data-prepper/templates/secret.yaml b/charts/data-prepper/templates/secret.yaml new file mode 100644 index 00000000..0e4ff081 --- /dev/null +++ b/charts/data-prepper/templates/secret.yaml @@ -0,0 +1,12 @@ +{{- if .Values.pipelineConfig.enabled }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "data-prepper.fullname" . }}-pipeline + labels: + {{- include "data-prepper.labels" . | nindent 4 }} +type: Opaque +stringData: + pipelines.yaml: | + {{- toYaml .Values.pipelineConfig.config | nindent 4 }} +{{- end }} diff --git a/charts/data-prepper/templates/service.yaml b/charts/data-prepper/templates/service.yaml new file mode 100644 index 00000000..5a6e1860 --- /dev/null +++ b/charts/data-prepper/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/charts/data-prepper/templates/serviceaccount.yaml b/charts/data-prepper/templates/serviceaccount.yaml new file mode 100644 index 00000000..5a1f4ec5 --- /dev/null +++ b/charts/data-prepper/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/charts/data-prepper/values.yaml b/charts/data-prepper/values.yaml new file mode 100644 index 00000000..53064151 --- /dev/null +++ b/charts/data-prepper/values.yaml @@ -0,0 +1,169 @@ +# Copyright OpenSearch Contributors +# SPDX-License-Identifier: Apache-2.0 + +# Default values for data-prepper. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: opensearchproject/data-prepper + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +extraEnvs: [] + # - name: "JAVA_OPTS" + # value: "-Dlog4j2.debug=true" + +# Check https://opensearch.org/docs/latest/data-prepper/managing-data-prepper/configuring-data-prepper/ +# for more information on the configuration options +config: + ssl: false + # circuit_breakers: + # heap: + # usage: 2gb + # reset: 30s + # check_interval: 5s + +# For OpenSearch Data Prepper is crucial for defining the behavior and structure of your data processing pipelines. +# Each pipeline is defined with a unique name and can include `source`, `processor`, and `sink` components to ingest, +# process, and output data respectively. This flexible configuration allows for the creation of complex data processing +# flows, including the routing of data between pipelines. +# For detailed information on the available options and to get the most up-to-date guidance on configuring `pipeline.yaml`, +# please consult the [OpenSearch Documentation on Pipelines](https://opensearch.org/docs/2.4/data-prepper/pipelines/pipelines/). +# This resource provides comprehensive examples and explanations of each component, ensuring you can tailor your Data Prepper +# deployment to meet your specific data processing needs. + +pipelineConfig: + # If enabled, a secret containing the pipeline configuration will be created based on the 'config' section below. + enabled: true + # The name of the existing secret containing the pipeline configuration. + # If enabled is false existingSecret is used. The existingSecret must have a key named `pipelines.yaml`. + existingSecret: "" + # The configuration of the pipeline see https://opensearch.org/docs/2.4/data-prepper/pipelines/pipelines/ + config: + entry-pipeline: + delay: "100" + source: + otel_trace_source: + ssl: false + sink: + - pipeline: + name: "raw-pipeline" + - pipeline: + name: "service-map-pipeline" + raw-pipeline: + source: + pipeline: + name: "entry-pipeline" + processor: + - otel_trace_raw: + sink: + - stdout: + service-map-pipeline: + delay: "100" + source: + pipeline: + name: "entry-pipeline" + processor: + - service_map_stateful: + sink: + - stdout: + +ports: + - name: http-source + port: 2021 + - name: otel-traces + port: 21890 + - name: otel-metrics + port: 21891 + - name: otel-logs + port: 21892 + +serviceAccount: + # Specifies whether a service account should be created + create: true + # 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 + +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: 100 + 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: {}