Skip to content

Commit

Permalink
Add two ports to service, daemonset and servicemonitor conditionally (#…
Browse files Browse the repository at this point in the history
…1168)

* Add two ports to service, daemonset and servicemonitor conditionally

* Update Helm docs

* Only use 1 port if ports in config are equal

* Change default internal metrics path to /metrics

* Remove .metrics. from Prometheus metrics values
  • Loading branch information
marevers authored Sep 19, 2024
1 parent 5aace7e commit 008f4f2
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 27 deletions.
20 changes: 13 additions & 7 deletions charts/beyla/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# beyla

![Version: 1.4.0](https://img.shields.io/badge/Version-1.4.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.8.0](https://img.shields.io/badge/AppVersion-1.8.0-informational?style=flat-square)
![Version: 1.4.1](https://img.shields.io/badge/Version-1.4.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 1.8.0](https://img.shields.io/badge/AppVersion-1.8.0-informational?style=flat-square)

eBPF-based autoinstrumentation HTTP, HTTP2 and gRPC services, as well as network metrics.

Expand Down Expand Up @@ -55,24 +55,30 @@ eBPF-based autoinstrumentation HTTP, HTTP2 and gRPC services, as well as network
| service.annotations | object | `{}` | Service annotations. |
| service.appProtocol | string | `""` | Adds the appProtocol field to the service. This allows to work with istio protocol selection. Ex: "http" or "tcp" |
| service.clusterIP | string | `""` | cluster IP |
| service.enabled | bool | `false` | whether to create a service for internal metrics |
| service.enabled | bool | `false` | whether to create a service for metrics |
| service.internalMetrics.appProtocol | string | `""` | Adds the appProtocol field to the service. This allows to work with istio protocol selection. Ex: "http" or "tcp" |
| service.internalMetrics.port | int | `8080` | internal metrics service port |
| service.internalMetrics.portName | string | `"internal-metrics"` | name of the port for internal metrics. |
| service.internalMetrics.targetPort | string | `nil` | targetPort overrides the internal metrics port. It defaults to the value of `internal_metrics.prometheus.port` from the Beyla configuration file. |
| service.labels | object | `{}` | Service labels. |
| service.loadBalancerClass | string | `""` | loadbalancer class name |
| service.loadBalancerIP | string | `""` | loadbalancer IP |
| service.loadBalancerSourceRanges | list | `[]` | source ranges for loadbalancer |
| service.port | int | `80` | service port |
| service.portName | string | `"metrics"` | name of the port for internal metrics. |
| service.targetPort | int | `9090` | targetPort has to be configured based on the values of `BEYLA_INTERNAL_METRICS_PROMETHEUS_PORT` environment variable or the value of `prometheus_export.port` from beyla configuration file. see more at https://grafana.com/docs/beyla/latest/configure/options/#internal-metrics-reporter |
| service.port | int | `80` | Prometheus metrics service port |
| service.portName | string | `"metrics"` | name of the port for Prometheus metrics. |
| service.targetPort | string | `nil` | targetPort overrides the Prometheus metrics port. It defaults to the value of `prometheus_export.port` from the Beyla configuration file. |
| service.type | string | `"ClusterIP"` | type of the service |
| 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.labels | object | `{}` | ServiceAccount labels. |
| serviceAccount.name | string | `""` | The name of the service account to use. If not set and create is true, a name is generated using the fullname template |
| serviceMonitor | object | `{"annotations":{},"enabled":false,"endpoint":{"interval":"15s"},"jobLabel":""}` | Enable creation of ServiceMonitor for scraping of prometheus HTTP endpoint |
| serviceMonitor | object | `{"additionalLabels":{},"annotations":{},"enabled":false,"internalMetrics":{"endpoint":{"interval":"15s"}},"jobLabel":"","metrics":{"endpoint":{"interval":"15s"}}}` | Enable creation of ServiceMonitor for scraping of prometheus HTTP endpoint |
| serviceMonitor.additionalLabels | object | `{}` | Add custom labels to the ServiceMonitor resource |
| serviceMonitor.annotations | object | `{}` | ServiceMonitor annotations |
| serviceMonitor.endpoint | object | `{"interval":"15s"}` | ServiceMonitor scraping endpoint. Target port and path is set based on service and prometheus_export values. For additional values, see the ServiceMonitor spec |
| serviceMonitor.internalMetrics.endpoint | object | `{"interval":"15s"}` | ServiceMonitor internal metrics scraping endpoint. Target port and path is set based on service and `internal_metrics` values. For additional values, see the ServiceMonitor spec |
| serviceMonitor.jobLabel | string | `""` | Prometheus job label. If empty, chart release name is used |
| serviceMonitor.metrics.endpoint | object | `{"interval":"15s"}` | ServiceMonitor Prometheus scraping endpoint. Target port and path is set based on service and `prometheus_export` values. For additional values, see the ServiceMonitor spec |
| tolerations | list | `[]` | Tolerations allow pods to be scheduled on nodes with specific taints |
| updateStrategy.type | string | `"RollingUpdate"` | update strategy type |
| volumeMounts | list | `[]` | Additional volumeMounts on the output Deployment definition. |
Expand Down
9 changes: 8 additions & 1 deletion charts/beyla/templates/daemon-set.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,16 @@ spec:
- ALL
{{- end }}
ports:
{{- if or (.Values.service.targetPort) (.Values.config.data.prometheus_export) }}
- name: {{ .Values.service.portName }}
containerPort: {{ .Values.service.targetPort }}
containerPort: {{ .Values.service.targetPort | default .Values.config.data.prometheus_export.port }}
protocol: TCP
{{- end }}
{{- if (and (or (.Values.service.internalMetrics.targetPort) (.Values.config.data.internal_metrics)) (not (eq .Values.config.data.prometheus_export.port .Values.config.data.internal_metrics.prometheus.port))) }}
- name: {{ .Values.service.internalMetrics.portName }}
containerPort: {{ .Values.service.internalMetrics.targetPort | default .Values.config.data.internal_metrics.prometheus.port }}
protocol: TCP
{{- end }}
{{- with .Values.resources }}
resources:
{{- toYaml . | nindent 12 }}
Expand Down
16 changes: 15 additions & 1 deletion charts/beyla/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,30 @@ spec:
externalTrafficPolicy: {{ . }}
{{- end }}
ports:
{{- if or (.Values.service.targetPort) (.Values.config.data.prometheus_export) }}
- name: {{ .Values.service.portName }}
port: {{ .Values.service.port }}
protocol: TCP
targetPort: {{ .Values.service.targetPort }}
targetPort: {{ .Values.service.targetPort | default .Values.config.data.prometheus_export.port }}
{{- with .Values.service.appProtocol }}
appProtocol: {{ . }}
{{- end }}
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }}
nodePort: {{ .Values.service.nodePort }}
{{- end }}
{{- end }}
{{- if (and (or (.Values.service.internalMetrics.targetPort) (.Values.config.data.internal_metrics)) (not (eq .Values.config.data.prometheus_export.port .Values.config.data.internal_metrics.prometheus.port))) }}
- name: {{ .Values.service.internalMetrics.portName }}
port: {{ .Values.service.internalMetrics.port }}
protocol: TCP
targetPort: {{ .Values.service.internalMetrics.targetPort | default .Values.config.data.internal_metrics.prometheus.port }}
{{- with .Values.service.internalMetrics.appProtocol }}
appProtocol: {{ . }}
{{- end }}
{{- if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.internalMetrics.nodePort))) }}
nodePort: {{ .Values.service.internalMetrics.nodePort }}
{{- end }}
{{- end }}
selector:
{{- include "beyla.selectorLabels" . | nindent 4 }}
{{- end }}
10 changes: 10 additions & 0 deletions charts/beyla/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,22 @@ metadata:
{{- end }}
spec:
endpoints:
{{- if or (.Values.service.targetPort) (.Values.config.data.prometheus_export) }}
- port: {{ .Values.service.portName }}
path: {{ .Values.config.data.prometheus_export.path }}
scheme: http
{{- with .Values.serviceMonitor.endpoint }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}
{{- if (and (or (.Values.service.internalMetrics.targetPort) (.Values.config.data.internal_metrics)) (not (eq .Values.config.data.prometheus_export.port .Values.config.data.internal_metrics.prometheus.port))) }}
- port: {{ .Values.service.internalMetrics.portName }}
path: {{ .Values.config.data.internal_metrics.prometheus.path }}
scheme: http
{{- with .Values.serviceMonitor.internalMetrics.endpoint }}
{{- toYaml . | nindent 6 }}
{{- end }}
{{- end }}
jobLabel: {{ .Values.serviceMonitor.jobLabel | default (include "beyla.fullname" .) }}
selector:
matchLabels:
Expand Down
57 changes: 39 additions & 18 deletions charts/beyla/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,19 @@ priorityClassName: ""
# system-node-critical
# system-cluster-critical

## -- Expose the beyla internal metrics service to be accessed from outside the cluster (LoadBalancer service).
## -- Expose the Beyla Prometheus and internal metrics service to be accessed from outside the cluster (LoadBalancer service).
## or access it from within the cluster (ClusterIP service). Set the service type and the port to serve it.
## ref: http://kubernetes.io/docs/user-guide/services/
##
service:
# -- whether to create a service for internal metrics
# -- whether to create a service for metrics
enabled: false
# -- type of the service
type: ClusterIP
# -- Service annotations.
annotations: {}
# -- Service labels.
labels: {}
# -- cluster IP
clusterIP: ""
# -- loadbalancer IP
Expand All @@ -97,20 +101,25 @@ service:
loadBalancerClass: ""
# -- source ranges for loadbalancer
loadBalancerSourceRanges: []
# -- service port
# -- Prometheus metrics service port
port: 80
# -- targetPort has to be configured based on the values of `BEYLA_INTERNAL_METRICS_PROMETHEUS_PORT` environment variable
# or the value of `prometheus_export.port` from beyla configuration file.
# see more at https://grafana.com/docs/beyla/latest/configure/options/#internal-metrics-reporter
targetPort: 9090
# -- Service annotations.
annotations: {}
# -- Service labels.
labels: {}
# -- name of the port for internal metrics.
# -- targetPort overrides the Prometheus metrics port. It defaults to the value of `prometheus_export.port`
# from the Beyla configuration file.
targetPort: null
# -- name of the port for Prometheus metrics.
portName: metrics
# -- Adds the appProtocol field to the service. This allows to work with istio protocol selection. Ex: "http" or "tcp"
appProtocol: ""
internalMetrics:
# -- internal metrics service port
port: 8080
# -- targetPort overrides the internal metrics port. It defaults to the value of `internal_metrics.prometheus.port`
# from the Beyla configuration file.
targetPort: null
# -- name of the port for internal metrics.
portName: internal-metrics
# -- Adds the appProtocol field to the service. This allows to work with istio protocol selection. Ex: "http" or "tcp"
appProtocol: ""

resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
Expand Down Expand Up @@ -208,11 +217,16 @@ config:
k8s_src_owner_name:
not_match: '{kube*,*jaeger-agent*,*prometheus*,*promtail*,*grafana-agent*}'
# to enable network metrics
# network:
# enable: true
# network:
# enable: true
prometheus_export:
port: 9090
path: /metrics
# to enable internal metrics
# internal_metrics:
# prometheus:
# port: 6060
# path: /metrics

## Env variables that will override configmap values
## For example:
Expand Down Expand Up @@ -240,11 +254,18 @@ serviceMonitor:
additionalLabels: {}
# -- ServiceMonitor annotations
annotations: {}
# -- ServiceMonitor scraping endpoint.
# Target port and path is set based on service and prometheus_export values.
metrics:
# -- ServiceMonitor Prometheus scraping endpoint.
# Target port and path is set based on service and `prometheus_export` values.
# For additional values, see the ServiceMonitor spec
endpoint:
interval: 15s
internalMetrics:
# -- ServiceMonitor internal metrics scraping endpoint.
# Target port and path is set based on service and `internal_metrics` values.
# For additional values, see the ServiceMonitor spec
endpoint:
interval: 15s
endpoint:
interval: 15s
# -- Prometheus job label.
# If empty, chart release name is used
jobLabel: ""

0 comments on commit 008f4f2

Please sign in to comment.