diff --git a/examples/helm-chart/Chart.yaml b/examples/helm-chart/Chart.yaml new file mode 100644 index 0000000000..de3255e268 --- /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.6.2 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..ead1a03966 --- /dev/null +++ b/examples/helm-chart/templates/_helpers.tpl @@ -0,0 +1,70 @@ +{{/* +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 }} + +{{/* +Content-based name for configuration so it triggers a redeploy +*/}} +{{- define "data-prepper.configName" -}} +{{- include "data-prepper.fullname" . }}-{{ trunc 8 (sha256sum (cat .Values.dataPrepperConfig .Values.pipelineConfig )) -}} +{{- end }} + diff --git a/examples/helm-chart/templates/configmap.yaml b/examples/helm-chart/templates/configmap.yaml new file mode 100644 index 0000000000..372ad2c3d0 --- /dev/null +++ b/examples/helm-chart/templates/configmap.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +data: + data-prepper-config.yaml: | + {{- toYaml .Values.dataPrepperConfig | nindent 6 }} +kind: ConfigMap +metadata: + name: {{ include "data-prepper.configName" . }} + labels: + {{- include "data-prepper.labels" . | nindent 4 }} + diff --git a/examples/helm-chart/templates/deployment.yaml b/examples/helm-chart/templates/deployment.yaml new file mode 100644 index 0000000000..8d470761c9 --- /dev/null +++ b/examples/helm-chart/templates/deployment.yaml @@ -0,0 +1,104 @@ +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 + configMap: + name: {{ include "data-prepper.configName" . }} + - name: data-prepper-pipelines + secret: + secretName: {{ include "data-prepper.configName" . }} + {{- 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..a7f63e4868 --- /dev/null +++ b/examples/helm-chart/templates/secret.yaml @@ -0,0 +1,9 @@ +apiVersion: v1 +data: + pipelines.yaml: {{ toYaml .Values.pipelineConfig | b64enc }} +kind: Secret +metadata: + name: {{ include "data-prepper.configName" . }} + 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/templates/servicemonitor.yaml b/examples/helm-chart/templates/servicemonitor.yaml new file mode 100644 index 0000000000..6828db6c79 --- /dev/null +++ b/examples/helm-chart/templates/servicemonitor.yaml @@ -0,0 +1,18 @@ +{{- 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: + matchLabels: + {{- include "data-prepper.selectorLabels" . | nindent 6 }} + endpoints: + {{- toYaml .Values.serviceMonitor.metricsEndpoints | nindent 2 }} +{{- end }} + diff --git a/examples/helm-chart/values.yaml b/examples/helm-chart/values.yaml new file mode 100644 index 0000000000..392dfe8407 --- /dev/null +++ b/examples/helm-chart/values.yaml @@ -0,0 +1,104 @@ +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: {} + +securityContext: {} + +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: otel-traces + port: 21890 +- name: otel-metrics + port: 21891 +- name: otel-logs + port: 21892 + +ingress: + enabled: false + className: '' + annotations: {} + hosts: + - host: chart-example.local + paths: + - path: / + pathType: ImplementationSpecific + tls: [] + +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: {} +