From 9fcd758de5b4210a016ad84a2c1483f2584ff16c Mon Sep 17 00:00:00 2001 From: Vitaly Fedorov <37942799+obsessionsys@users.noreply.github.com> Date: Sat, 27 Apr 2024 10:22:43 +0000 Subject: [PATCH] Init the Beyla helm chart Signed-off-by: Vitaly Fedorov Signed-off-by: Vitaly Fedorov <37942799+obsessionsys@users.noreply.github.com> --- charts/beyla/.helmignore | 23 ++++ charts/beyla/Chart.yaml | 28 ++++ charts/beyla/README.md | 50 +++++++ charts/beyla/templates/_helpers.tpl | 62 +++++++++ charts/beyla/templates/configmap.yaml | 17 +++ charts/beyla/templates/daemonset.yaml | 93 +++++++++++++ charts/beyla/templates/rbac.yaml | 30 ++++ charts/beyla/templates/secret.yaml | 26 ++++ charts/beyla/templates/serviceaccount.yaml | 15 ++ charts/beyla/templates/warnings.tpl | 5 + charts/beyla/values.yaml | 151 +++++++++++++++++++++ 11 files changed, 500 insertions(+) create mode 100644 charts/beyla/.helmignore create mode 100644 charts/beyla/Chart.yaml create mode 100644 charts/beyla/README.md create mode 100644 charts/beyla/templates/_helpers.tpl create mode 100644 charts/beyla/templates/configmap.yaml create mode 100644 charts/beyla/templates/daemonset.yaml create mode 100644 charts/beyla/templates/rbac.yaml create mode 100644 charts/beyla/templates/secret.yaml create mode 100644 charts/beyla/templates/serviceaccount.yaml create mode 100644 charts/beyla/templates/warnings.tpl create mode 100644 charts/beyla/values.yaml diff --git a/charts/beyla/.helmignore b/charts/beyla/.helmignore new file mode 100644 index 0000000000..0e8a0eb36f --- /dev/null +++ b/charts/beyla/.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/beyla/Chart.yaml b/charts/beyla/Chart.yaml new file mode 100644 index 0000000000..5fd831f99e --- /dev/null +++ b/charts/beyla/Chart.yaml @@ -0,0 +1,28 @@ +apiVersion: v2 +name: beyla +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: 1.5.2 + +# 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: "1.5.2" + +maintainers: + - name: "Vitaly Fedorov" + email: "obsessionsys@gmail.com" diff --git a/charts/beyla/README.md b/charts/beyla/README.md new file mode 100644 index 0000000000..9e4fee4466 --- /dev/null +++ b/charts/beyla/README.md @@ -0,0 +1,50 @@ +# grafana-beyla + +![Version: 1.5.2](https://img.shields.io/badge/Version-1.5.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.5.2](https://img.shields.io/badge/AppVersion-1.5.2-informational?style=flat-square) + +A Helm chart for Kubernetes + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| Vitaly Fedorov | | | + +## Values + +| Key | Type | Default | Description | +|-----|------|---------|-------------| +| affinity | object | `{}` | Affinity for pod assignment. See: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity | +| annotations | object | `{}` | General annotation for the daemonset | +| config | string | Dynamically generated beyla configmap | Beyla configuration file contents | +| extraEnvs | list | `[]` | Extra environment variables to add | +| fullnameOverride | string | `""` | Overrides the chart's computed fullname | +| hostAliases | list | `[]` | hostAliases to add | +| hostPID | bool | `true` | Mandatory for eBPF probes | +| image.pullPolicy | string | `"IfNotPresent"` | pullPolicy to use for pulling the image | +| image.repository | string | `"grafana/beyla"` | Repository to pull from | +| image.tag | string | `""` | | +| imagePullSecrets | list | `[]` | | +| nameOverride | string | `""` | Overrides the chart's name | +| nodeSelector | object | `{}` | Node labels for pod assignment. See: https://kubernetes.io/docs/user-guide/node-selection/ | +| otlp.endpoint | string | `"http://localhost"` | For correct operation, this endpoint must be installed and point to the opentelemtry collector service or ingress | +| otlp.headers | object | `{}` | Headers for OTLP Collector Example: Authorization=Basic ...rest of the secret header value... | +| otlp.insecure | bool | `false` | | +| otlp.protocol | string | `nil` | Protocol OTLP Collector (http or grpc) | +| podAnnotations | object | `{}` | Pod Annotations | +| podLabels | object | `{}` | Pod (extra) Labels | +| podSecurityContext | object | `{}` | podSecurityContext | +| resources | object | `{}` | | +| securityContext.privileged | bool | `true` | Defaults to privileged = true | +| securityContext.readOnlyRootFilesystem | bool | `true` | | +| serviceAccount.annotations | object | `{}` | Annotations to add to the service account | +| serviceAccount.automount | bool | `true` | Automatically mount a ServiceAccount's API credentials? | +| serviceAccount.create | bool | `true` | Specifies whether a service account should be created | +| serviceAccount.name | string | `""` | If not set and create is true, a name is generated using the fullname template | +| terminationMessagePolicy | string | `nil` | See https://kubernetes.io/docs/tasks/debug/debug-application/determine-reason-pod-failure/ | +| tolerations | list | `[]` | Tolerations for pod assignment. See: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ | +| volumeMounts | list | `[]` | Additional volumeMounts on the output Deployment definition. | +| volumes | list | `[]` | Additional volumes on the output Deployment definition. | + +---------------------------------------------- +Autogenerated from chart metadata using [helm-docs v1.8.1](https://github.com/norwoodj/helm-docs/releases/v1.8.1) diff --git a/charts/beyla/templates/_helpers.tpl b/charts/beyla/templates/_helpers.tpl new file mode 100644 index 0000000000..7ba5edc272 --- /dev/null +++ b/charts/beyla/templates/_helpers.tpl @@ -0,0 +1,62 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "chart.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 "chart.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 "chart.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "chart.labels" -}} +helm.sh/chart: {{ include "chart.chart" . }} +{{ include "chart.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "chart.selectorLabels" -}} +app.kubernetes.io/name: {{ include "chart.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{/* +Create the name of the service account to use +*/}} +{{- define "chart.serviceAccountName" -}} +{{- if .Values.serviceAccount.create }} +{{- default (include "chart.fullname" .) .Values.serviceAccount.name }} +{{- else }} +{{- default "default" .Values.serviceAccount.name }} +{{- end }} +{{- end }} diff --git a/charts/beyla/templates/configmap.yaml b/charts/beyla/templates/configmap.yaml new file mode 100644 index 0000000000..a6165b8e24 --- /dev/null +++ b/charts/beyla/templates/configmap.yaml @@ -0,0 +1,17 @@ +{{- $fullName := include "chart.fullname" . -}} +{{- $name := "beyla" -}} +{{- $data := dict "name" $name "Chart" .Chart "Release" .Release "Values" .Values -}} +apiVersion: v1 +kind: ConfigMap +metadata: + namespace: {{ .Release.Namespace }} + name: {{ $fullName }}-{{ $name }}-config + labels: + {{- include "chart.labels" $data | nindent 4 }} + annotations: + {{- if .Values.annotations }} + {{- toYaml .Values.annotations | nindent 4 }} + {{- end }} +data: + beyla-config.yml: | +{{- .Values.config | nindent 6 }} diff --git a/charts/beyla/templates/daemonset.yaml b/charts/beyla/templates/daemonset.yaml new file mode 100644 index 0000000000..5f5e33d5db --- /dev/null +++ b/charts/beyla/templates/daemonset.yaml @@ -0,0 +1,93 @@ +{{- $fullName := include "chart.fullname" . -}} +{{- $serviceAccountName := include "chart.serviceAccountName" . -}} +{{- $name := "beyla" -}} +{{- $data := dict "name" $name "Chart" .Chart "Release" .Release "Values" .Values -}} +--- +apiVersion: apps/v1 +kind: DaemonSet +metadata: + namespace: {{ .Release.Namespace }} + name: {{ $fullName }}-{{ $name }} + labels: + {{- include "chart.labels" $data | nindent 4 }} + {{- if .Values.podAnnotations -}} + annotations: + {{- toYaml .Values.podAnnotations | nindent 4 }} + {{- end }} +spec: + selector: + matchLabels: + {{- include "chart.selectorLabels" $data | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations -}} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "chart.selectorLabels" $data | nindent 8 }} + spec: + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{ toYaml . | indent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.hostAliases }} + hostAliases: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "chart.serviceAccountName" . }} + hostPID: {{ .Values.hostPID }} + containers: + - name: beyla + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.terminationMessagePolicy }} + terminationMessagePolicy: {{ .Values.terminationMessagePolicy }} + {{- end }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + volumeMounts: + - mountPath: /config + name: beyla-config + - mountPath: /var/run/beyla + name: var-run-beyla + {{- with .Values.volumeMounts }} + {{- toYaml . | nindent 12 }} + {{- end }} + env: + - name: BEYLA_CONFIG_PATH + value: "/config/beyla-config.yml" + - name: OTEL_EXPORTER_OTLP_ENDPOINT + valueFrom: + secretKeyRef: + name: {{ $fullName }}-{{ $name }}-credentials + key: otlp-endpoint + {{- if .Values.otlp.headers }} + - name: OTEL_EXPORTER_OTLP_HEADERS + valueFrom: + secretKeyRef: + name: {{ $fullName }}-{{ $name }}-credentials + key: otlp-headers + {{- end }} + {{- if .Values.extraEnvs -}} + {{- toYaml .Values.extraEnvs | nindent 12 }} + {{- end }} + resources: + {{- toYaml .Values.resources | nindent 12 }} + volumes: + - name: beyla-config + configMap: + name: {{ $fullName }}-{{ $name }}-config + - name: var-run-beyla + emptyDir: {} + {{- with .Values.volumes }} + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/charts/beyla/templates/rbac.yaml b/charts/beyla/templates/rbac.yaml new file mode 100644 index 0000000000..234499e944 --- /dev/null +++ b/charts/beyla/templates/rbac.yaml @@ -0,0 +1,30 @@ +{{- $fullName := include "chart.fullname" . -}} +{{- $serviceAccountName := include "chart.serviceAccountName" . -}} +{{- $name := "beyla" -}} +{{- $data := dict "name" $name "Chart" .Chart "Release" .Release "Values" .Values -}} +{{- if .Values.serviceAccount.create -}} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ $fullName }}-{{ $name }}-role +rules: + - apiGroups: ["apps"] + resources: ["replicasets"] + verbs: ["list", "watch"] + - apiGroups: [""] + resources: ["pods"] + verbs: ["list", "watch"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ $fullName }}-{{ $name }}-role-binding +subjects: + - kind: ServiceAccount + name: {{ $serviceAccountName }} + namespace: {{ .Release.Namespace }} +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ $fullName }}-{{ $name }}-role +{{- end }} \ No newline at end of file diff --git a/charts/beyla/templates/secret.yaml b/charts/beyla/templates/secret.yaml new file mode 100644 index 0000000000..9b58a98d57 --- /dev/null +++ b/charts/beyla/templates/secret.yaml @@ -0,0 +1,26 @@ +{{- $fullName := include "chart.fullname" . -}} +{{- $name := "beyla" -}} +{{- $data := dict "name" $name "Chart" .Chart "Release" .Release "Values" .Values -}} +apiVersion: v1 +kind: Secret +metadata: + name: {{ $fullName }}-{{ $name }}-credentials + namespace: {{ .Release.Namespace }} + labels: + {{- include "chart.labels" $data | nindent 4 }} + annotations: + {{- if .Values.annotations }} + {{- toYaml .Values.annotations | nindent 4 }} + {{- end }} +type: Opaque +stringData: + otlp-endpoint: {{ .Values.otlp.endpoint | quote }} +{{- if .Values.otlp.protocol -}} + otlp-protocol: {{ .Values.otlp.protocol | quote }} +{{- end }} +{{- if .Values.otlp.insecure -}} + otlp-insecure: "true" +{{- end }} +{{- if .Values.otlp.headers -}} + otlp-headers: {{ .Values.otlp.headers | quote }} +{{- end }} \ No newline at end of file diff --git a/charts/beyla/templates/serviceaccount.yaml b/charts/beyla/templates/serviceaccount.yaml new file mode 100644 index 0000000000..48b794bb05 --- /dev/null +++ b/charts/beyla/templates/serviceaccount.yaml @@ -0,0 +1,15 @@ +{{- $serviceAccountName := include "chart.serviceAccountName" . -}} +{{- if .Values.serviceAccount.create -}} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ $serviceAccountName }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "chart.labels" . | nindent 4 }} + {{- with .Values.serviceAccount.annotations }} + annotations: + {{- toYaml . | nindent 4 }} + {{- end }} +automountServiceAccountToken: {{ .Values.serviceAccount.automount }} +{{- end }} diff --git a/charts/beyla/templates/warnings.tpl b/charts/beyla/templates/warnings.tpl new file mode 100644 index 0000000000..8aeaff4f2e --- /dev/null +++ b/charts/beyla/templates/warnings.tpl @@ -0,0 +1,5 @@ +{{/* this file is for generating warnings about incorrect usage of the chart */}} + +{{- if not .Values.otlp.endpoint }} + {{ fail ".Values.otlp.endpoint must be set" }} +{{- end }} \ No newline at end of file diff --git a/charts/beyla/values.yaml b/charts/beyla/values.yaml new file mode 100644 index 0000000000..21b83b1632 --- /dev/null +++ b/charts/beyla/values.yaml @@ -0,0 +1,151 @@ +# Default values for grafana-beyla. +# This is a YAML-formatted file. +# Declare variables to be passed into your templates. + +image: + # -- Repository to pull from + repository: grafana/beyla + # -- pullPolicy to use for pulling the image + pullPolicy: IfNotPresent + # Overrides the image tag whose default is the chart appVersion. + tag: "" + +## -- Optionally specify an array of imagePullSecrets. +## Secrets must be manually created in the namespace. +## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/ +imagePullSecrets: [] + +# -- Overrides the chart's name +nameOverride: "" + +# -- Overrides the chart's computed fullname +fullnameOverride: "" + +serviceAccount: + # -- Specifies whether a service account should be created + create: true + # -- 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: "" + +# -- Pod Annotations +podAnnotations: {} +# -- Pod (extra) Labels +podLabels: {} + +# -- See https://kubernetes.io/docs/tasks/debug/debug-application/determine-reason-pod-failure/ +terminationMessagePolicy: ~ + # FallbackToLogsOnError + +# -- Mandatory for eBPF probes +hostPID: true + +# -- podSecurityContext +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: + # -- Defaults to privileged = true + privileged: true + readOnlyRootFilesystem: true + + # -- Custom to eBPF CAPABILITIES + # runAsUser: 0 + # readOnlyRootFilesystem: true + # capabilities: + # add: + # - SYS_ADMIN # <-- Important. Required for most eBPF probes to function correctly. + # - SYS_PTRACE # <-- Important. Allows Beyla to access the container namespaces and inspect executables. + # #- SYS_RESOURCE # <-- pre 5.11 kenrel only. Allows Beyla to increase the amount of locked memory. + +# service: +# type: ClusterIP +# port: 80 + +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 + +# -- OpenTelemetry collector configuration +otlp: + # -- Endpoint OTLP Collector + # -- For correct operation, this endpoint must be installed and point to the opentelemtry collector service or ingress + endpoint: http://localhost + # -- Protocol OTLP Collector (http or grpc) + protocol: ~ + # Insecure (true or false) + insecure: false + # -- Headers for OTLP Collector + # Example: Authorization=Basic ...rest of the secret header value... + headers: {} + +# -- Beyla configuration file contents +# @default -- Dynamically generated beyla configmap +config: | + # @default -- Dynamically generated beyla configmap + # this is required to enable kubernetes discovery and metadata + attributes: + kubernetes: + enable: true + # this will provide automatic routes report while minimizing cardinality + routes: + unmatched: heuristic + # let's instrument only the docs server + discovery: + services: + - k8s_deployment_name: "^docs$" + # uncomment the following line to also instrument the website server + # - k8s_deployment_name: "^website$" + +# -- Extra environment variables to add +extraEnvs: [] + # - name: BEYLA_PRINT_TRACES + # value: "true" + # - name: BEYLA_KUBE_METADATA_ENABLE + # value: "autodetect" + +# -- Additional volumes on the output Deployment definition. +volumes: [] + # - name: cgroup + # hostPath: + # path: /sys/fs/cgroup + +# -- Additional volumeMounts on the output Deployment definition. +volumeMounts: [] + # - name: cgroup + # mountPath: /sys/fs/cgroup + +# -- Node labels for pod assignment. See: https://kubernetes.io/docs/user-guide/node-selection/ +nodeSelector: {} + +# -- Tolerations for pod assignment. See: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ +tolerations: [] + # - effect: NoSchedule + # operator: Exists + # - effect: NoExecute + # operator: Exists + +# -- Affinity for pod assignment. See: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity +affinity: {} + +# -- General annotation for the daemonset +annotations: {} + +# -- hostAliases to add +hostAliases: [] +# - ip: 1.2.3.4 +# hostnames: +# - domain.tld +