From 05fa0f6e94c112c16de6bffa42222267e34a97ba Mon Sep 17 00:00:00 2001 From: Hermawan Wijaya Date: Mon, 9 Oct 2023 17:26:01 +0700 Subject: [PATCH] feat: add otelcollector support for meteor (#54) Co-authored-by: Hermawan Wijaya --- stable/meteor/Chart.yaml | 4 +- stable/meteor/templates/cronjob.yaml | 70 +++++++++++++++++-- .../templates/otelcollector-configmap.yaml | 13 ++++ stable/meteor/values.yaml | 19 +++++ 4 files changed, 98 insertions(+), 8 deletions(-) create mode 100644 stable/meteor/templates/otelcollector-configmap.yaml diff --git a/stable/meteor/Chart.yaml b/stable/meteor/Chart.yaml index 14cba333..9bdcb76a 100644 --- a/stable/meteor/Chart.yaml +++ b/stable/meteor/Chart.yaml @@ -1,5 +1,5 @@ apiVersion: v1 -version: 0.3.0 +version: 0.3.1 description: A Helm chart for Meteor (github.com/goto/meteor) name: meteor -appVersion: "v0.8.0" +appVersion: "v0.8.9" diff --git a/stable/meteor/templates/cronjob.yaml b/stable/meteor/templates/cronjob.yaml index f74faa09..0ea0072e 100644 --- a/stable/meteor/templates/cronjob.yaml +++ b/stable/meteor/templates/cronjob.yaml @@ -26,16 +26,15 @@ spec: image: "{{ required `image.repository is required` .Values.image.repository }}:{{ .Values.image.tag }}" imagePullPolicy: {{ .Values.image.pullPolicy }} command: - {{- if .Values.telegraf.enabled }} - /bin/sh - -c - | meteor run /opt/recipes; + {{- if .Values.telegraf.enabled }} pkill -SIGTERM telegraf - {{- else}} - - meteor - - run - - /opt/recipes + {{- end }} + {{- if .Values.otelcollector.enabled }} + pkill -SIGTERM otelcol-contrib {{- end }} volumeMounts: - name: "{{ include "meteor.name" . }}-volume" @@ -51,6 +50,58 @@ spec: - secretRef: name: "{{ include "meteor.name" . }}-secret" {{- end }} + {{- if .Values.otelcollector.enabled }} + - name: otel-collector-sidecar + image: {{ .Values.otelcollector.image }} + imagePullPolicy: IfNotPresent + args: + - "--config=/etc/otelcollector/config.yaml" + ports: + - containerPort: 1888 + name: pprof + protocol: TCP + - containerPort: 8888 + name: prometheusself + protocol: TCP + - containerPort: 8889 + name: prometheus + protocol: TCP + - containerPort: 13133 + name: healthcheck + protocol: TCP + - containerPort: 4317 + name: otlpgrpcrecv + protocol: TCP + - containerPort: 4318 + name: otlphttprecv + protocol: TCP + - containerPort: 55679 + name: zpages + protocol: TCP + env: + - name: K8S_NODE_NAME + valueFrom: + fieldRef: + fieldPath: spec.nodeName + - name: K8S_POD_NAME + valueFrom: + fieldRef: + fieldPath: metadata.name + - name: K8S_POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + - name: K8S_POD_IP + valueFrom: + fieldRef: + fieldPath: status.podIP + - name: OTEL_RESOURCE_ATTRIBUTES + value: | + k8s.deployment.name={{ include "meteor.name" . }},k8s.namespace.name=$(K8S_POD_NAMESPACE),k8s.node.name=$(K8S_NODE_NAME),k8s.pod.name=$(K8S_POD_NAME),k8s.pod.ip=$(K8S_POD_IP) + volumeMounts: + - name: otelcollector-conf + mountPath: /etc/otelcollector/ + {{- end }} {{- if .Values.telegraf.enabled }} - name: telegraf-sidecar image: {{ .Values.telegraf.image }} @@ -70,8 +121,10 @@ spec: volumeMounts: - name: telegraf-conf mountPath: /etc/telegraf/ - shareProcessNamespace: true {{- end }} + {{- if or .Values.telegraf.enabled .Values.otelcollector.enabled }} + shareProcessNamespace: true + {{- end}} restartPolicy: Never volumes: - name: "{{ include "meteor.name" . }}-volume" @@ -94,3 +147,8 @@ spec: configMap: name: {{ include "meteor.name" . }}-telegraf {{- end }} + {{- if .Values.otelcollector.enabled }} + - name: otelcollector-conf + configMap: + name: {{ include "meteor.name" . }}-otelcollector + {{- end }} diff --git a/stable/meteor/templates/otelcollector-configmap.yaml b/stable/meteor/templates/otelcollector-configmap.yaml new file mode 100644 index 00000000..8cccea25 --- /dev/null +++ b/stable/meteor/templates/otelcollector-configmap.yaml @@ -0,0 +1,13 @@ +{{- if .Values.otelcollector.enabled -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "meteor.name" . }}-otelcollector + labels: +{{- if .Values.labels }} +{{ toYaml .Values.labels | indent 4 }} +{{- end }} +data: + config.yaml: |- +{{ .Values.otelcollector.config | indent 4 }} +{{- end }} diff --git a/stable/meteor/values.yaml b/stable/meteor/values.yaml index 6ecbc700..31f372a8 100644 --- a/stable/meteor/values.yaml +++ b/stable/meteor/values.yaml @@ -32,3 +32,22 @@ telegraf: args: command: - telegraf + +otelcollector: + enabled: false + image: otel/opentelemetry-collector-contrib:0.79.0 + config: | + receivers: + otlp: + protocols: + grpc: + http: + processors: + exporters: + logging: + service: + pipelines: + traces: + receivers: [otlp] + processors: [] + exporters: [logging]