From 4b4ffb0ce3783370f8eb08a6c7bf1a88ee720aa6 Mon Sep 17 00:00:00 2001 From: Akash LM Date: Sat, 8 Jun 2024 23:23:22 +0530 Subject: [PATCH] feat: Add helm chart --- charts/qualitytrace/.helmignore | 23 ++ charts/qualitytrace/Chart.yaml | 11 + charts/qualitytrace/README.md | 25 ++ charts/qualitytrace/templates/NOTES.txt | 22 + charts/qualitytrace/templates/_helpers.tpl | 122 ++++++ .../qualitytrace/templates/analyzer-job.yaml | 130 ++++++ .../qualitytrace/templates/configmap-db.yaml | 20 + charts/qualitytrace/templates/configmap.yaml | 35 ++ .../templates/create-user-db-job.yaml | 52 +++ charts/qualitytrace/templates/deployment.yaml | 107 +++++ charts/qualitytrace/templates/hpa.yaml | 28 ++ charts/qualitytrace/templates/ingress.yaml | 61 +++ .../templates/otel-collector-configmap.yaml | 7 + .../templates/otel-collector-deployment.yaml | 73 ++++ .../otel-collector-ingress_route.yaml | 26 ++ .../templates/otel-collector-service.yaml | 23 ++ charts/qualitytrace/templates/service.yaml | 27 ++ .../templates/serviceaccount.yaml | 12 + .../templates/tests/test-connection.yaml | 15 + charts/qualitytrace/values.yaml | 385 ++++++++++++++++++ 20 files changed, 1204 insertions(+) create mode 100644 charts/qualitytrace/.helmignore create mode 100644 charts/qualitytrace/Chart.yaml create mode 100644 charts/qualitytrace/README.md create mode 100644 charts/qualitytrace/templates/NOTES.txt create mode 100644 charts/qualitytrace/templates/_helpers.tpl create mode 100644 charts/qualitytrace/templates/analyzer-job.yaml create mode 100644 charts/qualitytrace/templates/configmap-db.yaml create mode 100644 charts/qualitytrace/templates/configmap.yaml create mode 100644 charts/qualitytrace/templates/create-user-db-job.yaml create mode 100644 charts/qualitytrace/templates/deployment.yaml create mode 100644 charts/qualitytrace/templates/hpa.yaml create mode 100644 charts/qualitytrace/templates/ingress.yaml create mode 100644 charts/qualitytrace/templates/otel-collector-configmap.yaml create mode 100644 charts/qualitytrace/templates/otel-collector-deployment.yaml create mode 100644 charts/qualitytrace/templates/otel-collector-ingress_route.yaml create mode 100644 charts/qualitytrace/templates/otel-collector-service.yaml create mode 100644 charts/qualitytrace/templates/service.yaml create mode 100644 charts/qualitytrace/templates/serviceaccount.yaml create mode 100644 charts/qualitytrace/templates/tests/test-connection.yaml create mode 100644 charts/qualitytrace/values.yaml diff --git a/charts/qualitytrace/.helmignore b/charts/qualitytrace/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/qualitytrace/.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/qualitytrace/Chart.yaml b/charts/qualitytrace/Chart.yaml new file mode 100644 index 0000000..fcf7053 --- /dev/null +++ b/charts/qualitytrace/Chart.yaml @@ -0,0 +1,11 @@ +apiVersion: v2 +appVersion: v1.0.0 +dependencies: +- name: postgresql + repository: https://kube-tarian.github.io/helmrepo-supporting-tools/ + version: 1.x.x + condition: postgresql.enabled +description: A Helm chart for QualityTrace +name: qualitytrace +type: application +version: 1.0.0 diff --git a/charts/qualitytrace/README.md b/charts/qualitytrace/README.md new file mode 100644 index 0000000..d368f74 --- /dev/null +++ b/charts/qualitytrace/README.md @@ -0,0 +1,25 @@ +# qualitytrace + +This is the Helm chart for [qualitytrace] installation. + +## Installation + +### Chart installation + +Add repo: + +```sh +helm repo add qualitytrace https://intelops.github.io/qualitytrace +helm repo update + +``` + +```sh +helm install qualitytrace qualitytrace/qualitytrace +``` + +## Uninstall + +```sh +helm delete qualitytrace +``` diff --git a/charts/qualitytrace/templates/NOTES.txt b/charts/qualitytrace/templates/NOTES.txt new file mode 100644 index 0000000..819acd2 --- /dev/null +++ b/charts/qualitytrace/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 "qualitytrace.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 the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "qualitytrace.fullname" . }}' + export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "qualitytrace.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 "qualitytrace.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/qualitytrace/templates/_helpers.tpl b/charts/qualitytrace/templates/_helpers.tpl new file mode 100644 index 0000000..1460756 --- /dev/null +++ b/charts/qualitytrace/templates/_helpers.tpl @@ -0,0 +1,122 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "qualitytrace.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 "qualitytrace.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 "qualitytrace.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "qualitytrace.labels" -}} +helm.sh/chart: {{ include "qualitytrace.chart" . }} +{{ include "qualitytrace.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Create a default fully qualified postgresql name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +*/}} +{{- define "qualitytrace.postgresql.fullname" -}} +{{- include "common.names.dependency.fullname" (dict "chartName" "postgresql" "chartValues" .Values.postgresql "context" $) -}} +{{- end -}} + + +{{- define "qualitytrace.database.encryptedPassword" -}} + {{- include "qualitytrace.database.rawPassword" . | b64enc | quote -}} +{{- end -}} + +{{- define "qualitytrace.database.rawPassword" -}} +{{- if .Values.postgresql.enabled }} + {{- if .Values.global.postgresql }} + {{- if .Values.global.postgresql.auth }} + {{- coalesce .Values.global.postgresql.auth.postgresPassword .Values.postgresql.auth.postgresPassword -}} + {{- else -}} + {{- .Values.postgresql.auth.postgresPassword -}} + {{- end -}} + {{- else -}} + {{- .Values.postgresql.auth.postgresPassword -}} + {{- end -}} +{{- else -}} + {{- .Values.externalDatabase.password -}} +{{- end -}} +{{- end -}} + + +{{/* +Selector labels +*/}} +{{- define "qualitytrace.selectorLabels" -}} +app.kubernetes.io/name: {{ include "qualitytrace.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "qualitytrace.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "qualitytrace.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} + +{{/* +Define a valid pathPrefix +*/}} +{{- define "qualitytrace.pathPrefix" -}} + {{- if .Values.server.pathPrefix }} + {{- .Values.server.pathPrefix }} + {{- else }} + {{- "/" }} + {{- end }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "otelCollector.labels" -}} +helm.sh/chart: {{ include "qualitytrace.chart" . }} +{{ include "otelCollector.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end -}} + +{{/* +Selector labels +*/}} +{{- define "otelCollector.selectorLabels" -}} +app.kubernetes.io/name: {{ default "otel-collector" .Values.otelCollector.name }} +{{- end -}} \ No newline at end of file diff --git a/charts/qualitytrace/templates/analyzer-job.yaml b/charts/qualitytrace/templates/analyzer-job.yaml new file mode 100644 index 0000000..7499d59 --- /dev/null +++ b/charts/qualitytrace/templates/analyzer-job.yaml @@ -0,0 +1,130 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: {{ include "qualitytrace.fullname" . }}-analyzer + annotations: + "helm.sh/hook": post-install + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + spec: + containers: + - name: analyzer + image: ghcr.io/kube-tarian/helmrepo-supporting-tools/curl:latest + command: ["/bin/sh", "-c"] + args: + - > + sleep 100 && + curl --location --request PUT 'http://{{ include "qualitytrace.fullname" . }}:11633/api/analyzers/current' \ + --header 'Content-Type: application/json' \ + --data '{ + "type": "Analyzer", + "typePlural": "Analyzers", + "spec": { + "id": "current", + "name": "analyzer", + "minimumScore": 0, + "enabled": {{ .Values.analyzer.enabled }}, + "plugins": [ + { + "name": "OTel Semantic Conventions", + "id": "standards", + "enabled": true, + "description": "Enforce trace standards following OTel Semantic Conventions", + "rules": [ + { + "id": "span-naming", + "weight": 25, + "errorLevel": "error", + "name": "Span Naming", + "description": "Enforce span names that identify a class of Spans", + "errorDescription": "", + "tips": [] + }, + { + "id": "required-attributes", + "weight": 25, + "errorLevel": "error", + "name": "Required Attributes", + "description": "Enforce required attributes by span type", + "errorDescription": "This span is missing the following required attributes:", + "tips": [ + "This rule checks if all required attributes are present in spans of given type" + ] + }, + { + "id": "attribute-naming", + "weight": 25, + "errorLevel": "error", + "name": "Attribute Naming", + "description": "Enforce attribute keys to follow common specifications", + "errorDescription": "The following attributes do not follow the naming convention:", + "tips": [ + "You should always add namespaces to your span names to ensure they will not be overwritten", + "Use snake_case to separate multi-words. Ex: http.status_code instead of http.statusCode" + ] + }, + { + "id": "no-empty-attributes", + "weight": 25, + "errorLevel": "error", + "name": "No Empty Attributes", + "description": "Disallow empty attribute values", + "errorDescription": "The following attributes are empty:", + "tips": [ + "Empty attributes don'\''t provide any information about the operation and should be removed" + ] + } + ] + }, + { + "name": "Common Problems", + "id": "common", + "enabled": true, + "description": "Help you find common mistakes with your application", + "rules": [ + { + "id": "prefer-dns", + "weight": 100, + "errorLevel": "error", + "name": "Prefer DNS", + "description": "Enforce usage of DNS instead of IP addresses", + "errorDescription": "The following attributes are using IP addresses instead of DNS:", + "tips": [] + } + ] + }, + { + "name": "Security", + "id": "security", + "enabled": true, + "description": "Help you find security problems with your application", + "rules": [ + { + "id": "secure-https-protocol", + "weight": 30, + "errorLevel": "error", + "name": "Secure HTTPS Protocol", + "description": "Enforce usage of secure protocol for HTTP server spans", + "errorDescription": "The following attributes are using insecure http protocol:", + "tips": [] + }, + { + "id": "no-api-key-leak", + "weight": 70, + "errorLevel": "error", + "name": "No API Key Leak", + "description": "Disallow leaked API keys for HTTP spans", + "errorDescription": "The following attributes are exposing API keys:", + "tips": [] + } + ] + } + ] + } + }' + restartPolicy: Never + backoffLimit: 1 + + + diff --git a/charts/qualitytrace/templates/configmap-db.yaml b/charts/qualitytrace/templates/configmap-db.yaml new file mode 100644 index 0000000..0492ae0 --- /dev/null +++ b/charts/qualitytrace/templates/configmap-db.yaml @@ -0,0 +1,20 @@ +{{- if not .Values.postgresql.enabled }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: postgresql-query + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-weight": "1" + "helm.sh/hook-delete-policy": before-hook-creation +data: + create-database.sql: | + SELECT 'CREATE DATABASE {{ .Values.externalPostgresql.qualitytrace.database }}' + WHERE NOT EXISTS (SELECT FROM pg_database WHERE datname='{{ .Values.externalPostgresql.qualitytrace.database }}')\gexec + + SELECT 'CREATE USER {{ .Values.externalPostgresql.qualitytrace.username }} WITH PASSWORD ''' || :'db_password' || '''' + WHERE NOT EXISTS (SELECT 1 FROM pg_roles WHERE rolname='{{ .Values.externalPostgresql.qualitytrace.username }}')\gexec + + ALTER DATABASE {{ .Values.externalPostgresql.qualitytrace.database }} OWNER TO {{ .Values.externalPostgresql.qualitytrace.username }}; + ALTER ROLE {{ .Values.externalPostgresql.qualitytrace.username }} CREATEDB; +{{- end }} \ No newline at end of file diff --git a/charts/qualitytrace/templates/configmap.yaml b/charts/qualitytrace/templates/configmap.yaml new file mode 100644 index 0000000..1fa88fe --- /dev/null +++ b/charts/qualitytrace/templates/configmap.yaml @@ -0,0 +1,35 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "qualitytrace.fullname" . }} + labels: + {{- include "qualitytrace.labels" . | nindent 4 }} +data: + config.yaml: |- + poolingConfig: + {{- toYaml .Values.poolingConfig | nindent 6 }} + googleAnalytics: + enabled: {{.Values.analytics.enabled}} + postgres: + {{- if .Values.postgresql.enabled }} + host: {{ include "qualitytrace.postgresql.fullname" . }} + user: {{.Values.postgresql.auth.username}} + password: {{.Values.postgresql.auth.password}} + {{- else }} + host: {{ .Values.externalPostgresql.host }} + user: {{ .Values.externalPostgresql.qualitytrace.username }} + {{- if not .Values.externalPostgresql.qualitytrace.existingSecret }} + password: {{ .Values.externalPostgresql.qualitytrace.password }} + {{- else }} + password: 'db_password' + {{- end }} + {{- end }} + port: 5432 + params: sslmode=disable + telemetry: + {{- toYaml .Values.telemetry | nindent 6 }} + server: + {{- toYaml .Values.server | nindent 6 }} + provisioning.yaml: |- + {{- toYaml .Values.provisioning | nindent 4 }} +--- diff --git a/charts/qualitytrace/templates/create-user-db-job.yaml b/charts/qualitytrace/templates/create-user-db-job.yaml new file mode 100644 index 0000000..1429eec --- /dev/null +++ b/charts/qualitytrace/templates/create-user-db-job.yaml @@ -0,0 +1,52 @@ +{{- if not .Values.postgresql.enabled }} +apiVersion: batch/v1 +kind: Job +metadata: + name: create-user-database + annotations: + "helm.sh/hook": pre-install + "helm.sh/hook-weight": "2" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: create-user-database + spec: + containers: + - name: postgresql-client + image: {{ .Values.postgresql.image.registry }}/{{ .Values.postgresql.image.repository }}:{{ .Values.postgresql.image.tag }} + command: + - "/bin/bash" + - "-c" + - | + psql -h {{ .Values.externalPostgresql.host }} -p 5432 -U postgres -v db_password=$DB_PASSWORD -f /script/create-database.sql + env: + - name: PGPASSWORD + {{- if not .Values.externalPostgresql.existingSecret }} + value: "{{ .Values.externalPostgresql.postgresqlPassword }}" + {{- else }} + valueFrom: + secretKeyRef: + name: {{ .Values.externalPostgresql.existingSecret.name }} + key: {{ .Values.externalPostgresql.existingSecret.passwordKey }} + {{- end }} + - name: DB_PASSWORD + {{- if not .Values.externalPostgresql.qualitytrace.existingSecret }} + value: "{{ .Values.externalPostgresql.qualitytrace.password }}" + {{- else }} + valueFrom: + secretKeyRef: + name: {{ .Values.externalPostgresql.qualitytrace.existingSecret.name }} + key: {{ .Values.externalPostgresql.qualitytrace.existingSecret.passwordKey }} + {{- end }} + volumeMounts: + - name: script-volume + mountPath: /script + readOnly: true + restartPolicy: Never + volumes: + - name: script-volume + configMap: + name: postgresql-query +{{- end }} + diff --git a/charts/qualitytrace/templates/deployment.yaml b/charts/qualitytrace/templates/deployment.yaml new file mode 100644 index 0000000..a0d07ac --- /dev/null +++ b/charts/qualitytrace/templates/deployment.yaml @@ -0,0 +1,107 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "qualitytrace.fullname" . }} + labels: + {{- include "qualitytrace.labels" . | nindent 4 }} +spec: + {{- if not .Values.autoscaling.enabled }} + replicas: {{ .Values.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "qualitytrace.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "qualitytrace.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "qualitytrace.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + env: + {{- if and (not .Values.postgresql.enabled) (.Values.externalPostgresql.qualitytrace.existingSecret) }} + - name: DB_PASSWORD + valueFrom: + secretKeyRef: + name: {{ .Values.externalPostgresql.qualitytrace.existingSecret.name }} + key: {{ .Values.externalPostgresql.qualitytrace.existingSecret.passwordKey }} + {{- end }} + - name: QUALITYTRACE_DEV + value: "{{ .Values.env.qualitytraceDev }}" + {{- if and (not .Values.postgresql.enabled) (.Values.externalPostgresql.qualitytrace.existingSecret) }} + command: + - sh + - -c + - | + cp /app/config/config.yaml /processed-config/ + sed -i 's/db_password/'"$DB_PASSWORD"'/g' /processed-config/config.yaml + /app/qualitytrace-server serve --config /processed-config/config.yaml --provisioning-file /app/config/provisioning.yaml + {{- else }} + args: + - "--config" + - "/app/config/config.yaml" + - "--provisioning-file" + - "/app/config/provisioning.yaml" + {{- end }} + imagePullPolicy: {{ .Values.image.pullPolicy }} + ports: + - name: http + containerPort: {{ .Values.server.httpPort }} + protocol: TCP + - name: otlp-grpc + containerPort: {{ .Values.server.otlpGrpcPort }} + protocol: TCP + - name: otlp-http + containerPort: {{ .Values.server.otlpHttpPort }} + protocol: TCP + # livenessProbe: + # httpGet: + # path: {{ include "qualitytrace.pathPrefix" . }} + # port: http + # readinessProbe: + # httpGet: + # path: {{ include "qualitytrace.pathPrefix" . }} + # port: http + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumeMounts: + - name: config + mountPath: /app/config + {{- if and (not .Values.postgresql.enabled) (.Values.externalPostgresql.qualitytrace.existingSecret) }} + - name: processed-config-volume + mountPath: /processed-config + {{- end}} + volumes: + - name: config + configMap: + name: {{ include "qualitytrace.fullname" . }} + {{- if and (not .Values.postgresql.enabled) (.Values.externalPostgresql.qualitytrace.existingSecret) }} + - name: processed-config-volume + emptyDir: {} + {{- 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/qualitytrace/templates/hpa.yaml b/charts/qualitytrace/templates/hpa.yaml new file mode 100644 index 0000000..0d0d8b7 --- /dev/null +++ b/charts/qualitytrace/templates/hpa.yaml @@ -0,0 +1,28 @@ +{{- if .Values.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "qualitytrace.fullname" . }} + labels: + {{- include "qualitytrace.labels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "qualitytrace.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/charts/qualitytrace/templates/ingress.yaml b/charts/qualitytrace/templates/ingress.yaml new file mode 100644 index 0000000..526bcd7 --- /dev/null +++ b/charts/qualitytrace/templates/ingress.yaml @@ -0,0 +1,61 @@ +{{- if .Values.ingress.enabled -}} +{{- $fullName := include "qualitytrace.fullname" . -}} +{{- $svcPort := .Values.server.httpPort -}} +{{- 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 "qualitytrace.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/qualitytrace/templates/otel-collector-configmap.yaml b/charts/qualitytrace/templates/otel-collector-configmap.yaml new file mode 100644 index 0000000..34124a1 --- /dev/null +++ b/charts/qualitytrace/templates/otel-collector-configmap.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "qualitytrace.fullname" . }}-collector-config +data: + otel-collector-config.yaml: |- + {{- toYaml .Values.otelCollector.config | nindent 4 }} diff --git a/charts/qualitytrace/templates/otel-collector-deployment.yaml b/charts/qualitytrace/templates/otel-collector-deployment.yaml new file mode 100644 index 0000000..d70d0ae --- /dev/null +++ b/charts/qualitytrace/templates/otel-collector-deployment.yaml @@ -0,0 +1,73 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "qualitytrace.fullname" . }}-otel-collector + labels: + {{- include "otelCollector.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + {{- include "otelCollector.selectorLabels" . | nindent 6 }} + template: + metadata: + labels: + {{- include "otelCollector.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.otelCollector.imagePullSecrets }} + imagePullSecrets: + {{- range . }} + - name: {{ . | quote }} + {{- end }} + {{- end }} + priorityClassName: {{ .Values.otelCollector.priorityClassName | quote }} + {{- with .Values.otelCollector.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.otelCollector.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.otelCollector.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.otelCollector.topologySpreadConstraints }} + topologySpreadConstraints: {{ toYaml . | nindent 8 }} + {{- end }} + securityContext: + {{- toYaml .Values.otelCollector.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Values.otelCollector.name }} + image: "{{ .Values.otelCollector.image.repository }}:{{ .Values.otelCollector.image.tag }}" + imagePullPolicy: {{ .Values.otelCollector.image.pullPolicy }} + ports: + - containerPort: {{ .Values.otelCollector.ports.grpc.containerPort }} + name: grpc-otlp + protocol: TCP + - containerPort: {{ .Values.otelCollector.ports.http.containerPort }} + name: http-otlp + protocol: TCP + resources: + requests: + cpu: {{ .Values.otelCollector.resources.requests.cpu }} + memory: {{ .Values.otelCollector.resources.requests.memory }} + args: + {{- if .Values.otelCollector.configMap.create }} + - "--config=/conf/otel-collector-config.yaml" + {{- end }} + {{- with .Values.otelCollector.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + volumeMounts: + - name: otel-collector-config-vol + mountPath: /conf + + volumes: + - name: otel-collector-config-vol + configMap: + items: + - key: otel-collector-config.yaml + path: otel-collector-config.yaml + name: {{ include "qualitytrace.fullname" . }}-collector-config diff --git a/charts/qualitytrace/templates/otel-collector-ingress_route.yaml b/charts/qualitytrace/templates/otel-collector-ingress_route.yaml new file mode 100644 index 0000000..e0db67a --- /dev/null +++ b/charts/qualitytrace/templates/otel-collector-ingress_route.yaml @@ -0,0 +1,26 @@ +{{- if .Values.otelCollector.ingressRoute.enabled -}} +apiVersion: traefik.containo.us/v1alpha1 +kind: IngressRoute +metadata: + name: {{ include "qualitytrace.fullname" . }}-otel-collector + {{- with .Values.otelCollector.ingressRoute.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + entryPoints: + - web + routes: + - kind: Rule + match: Host(`{{ .Values.otelCollector.ingressRoute.host }}`) + services: + - name: {{ include "qualitytrace.fullname" . }}-otel-collector + port: {{ .Values.otelCollector.ingressRoute.service.port }} + scheme: h2c + {{- if .Values.otelCollector.ingressRoute.tls }} + tls: + {{- range .Values.otelCollector.ingressRoute.tls }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} +{{- end }} \ No newline at end of file diff --git a/charts/qualitytrace/templates/otel-collector-service.yaml b/charts/qualitytrace/templates/otel-collector-service.yaml new file mode 100644 index 0000000..998e784 --- /dev/null +++ b/charts/qualitytrace/templates/otel-collector-service.yaml @@ -0,0 +1,23 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "qualitytrace.fullname" . }}-otel-collector + labels: + {{- include "otelCollector.labels" . | nindent 4 }} + {{- with .Values.otelCollector.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: {{ .Values.otelCollector.service.type }} + ports: + - port: {{ .Values.otelCollector.ports.grpc.containerPort }} + targetPort: grpc-otlp + protocol: TCP + name: grpc-otlp + - port: {{ .Values.otelCollector.ports.http.containerPort }} + targetPort: http-otlp + protocol: TCP + name: http-otlp + selector: + {{- include "otelCollector.selectorLabels" . | nindent 4 }} diff --git a/charts/qualitytrace/templates/service.yaml b/charts/qualitytrace/templates/service.yaml new file mode 100644 index 0000000..9b1ca88 --- /dev/null +++ b/charts/qualitytrace/templates/service.yaml @@ -0,0 +1,27 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "qualitytrace.fullname" . }} + labels: + {{- include "qualitytrace.labels" . | nindent 4 }} + {{- with .Values.service.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +spec: + type: {{ .Values.service.type }} + ports: + - port: {{ .Values.server.httpPort }} + targetPort: http + protocol: TCP + name: http + - port: {{ .Values.server.otlpGrpcPort }} + targetPort: otlp-grpc + protocol: TCP + name: otlp-grpc + - port: {{ .Values.server.otlpHttpPort }} + targetPort: otlp-http + protocol: TCP + name: otlp-http + selector: + {{- include "qualitytrace.selectorLabels" . | nindent 4 }} diff --git a/charts/qualitytrace/templates/serviceaccount.yaml b/charts/qualitytrace/templates/serviceaccount.yaml new file mode 100644 index 0000000..3a7e73c --- /dev/null +++ b/charts/qualitytrace/templates/serviceaccount.yaml @@ -0,0 +1,12 @@ +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ include "qualitytrace.serviceAccountName" . }} + labels: + {{- include "qualitytrace.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} diff --git a/charts/qualitytrace/templates/tests/test-connection.yaml b/charts/qualitytrace/templates/tests/test-connection.yaml new file mode 100644 index 0000000..046ec3b --- /dev/null +++ b/charts/qualitytrace/templates/tests/test-connection.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Pod +metadata: + name: "{{ include "qualitytrace.fullname" . }}-test-connection" + labels: + {{- include "qualitytrace.labels" . | nindent 4 }} + annotations: + "helm.sh/hook": test +spec: + containers: + - name: wget + image: busybox + command: ['wget'] + args: ['{{ include "qualitytrace.fullname" . }}:{{ .Values.service.port }}'] + restartPolicy: Never diff --git a/charts/qualitytrace/values.yaml b/charts/qualitytrace/values.yaml new file mode 100644 index 0000000..19b228d --- /dev/null +++ b/charts/qualitytrace/values.yaml @@ -0,0 +1,385 @@ +# Section for configuring the postgres database that will be used by qualitytrace +postgresql: + # For now, this is required to be enabled, otherwise qualitytrace will not + # be able to function properly. + enabled: true + architecture: standalone + image: + registry: ghcr.io + repository: kube-tarian/helmrepo-supporting-tools/postgresql + tag: 16.0.0-debian-11-r13 + + # credentials for accessing the database + auth: + database: "qualitytrace" + username: "qualitytrace" + password: not-secure-database-password + existingSecret: "" + + ## @section Metrics Parameters + metrics: + ## @param metrics.enabled Start a prometheus exporter + enabled: false + ## Prometheus Operator ServiceMonitor configuration + serviceMonitor: + ## @param metrics.serviceMonitor.enabled Create ServiceMonitor Resource for scraping metrics using Prometheus Operator + enabled: false + +# Provisioning allows to define initial settings to be loaded into the database on first run. +# These will only be applied when running qualitytrace against an empty database. If qualitytrace has already +# been configured, the provisioning settings are ignored. +provisioning: + # Datastore is where your application stores its traces. You can define several different datastores with + # different names, however, only one is used by qualitytrace. + type: DataStore + spec: + id: current + name: Signoz + type: signoz + + # type: DataStore + # spec: + # name: Jaeger + # Indicates that this datastore is a jaeger instance + # type: jaeger + # Configures how qualitytrace connects to jaeger. + # jaeger: + # endpoint: jaeger-query:16685 + # tls: + # insecure: true + + +# This section configures the strategy for pooling traces from the trace backend +poolingConfig: + # How long qualitytrace will wait for a complete trace before timing out + # If you have long-running operations that will generate part of your trace, you have + # to change this attribute to be greater than the execution time of your operation. + maxWaitTimeForTrace: 30s + + # How long qualitytrace will wait to retry fetching the trace. If you define it as 5s it means that + # qualitytrace will retrieve the operation trace every 5 seconds and check if it's complete. It will + # do that until the operation times out. + retryDelay: 5s + +# Section for anonymous analytics. If it's enabled, qualitytrace will collect anonymous analytics data +# to help us improving our project. If you don't want to send analytics data, set enabled as false. +analytics: + enabled: true + +# Section to configure how telemetry works in qualitytrace. +telemetry: + # exporters are opentelemetry exporters. It configures how qualitytrace generates and send telemetry to + # a datastore. + exporters: + # This is an exporter called collector, but it could be named anything else. + collector: + # configures the service.name attribute in all trace spans generated by qualitytrace + serviceName: qualitytrace + # indicates the percentage of traces that would be sent to the datastore. 100 = 100% + sampling: 100 + # configures the exporter + exporter: + # qualitytrace sends data using the opentelemetry collector. For now there is no other + # alternative. But the collector is flexible enough to send traces to any other tracing backend + # you might need. + type: collector + collector: + # endpoint to send traces to the collector + endpoint: qualitytrace-otel-collector:4317 + +# Configures the server +server: + # Indicates the port that qualitytrace will run ons + httpPort: 11633 + otlpGrpcPort: 4317 + otlpHttpPort: 4318 + + # Indicates which telemetry components will be used by qualitytrace + telemetry: + # The exporter that qualitytrace will use to send telemetry + exporter: collector + # The exporter that qualitytrace will send the triggering transaction span. This is optional. If you + # want to have the trigger transaction span in your trace, you have to configure this field to + # send the span to the same place your application sends its telemetry. + # applicationExporter: collector + +replicaCount: 1 + +# You don't have to change anything bellow this line. + +image: + repository: ghcr.io/intelops/qualitytrace + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: latest + +env: + qualitytraceDev: "" + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" +serviceAccount: + # Specifies whether a service account should be created + create: false + # 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: "" + +analyzer: + enabled: false + +podAnnotations: {} + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +service: + type: ClusterIP + annotations: {} + +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: 250m + memory: 512Mi + +autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + +nodeSelector: {} + +tolerations: [] + +affinity: {} + + +otelCollector: + name: "otel-collector" + image: + repository: ghcr.io/kube-tarian/helmrepo-supporting-tools/opentelemetry-collector-contrib + tag: 0.79.0 + pullPolicy: Always + + # -- Image Registry Secret Names for OtelCollector + # If set, this has higher precedence than the root level or global value of imagePullSecrets. + imagePullSecrets: [] + + configMap: + # -- Specifies whether a configMap should be created (true by default) + create: true + + # OtelCollector service + service: + # -- Annotations to use by service associated to OtelCollector + annotations: {} + # -- Service Type: LoadBalancer (allows external access) or NodePort (more secure, no extra cost) + type: ClusterIP + + # -- OtelCollector Deployment annotation. + annotations: {} + # -- OtelCollector pod(s) annotation. + podAnnotations: {} + # -- OtelCollector pod(s) labels. + podLabels: {} + + # -- Additional environments to set for OtelCollector + additionalEnvs: {} + # env_key: env_value + + # Configuration for ports + ports: + grpc: + # -- Whether to enable service port for OTLP gRPC + enabled: true + # -- Container port for OTLP gRPC + containerPort: 4317 + # -- Service port for OTLP gRPC + servicePort: 4317 + # -- Node port for OTLP gRPC + nodePort: "" + # -- Protocol to use for OTLP gRPC + protocol: TCP + http: + # -- Whether to enable service port for OTLP HTTP + enabled: true + # -- Container port for OTLP HTTP + containerPort: 4318 + # -- Service port for OTLP HTTP + servicePort: 4318 + # -- Node port for OTLP HTTP + nodePort: "" + # -- Protocol to use for OTLP HTTP + protocol: TCP + + ingressRoute: + enabled: false + annotations: {} + host: "otelcollector.domain.com" + service: + port: 4317 + tls: [] + # - secretName: chart-example-tls + + ingress: + # -- Enable ingress for OtelCollector + enabled: false + # -- Ingress Class Name to be used to identify ingress controllers + className: "" + # -- Annotations to OtelCollector Ingress + annotations: {} + # cert-manager.io/cluster-issuer: letsencrypt-prod + # nginx.ingress.kubernetes.io/ssl-redirect: "true" + # nginx.ingress.kubernetes.io/backend-protocol: "GRPC" + # kubernetes.io/ingress.class: nginx + # kubernetes.io/tls-acme: "true" + # -- OtelCollector Ingress Host names with their path details + hosts: + - host: otelcollector.domain.com + paths: + - path: / + pathType: ImplementationSpecific + port: 4317 + # -- OtelCollector Ingress TLS + tls: [] + # - secretName: chart-example-tls + # hosts: + # - otelcollector.domain.com + + # -- Configure resource requests and limits. Update according to your own use + # case as these values might not be suitable for your workload. + # Ref: http://kubernetes.io/docs/user-guide/compute-resources/ + # + # @default -- See `values.yaml` for defaults + resources: + requests: + cpu: 250m + memory: 512Mi + # limits: + # cpu: "1" + # memory: 2Gi + + # -- OtelCollector priority class name + priorityClassName: "" + # -- Node selector for settings for OtelCollector pod + nodeSelector: {} + # -- Toleration labels for OtelCollector pod assignment + tolerations: [] + # -- Affinity settings for OtelCollector pod + affinity: {} + + podSecurityContext: {} + # fsGroup: 2000 + + securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 11 + targetCPUUtilizationPercentage: 50 + #targetMemoryUtilizationPercentage: 50 + + # -- Configurations for OtelCollector + # @default -- See `values.yaml` for defaults + config: + receivers: + otlp: + protocols: + grpc: + http: + + processors: + batch: + timeout: 100ms + + # Data sources: + probabilistic_sampler: + hash_seed: 22 + sampling_percentage: 100 + + exporters: + # Output logger, used to check OTel Collector sanity + logging: + loglevel: debug + + # OTLP for qualitytrace + otlp/qualitytrace: + endpoint: qualitytrace:4317 + tls: + insecure: true + # OTLP for Signoz + otlp/signoz: + endpoint: signoz-otel-collector:4317 + tls: + insecure: true + + service: + pipelines: + traces: + receivers: [otlp] + processors: [probabilistic_sampler, batch] + exporters: [otlp/signoz, otlp/qualitytrace, logging] + + +externalPostgresql: + host: postgresql + # password for accessing the postgres user. Ignored if existingSecret is set + postgresqlPassword: "" + # -- Name and key of an existing Kubernetes secret object containing the password + existingSecret: {} + # name: + # passwordKey: + + # User and database creation + qualitytrace: + database: "qualitytrace" + username: "qualitytrace" + # password for accessing the database. Ignored if existingSecret is set + password: "" + # -- Name and key of an existing Kubernetes secret object containing the password + existingSecret: {} + # name: + # passwordKey: \ No newline at end of file