Skip to content

Commit

Permalink
feat(signoz-otel-gateway): add signoz-otel-gateway chart (#480)
Browse files Browse the repository at this point in the history
#### Features

- Add `signoz-otel-gateway` chart
  • Loading branch information
grandwizard28 authored Aug 8, 2024
1 parent 5ac01ff commit c2c12a4
Show file tree
Hide file tree
Showing 15 changed files with 745 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ jobs:
if: steps.list-changed.outputs.changed == 'true'

- name: Run chart-testing (install)
run: ct install --config ct.yaml --helm-extra-set-args --set=presets.otlpExporter.enabled=false,presets.loggingExporter.enabled=true
run: ct install --config ct.yaml
if: steps.list-changed.outputs.changed == 'true'
2 changes: 1 addition & 1 deletion charts/k8s-infra/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: k8s-infra
description: Helm chart for collecting metrics and logs in K8s
type: application
version: 0.11.8
version: 0.11.9
appVersion: "0.88.0"
home: https://signoz.io
icon: https://signoz.io/img/SigNozLogo-orange.svg
Expand Down
4 changes: 2 additions & 2 deletions charts/k8s-infra/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ namespace: ""
# -- Presets to easily set up OtelCollector configurations.
presets:
loggingExporter:
enabled: false
enabled: true
# Verbosity of the logging export: basic, normal, detailed
verbosity: basic
# Number of messages initially logged each second
samplingInitial: 2
# Sampling rate after the initial messages are logged
samplingThereafter: 500
otlpExporter:
enabled: true
enabled: false
logsCollection:
enabled: true
startAt: beginning
Expand Down
23 changes: 23 additions & 0 deletions charts/signoz-otel-gateway/.helmignore
Original file line number Diff line number Diff line change
@@ -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/
6 changes: 6 additions & 0 deletions charts/signoz-otel-gateway/Chart.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies:
- name: postgresql
repository: https://charts.bitnami.com/bitnami
version: 15.0.0
digest: sha256:565cf5a1350794bca648c3f1e3dd374908e478fc9994caeae4564d72220e56bb
generated: "2024-06-06T21:47:55.218828+05:30"
20 changes: 20 additions & 0 deletions charts/signoz-otel-gateway/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v2
name: signoz-otel-gateway
description: A Helm chart for deploying SigNoz Opentelemetry Gateway
type: application
version: 0.0.1
appVersion: "v0.0.16"
home: https://signoz.io/
icon: https://signoz.io/img/SigNozLogo-orange.svg
dependencies:
- name: postgresql
version: 15.0.0
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
maintainers:
- name: SigNoz
email: [email protected]
url: https://signoz.io
- name: prashant-shahi
email: [email protected]
url: https://prashantshahi.dev
193 changes: 193 additions & 0 deletions charts/signoz-otel-gateway/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "signoz-otel-gateway.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 "signoz-otel-gateway.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 "signoz-otel-gateway.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "signoz-otel-gateway.labels" -}}
helm.sh/chart: {{ include "signoz-otel-gateway.chart" . }}
{{ include "signoz-otel-gateway.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "signoz-otel-gateway.selectorLabels" -}}
app.kubernetes.io/name: {{ include "signoz-otel-gateway.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "signoz-otel-gateway.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "signoz-otel-gateway.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Create a list of all ports
*/}}
{{- define "signoz-otel-gateway.ports" -}}
{{- $serviceType := deepCopy .Values.service.type -}}
{{- $ports := deepCopy .Values.service.ports -}}
{{- range $key, $port := $ports -}}
{{- if $port.enabled }}
- name: {{ $key }}
port: {{ $port.servicePort }}
targetPort: {{ $key }}
protocol: {{ $port.protocol }}
{{- if (eq $serviceType "ClusterIP") }}
nodePort: null
{{- else if (eq $serviceType "NodePort") }}
nodePort: {{ $port.nodePort }}
{{- end }}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Create config map
*/}}
{{- define "signoz-otel-gateway.config" -}}
{{- $config := omit .Values.config "create" -}}
{{- range $key, $value := $config }}
{{- $fmted := $value | toString }}
{{- if not (eq $fmted "") }}
{{ $key }}: {{ $fmted | toYaml }}
{{- end }}
{{- end }}
{{- end -}}


{{- define "secretkeyref" -}}
valueFrom:
secretKeyRef:
name: {{ .name }}
key: {{ .key }}
{{- end -}}

{{- define "fieldkeyref" -}}
valueFrom:
fieldRef:
apiVersion: v1
fieldPath: {{ .path }}
{{- end -}}

{{/*
Create env
*/}}
{{- define "signoz-otel-gateway.env" -}}
{{/*
====== GENERATED ENVIRONMENT VARIABLES ======
*/}}
{{- $genEnv := dict -}}
{{- $_ := set $genEnv "SIGNOZ_COMPONENT" "signoz-otel-gateway" -}}
{{- $_ := set $genEnv "OTEL_SERVICE_NAME" "signoz-otel-gateway" -}}
{{- $_ := set $genEnv "OTEL_RESOURCE_ATTRIBUTES" "signoz.component=$(SIGNOZ_COMPONENT),k8s.pod.uid=$(K8S_POD_UID),k8s.pod.ip=$(K8S_POD_IP)" -}}
{{/*
====== FIELD ENVIRONMENT VARIABLES ======
*/}}
{{- $fieldEnv := dict -}}
{{- range $key, $value := (dict "K8S_NODE_NAME" "spec.nodeName" "K8S_POD_IP" "status.podIP" "K8S_POD_NAME" "metadata.name" "K8S_POD_UID" "metadata.uid" "K8S_NAMESPACE" "metadata.namespace") -}}
{{- $_ := set $fieldEnv $key (include "fieldkeyref" (dict "path" $value)) -}}
{{- end -}}

{{/*
====== SECRET ENVIRONMENT VARIABLES ======
*/}}
{{- $prefix := (include "signoz-otel-gateway.fullname" .) }}
{{- $secretEnv := dict -}}
{{- if .Values.externalSecrets.create -}}
{{- range $key, $value := .Values.externalSecrets.secrets -}}
{{- if $value.env -}}
{{- range $ikey, $ivalue := $value.env -}}
{{- $_ := set $secretEnv (upper (printf "OTELGATEWAY_%s" $ikey)) (include "secretkeyref" (dict "name" (printf "%s-%s" $prefix $key) "key" $ivalue)) -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{/*
====== USER ENVIRONMENT VARIABLES ======
*/}}
{{- $userEnv := dict -}}
{{- range $key, $val := .Values.env }}
{{- $upper := upper $key -}}
{{- $var := printf "OTELGATEWAY_%s" $upper -}}
{{- $_ := set $userEnv $var $val -}}
{{- end -}}

{{/*
====== MERGE AND RENDER ENV BLOCK ======
*/}}

{{- $completeEnv := mergeOverwrite $genEnv $fieldEnv $userEnv $secretEnv -}}
{{- template "signoz-otel-gateway.renderEnv" $completeEnv -}}

{{- end -}}

{{/*
Given a dictionary of variable=value pairs including value and valueFrom, render a container env block.
Environment variables are sorted alphabetically
*/}}
{{- define "signoz-otel-gateway.renderEnv" -}}

{{- $dict := . -}}

{{- range keys . | sortAlpha }}
{{- $val := pluck . $dict | first -}}
{{- $valueType := printf "%T" $val -}}
{{ if eq $valueType "map[string]interface {}" }}
- name: {{ . }}
{{ toYaml $val | indent 2 -}}
{{- else if eq $valueType "string" }}
{{- if regexMatch "valueFrom" $val }}
- name: {{ . }}
{{ $val | indent 2 }}
{{- else }}
- name: {{ . }}
value: {{ $val | quote }}
{{- end }}
{{- else }}
- name: {{ . }}
value: {{ $val | quote }}
{{- end }}
{{- end -}}

{{- end -}}
11 changes: 11 additions & 0 deletions charts/signoz-otel-gateway/templates/config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- if .Values.config.create }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "signoz-otel-gateway.fullname" . }}
labels:
{{- include "signoz-otel-gateway.labels" . | nindent 4 }}
data:
config.yaml: |-
{{- omit .Values.config "create" | toYaml | nindent 4 }}
{{- end }}
100 changes: 100 additions & 0 deletions charts/signoz-otel-gateway/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "signoz-otel-gateway.fullname" . }}
labels:
{{- include "signoz-otel-gateway.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "signoz-otel-gateway.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/config.yaml") . | sha256sum }}
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "signoz-otel-gateway.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "signoz-otel-gateway.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
initContainers:
- name: migrate
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command:
- /usr/local/bin/otelgateway
args:
- migrate
env:
{{- include "signoz-otel-gateway.env" . | nindent 12 }}
containers:
- name: gateway
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
{{- range $key, $port := .Values.service.ports }}
{{- if $port.enabled }}
- name: {{ $key }}
containerPort: {{ $port.containerPort }}
protocol: {{ $port.protocol }}
{{- end }}
{{- end }}
command:
- /usr/local/bin/otelgateway
args:
- collector
{{- if .Values.config.create }}
- --config=file:/conf/config.yaml
{{- end }}
{{- range .Values.args }}
- {{ . | quote }}
{{- end }}
env:
{{- include "signoz-otel-gateway.env" . | nindent 12 }}
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
{{- if .Values.config.create }}
- name: config
mountPath: /conf
{{- end }}
{{- with .Values.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ include "signoz-otel-gateway.fullname" . }}
{{- 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 }}
Loading

0 comments on commit c2c12a4

Please sign in to comment.