From c94c846f8b70b1fe6bf69f08b6e4fe231a794656 Mon Sep 17 00:00:00 2001 From: rjshrjndrn Date: Thu, 23 May 2024 19:35:46 +0200 Subject: [PATCH] chore(helm): Adding connector chart Signed-off-by: rjshrjndrn --- scripts/helmcharts/openreplay/Chart.yaml | 4 + .../openreplay/charts/connector/.helmignore | 23 +++ .../openreplay/charts/connector/Chart.yaml | 24 ++++ .../openreplay/charts/connector/README.md | 4 + .../charts/connector/templates/_helpers.tpl | 87 +++++++++++ .../connector/templates/deployment.yaml | 103 +++++++++++++ .../charts/connector/templates/hpa.yaml | 29 ++++ .../charts/connector/templates/ingress.yaml | 62 ++++++++ .../connector/templates/serviceMonitor.yaml | 18 +++ .../connector/templates/serviceaccount.yaml | 13 ++ .../openreplay/charts/connector/values.yaml | 135 ++++++++++++++++++ scripts/helmcharts/vars.yaml | 33 ++--- 12 files changed, 519 insertions(+), 16 deletions(-) create mode 100644 scripts/helmcharts/openreplay/charts/connector/.helmignore create mode 100644 scripts/helmcharts/openreplay/charts/connector/Chart.yaml create mode 100644 scripts/helmcharts/openreplay/charts/connector/README.md create mode 100644 scripts/helmcharts/openreplay/charts/connector/templates/_helpers.tpl create mode 100644 scripts/helmcharts/openreplay/charts/connector/templates/deployment.yaml create mode 100644 scripts/helmcharts/openreplay/charts/connector/templates/hpa.yaml create mode 100644 scripts/helmcharts/openreplay/charts/connector/templates/ingress.yaml create mode 100644 scripts/helmcharts/openreplay/charts/connector/templates/serviceMonitor.yaml create mode 100644 scripts/helmcharts/openreplay/charts/connector/templates/serviceaccount.yaml create mode 100644 scripts/helmcharts/openreplay/charts/connector/values.yaml diff --git a/scripts/helmcharts/openreplay/Chart.yaml b/scripts/helmcharts/openreplay/Chart.yaml index 875a6be3b..80f3953d9 100644 --- a/scripts/helmcharts/openreplay/Chart.yaml +++ b/scripts/helmcharts/openreplay/Chart.yaml @@ -33,3 +33,7 @@ dependencies: version: "0.3.1" repository: "file://charts/quickwit" condition: quickwit.enabled + - name: connector + repository: file://charts/connector + version: 0.1.1 + condition: connector.enabled diff --git a/scripts/helmcharts/openreplay/charts/connector/.helmignore b/scripts/helmcharts/openreplay/charts/connector/.helmignore new file mode 100644 index 000000000..0e8a0eb36 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/connector/.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/scripts/helmcharts/openreplay/charts/connector/Chart.yaml b/scripts/helmcharts/openreplay/charts/connector/Chart.yaml new file mode 100644 index 000000000..18c12cfe0 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/connector/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: connector +description: A Helm chart for Kubernetes + +# 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.1 + +# 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: "v1.17.1" diff --git a/scripts/helmcharts/openreplay/charts/connector/README.md b/scripts/helmcharts/openreplay/charts/connector/README.md new file mode 100644 index 000000000..30496b7f0 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/connector/README.md @@ -0,0 +1,4 @@ +### Installation + +```bash +helm upgrade -i connector ./ -f /path/to/vars.yaml -n db diff --git a/scripts/helmcharts/openreplay/charts/connector/templates/_helpers.tpl b/scripts/helmcharts/openreplay/charts/connector/templates/_helpers.tpl new file mode 100644 index 000000000..9661f20a2 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/connector/templates/_helpers.tpl @@ -0,0 +1,87 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "connector.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 "connector.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 "connector.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "connector.labels" -}} +helm.sh/chart: {{ include "connector.chart" . }} +{{ include "connector.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "connector.selectorLabels" -}} +app.kubernetes.io/name: {{ include "connector.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "connector.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "connector.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Create the environment configuration for REDIS_STRING +*/}} +{{- define "openreplay.env.redis_string" -}} +{{- if .enabled }} +{{- $scheme := (eq (.tls | default dict).enabled true) | ternary "rediss" "redis" -}} +{{- $auth := "" -}} +{{- if or .existingSecret .redisPassword -}} + {{- $auth = printf "%s:$(REDIS_PASSWORD)@" (.redisUsername | default "") -}} +{{- end -}} +{{- if .existingSecret -}} +- name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .existingSecret }} + key: redis-password +{{- else if .redisPassword }} +- name: REDIS_PASSWORD + value: {{ .redisPassword }} +{{- end}} +- name: REDIS_STRING + value: '{{ $scheme }}://{{ $auth }}{{ .redisHost }}:{{ .redisPort }}' +{{- end }} +{{- end }} diff --git a/scripts/helmcharts/openreplay/charts/connector/templates/deployment.yaml b/scripts/helmcharts/openreplay/charts/connector/templates/deployment.yaml new file mode 100644 index 000000000..d46405502 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/connector/templates/deployment.yaml @@ -0,0 +1,103 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "connector.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "connector.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "connector.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "connector.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "connector.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + shareProcessNamespace: true + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + {{- if .Values.global.enterpriseEditionLicense }} + image: "{{ tpl .Values.image.repository . }}:{{ .Values.image.tag | default .Chart.AppVersion }}-ee" + {{- else }} + image: "{{ tpl .Values.image.repository . }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + {{- end }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.healthCheck}} + {{- .Values.healthCheck | toYaml | nindent 10}} + {{- end}} + env: + {{- range $key, $val := .Values.global.connector.env }} + - name: {{ $key }} + value: '{{ $val }}' + {{- end}} + - name: pg_password + {{- if .Values.global.postgresql.existingSecret }} + valueFrom: + secretKeyRef: + name: {{ .Values.global.postgresql.existingSecret }} + key: postgresql-postgres-password + {{- else }} + value: '{{ .Values.global.postgresql.postgresqlPassword }}' + {{- end}} + - name: POSTGRES_STRING + value: 'postgres://{{ .Values.global.postgresql.postgresqlUser }}:$(pg_password)@{{ .Values.global.postgresql.postgresqlHost }}:{{ .Values.global.postgresql.postgresqlPort }}/{{ .Values.global.postgresql.postgresqlDatabase }}' + - name: KAFKA_SERVERS + value: '{{ .Values.global.kafka.kafkaHost }}:{{ .Values.global.kafka.kafkaPort }}' + - name: KAFKA_USE_SSL + value: '{{ .Values.global.kafka.kafkaUseSsl }}' + - name: LICENSE_KEY + value: '{{ .Values.global.enterpriseEditionLicense }}' + - name: AWS_ACCESS_KEY_ID + {{- if .Values.global.s3.existingSecret }} + valueFrom: + secretKeyRef: + name: {{ .Values.global.s3.existingSecret }} + key: access-key + {{- else }} + value: {{ .Values.global.s3.accessKey }} + {{- end }} + - name: AWS_SECRET_ACCESS_KEY + {{- if .Values.global.s3.existingSecret }} + valueFrom: + secretKeyRef: + name: {{ .Values.global.s3.existingSecret }} + key: secret-key + {{- else }} + value: {{ .Values.global.s3.secretKey }} + {{- end }} + - name: AWS_ENDPOINT + value: '{{ .Values.global.s3.endpoint }}' + - name: AWS_REGION + value: '{{ .Values.global.s3.region }}' + {{- include "openreplay.env.redis_string" .Values.global.redis | nindent 12 }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- 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/scripts/helmcharts/openreplay/charts/connector/templates/hpa.yaml b/scripts/helmcharts/openreplay/charts/connector/templates/hpa.yaml new file mode 100644 index 000000000..13c90c6a1 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/connector/templates/hpa.yaml @@ -0,0 +1,29 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "connector.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "connector.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "connector.fullname" . }} + minReplicas: {{ .Values.autoscaling.minReplicas }} + maxReplicas: {{ .Values.autoscaling.maxReplicas }} + metrics: + {{- if .Values.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/scripts/helmcharts/openreplay/charts/connector/templates/ingress.yaml b/scripts/helmcharts/openreplay/charts/connector/templates/ingress.yaml new file mode 100644 index 000000000..807677c39 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/connector/templates/ingress.yaml @@ -0,0 +1,62 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "connector.fullname" . -}} +{{- $svcPort := .Values.service.ports.http -}} +{{- 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 }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "connector.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/scripts/helmcharts/openreplay/charts/connector/templates/serviceMonitor.yaml b/scripts/helmcharts/openreplay/charts/connector/templates/serviceMonitor.yaml new file mode 100644 index 000000000..9a1bdec3c --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/connector/templates/serviceMonitor.yaml @@ -0,0 +1,18 @@ +{{- if and ( .Capabilities.APIVersions.Has "monitoring.coreos.com/v1" ) ( .Values.serviceMonitor.enabled ) }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "connector.fullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "connector.labels" . | nindent 4 }} + {{- if .Values.serviceMonitor.additionalLabels }} + {{- toYaml .Values.serviceMonitor.additionalLabels | nindent 4 }} + {{- end }} +spec: + endpoints: + {{- .Values.serviceMonitor.scrapeConfigs | toYaml | nindent 4 }} + selector: + matchLabels: + {{- include "connector.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/scripts/helmcharts/openreplay/charts/connector/templates/serviceaccount.yaml b/scripts/helmcharts/openreplay/charts/connector/templates/serviceaccount.yaml new file mode 100644 index 000000000..017d4d7b0 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/connector/templates/serviceaccount.yaml @@ -0,0 +1,13 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "connector.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "connector.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/scripts/helmcharts/openreplay/charts/connector/values.yaml b/scripts/helmcharts/openreplay/charts/connector/values.yaml new file mode 100644 index 000000000..ca3983036 --- /dev/null +++ b/scripts/helmcharts/openreplay/charts/connector/values.yaml @@ -0,0 +1,135 @@ +# Default values for openreplay. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +replicaCount: 1 + +image: + repository: "{{ .Values.global.openReplayContainerRegistry }}/connector" + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +imagePullSecrets: [] +nameOverride: "connector" +fullnameOverride: "connector-openreplay" + +serviceAccount: + # Specifies whether a service account should be created + create: 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: {} + +securityContext: + runAsUser: 1001 + runAsGroup: 1001 +podSecurityContext: + runAsUser: 1001 + runAsGroup: 1001 + fsGroup: 1001 + fsGroupChangePolicy: "OnRootMismatch" + +#securityContext: {} +# capabilities: +# drop: +# - ALL +# readOnlyRootFilesystem: true +# runAsNonRoot: true +# runAsUser: 1000 + +serviceMonitor: + enabled: false + additionalLabels: + release: observability + scrapeConfigs: + - port: metrics + honorLabels: true + interval: 15s + path: /metrics + scheme: http + scrapeTimeout: 10s + +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: 5 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +env: {} + +pvc: + # This can be either persistentVolumeClaim or hostPath. + # In case of pvc, you'll have to provide the pvc name. + # For example + # name: openreplay-efs + name: "{{ .Values.global.pvcRWXName }}" + hostMountPath: /openreplay/storage/nfs + +persistence: + {} + # # Spec of spec.template.spec.containers[*].volumeMounts + # mounts: + # - name: kafka-ssl + # mountPath: /opt/kafka/ssl + # # Spec of spec.template.spec.volumes + # volumes: + # - name: kafka-ssl + # secret: + # secretName: kafka-ssl + +nodeSelector: {} + +tolerations: [] + +affinity: {} + +global: + postgresql: {} + kafka: {} + s3: {} + connector: + env: + CONNECTOR_TYPE: "s3" + PROJECT_IDS: "" + BUCKET_NAME: "name" + AWS_SKIP_SSL_VALIDATION: true + REDIS_CACHE_ENABLED: false + GROUP_CONNECTOR: "connector" + TOPIC_RAW_WEB: "raw" + TOPIC_ANALYTICS: "analytics" diff --git a/scripts/helmcharts/vars.yaml b/scripts/helmcharts/vars.yaml index 57bfef38c..9be02b59b 100644 --- a/scripts/helmcharts/vars.yaml +++ b/scripts/helmcharts/vars.yaml @@ -17,8 +17,10 @@ postgresql: &postgres # asdf # cpu: 2 -clickhouse: &clickhouse - # For enterpriseEdition +connector: &connector # For enterpriseEdition + enabled: false + +clickhouse: &clickhouse # For enterpriseEdition enabled: false chHost: clickhouse-openreplay-clickhouse.db.svc.cluster.local username: default @@ -26,8 +28,7 @@ clickhouse: &clickhouse service: webPort: 9000 -quickwit: &quickwit - # For enterpriseEdition +quickwit: &quickwit # For enterpriseEdition enabled: false kafka: &kafka @@ -73,8 +74,8 @@ ingress-nginx: &ingress-nginx ingressClassResource: # -- Name of the ingressClass name: openreplay - # -- For backwards compatibility with ingress.class annotation, use ingressClass. - # Algorithm is as follows, first ingressClassName is considered, if not present, controller looks for ingress.class annotation + # -- For backwards compatibility with ingress.class annotation, use ingressClass. + # Algorithm is as follows, first ingressClassName is considered, if not present, controller looks for ingress.class annotation ingressClass: openreplay addHeaders: # Enable only if you know what you're doing!!! @@ -112,6 +113,7 @@ global: redis: *redis quickwit: *quickwit clickhouse: *clickhouse + connector: *connector # Registry URL from where the OR images should be pulled. openReplayContainerRegistry: "public.ecr.aws/p1t3u8a3" # secret key to inject to assist and peers service @@ -137,15 +139,15 @@ global: accessKey: *accessKey secretKey: *secretKey email: - emailHost: '' - emailPort: '587' - emailUser: '' - emailPassword: '' - emailUseTls: 'true' - emailUseSsl: 'false' - emailSslKey: '' - emailSslCert: '' - emailFrom: 'OpenReplay' + emailHost: "" + emailPort: "587" + emailUser: "" + emailPassword: "" + emailUseTls: "true" + emailUseSsl: "false" + emailSslKey: "" + emailSslCert: "" + emailFrom: "OpenReplay" enterpriseEditionLicense: "" domainName: "" @@ -163,7 +165,6 @@ chalice: # idp_name: '' # idp_tenantKey: '' # enforce_SSO: 'false' - # Below is an example on how to override values # chartname: # filedFrom chart/Values.yaml: