Skip to content

Commit 42b5210

Browse files
committed
Merge branch 'feat/monitor-event' into 'master'
feat(QOV-964): update helm chart + add monitoring part See merge request qovery/backend/k8s-event-logger!5
2 parents 1ada22b + 4744414 commit 42b5210

File tree

9 files changed

+224
-70
lines changed

9 files changed

+224
-70
lines changed

chart/Chart.yaml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,26 @@
11
apiVersion: v1
2-
appVersion: "2.3"
3-
version: "1.2.2"
4-
description: A tool to log k8s events to stdout in JSON
2+
appVersion: "2.1"
3+
description: 'This chart runs a pod that simply watches Kubernetes Events and logs
4+
them to stdout in JSON to be collected and stored by your logging solution, e.g.
5+
[fluentd](https://github.com/helm/charts/tree/master/stable/fluentd) or [fluent-bit](https://github.com/helm/charts/tree/master/stable/fluent-bit). https://github.com/max-rocket-internet/k8s-event-logger Events
6+
in Kubernetes log very important information. If are trying to understand what happened
7+
in the past then these events show clearly what your Kubernetes cluster was thinking
8+
and doing. Some examples: - Pod events like failed probes, crashes, scheduling
9+
related information like `TriggeredScaleUp` or `FailedScheduling` - HorizontalPodAutoscaler
10+
events like scaling up and down - Deployment events like scaling in and out of ReplicaSets
11+
- Ingress events like create and update The problem is that these events are simply
12+
API objects in Kubernetes and are only stored for about 1 hour. Without some way
13+
of storing these events, debugging a problem in the past very tricky. '
514
home: https://github.com/max-rocket-internet/k8s-event-logger
6-
name: k8s-event-logger
7-
maintainers:
8-
- name: max-rocket-internet
9-
10-
engine: gotpl
1115
icon: https://github.com/kubernetes/kubernetes/raw/master/logo/logo.png
1216
keywords:
1317
- events
1418
- logging
15-
- auditing
19+
- Auditing
20+
maintainers:
21+
22+
name: max-rocket-internet
23+
name: k8s-event-logger
1624
sources:
1725
- https://github.com/max-rocket-internet/k8s-event-logger
26+
version: 1.1.8

chart/README.md

Lines changed: 77 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,91 @@
11
# k8s-event-logger
22

3-
This chart installs [github.com/max-rocket-internet/k8s-event-logger](https://github.com/max-rocket-internet/k8s-event-logger).
3+
![Version: 1.1.8](https://img.shields.io/badge/Version-1.1.8-informational?style=flat-square) ![AppVersion: 2.1](https://img.shields.io/badge/AppVersion-2.1-informational?style=flat-square)
44

5-
## Prerequisites
5+
This chart runs a pod that simply watches Kubernetes Events and logs them to stdout in JSON to be collected and stored by your logging solution, e.g. [fluentd](https://github.com/helm/charts/tree/master/stable/fluentd) or [fluent-bit](https://github.com/helm/charts/tree/master/stable/fluent-bit).
66

7-
- Kubernetes 1.23+
7+
https://github.com/max-rocket-internet/k8s-event-logger
88

9-
## Installing the Chart
9+
Events in Kubernetes log very important information. If are trying to understand what happened in the past then these events show clearly what your Kubernetes cluster was thinking and doing. Some examples:
1010

11-
To install the chart with the release name `my-release` and default configuration:
11+
- Pod events like failed probes, crashes, scheduling related information like `TriggeredScaleUp` or `FailedScheduling`
12+
- HorizontalPodAutoscaler events like scaling up and down
13+
- Deployment events like scaling in and out of ReplicaSets
14+
- Ingress events like create and update
1215

13-
```sh
14-
helm install my-release ./chart
16+
The problem is that these events are simply API objects in Kubernetes and are only stored for about 1 hour. Without some way of storing these events, debugging a problem in the past very tricky.
17+
18+
**Homepage:** <https://github.com/max-rocket-internet/k8s-event-logger>
19+
20+
## How to install this chart
21+
22+
Add Delivery Hero public chart repo:
23+
24+
```console
25+
helm repo add deliveryhero https://charts.deliveryhero.io/
1526
```
1627

17-
## Uninstalling the Chart
28+
A simple install with default values:
29+
30+
```console
31+
helm install deliveryhero/k8s-event-logger
32+
```
33+
34+
To install the chart with the release name `my-release`:
35+
36+
```console
37+
helm install my-release deliveryhero/k8s-event-logger
38+
```
1839

19-
To delete the chart:
40+
To install with some set values:
2041

21-
```sh
22-
helm delete my-release
42+
```console
43+
helm install my-release deliveryhero/k8s-event-logger --set values_key1=value1 --set values_key2=value2
2344
```
2445

25-
## Configuration
26-
27-
The following table lists the configurable parameters for this chart and their default values.
28-
29-
| Parameter | Description | Default |
30-
| -------------------------|--------------------------------------|--------------------------------------------------------|
31-
| `resources` | Resources for the overprovision pods | `{}` |
32-
| `image.repository` | Image repository | `maxrocketinternet/k8s-event-logger` |
33-
| `image.tag` | Image tag | `2.3` |
34-
| `image.pullPolicy` | Container pull policy | `IfNotPresent` |
35-
| `affinity` | Map of node/pod affinities | `{}` |
36-
| `nodeSelector` | Node labels for pod assignment | `{}` |
37-
| `annotations` | Optional deployment annotations | `{}` |
38-
| `fullnameOverride` | Override the fullname of the chart | `nil` |
39-
| `nameOverride` | Override the name of the chart | `nil` |
40-
| `tolerations` | Optional deployment tolerations | `[]` |
41-
| `podLabels` | Additional labels to use for pods | `{}` |
42-
| `env.KUBERNETES_API_URL` | URL of the k8s API in your cluster | `https://172.20.0.1:443` |
43-
| `env.CA_FILE` | Path to the service account CA file | `/var/run/secrets/kubernetes.io/serviceaccount/ca.crt` |
44-
| `podLabels` | Additional labels to use for pods | `{}` |
45-
46-
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install` or provide a YAML file containing the values for the above parameters:
47-
48-
```sh
49-
helm install --name my-release stable/k8s-event-logger --values values.yaml
46+
To install with custom values file:
47+
48+
```console
49+
helm install my-release deliveryhero/k8s-event-logger -f values.yaml
5050
```
51+
52+
## Source Code
53+
54+
* <https://github.com/max-rocket-internet/k8s-event-logger>
55+
56+
## Values
57+
58+
| Key | Type | Default | Description |
59+
|-----|------|---------|-------------|
60+
| affinity | object | `{}` | |
61+
| annotations | object | `{}` | |
62+
| args | list | `[]` | |
63+
| containerName | string | `"k8s-event-logger"` | |
64+
| env | object | `{}` | A map of environment variables |
65+
| fullnameOverride | string | `""` | |
66+
| image.pullPolicy | string | `"IfNotPresent"` | |
67+
| image.repository | string | `"maxrocketinternet/k8s-event-logger"` | |
68+
| imagePullSecrets | list | `[]` | |
69+
| nameOverride | string | `""` | |
70+
| nodeSelector | object | `{}` | |
71+
| podAnnotations | object | `{}` | |
72+
| podLabels | object | `{}` | |
73+
| podSecurityContext.allowPrivilegeEscalation | bool | `false` | |
74+
| podSecurityContext.capabilities.drop[0] | string | `"ALL"` | |
75+
| podSecurityContext.readOnlyRootFilesystem | bool | `true` | |
76+
| podSecurityContext.runAsGroup | int | `10001` | |
77+
| podSecurityContext.runAsNonRoot | bool | `true` | |
78+
| podSecurityContext.runAsUser | int | `10001` | |
79+
| podSecurityContext.seccompProfile.type | string | `"RuntimeDefault"` | |
80+
| resources.limits.cpu | string | `"100m"` | |
81+
| resources.limits.memory | string | `"128Mi"` | |
82+
| resources.requests.cpu | string | `"10m"` | |
83+
| resources.requests.memory | string | `"128Mi"` | |
84+
| securityContext | object | `{}` | |
85+
| tolerations | list | `[]` | |
86+
87+
## Maintainers
88+
89+
| Name | Email | Url |
90+
| ---- | ------ | --- |
91+
| max-rocket-internet | <[email protected]> | |

chart/templates/_helpers.tpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,19 @@ Common labels
3838
{{- define "k8s-event-logger.labels" -}}
3939
helm.sh/chart: {{ include "k8s-event-logger.chart" . }}
4040
app.kubernetes.io/instance: {{ .Release.Name }}
41+
app.kubernetes.io/name: {{ .Release.Name }}
4142
{{- if .Chart.AppVersion }}
4243
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
4344
{{- end }}
4445
app.kubernetes.io/managed-by: {{ .Release.Service }}
4546
{{- end -}}
47+
48+
49+
50+
{{/*
51+
Selector labels
52+
*/}}
53+
{{- define "k8s-event-logger.selectorLabels" -}}
54+
app.kubernetes.io/name: {{ include "k8s-event-logger.name" . }}
55+
app.kubernetes.io/instance: {{ .Release.Name }}
56+
{{- end }}

chart/templates/clusterrole.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@ metadata:
66
app.kubernetes.io/name: {{ include "k8s-event-logger.name" . }}
77
{{- include "k8s-event-logger.labels" . | nindent 4 }}
88
rules:
9-
- apiGroups: [""]
10-
resources: ["events"]
11-
verbs: ["get", "list", "watch"]
9+
{{- toYaml .Values.rbac.rules | nindent 2 }}

chart/templates/deployment.yaml

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ apiVersion: apps/v1
22
kind: Deployment
33
metadata:
44
name: {{ include "k8s-event-logger.fullname" . }}
5-
namespace: {{ .Release.Namespace }}
65
labels:
7-
app.kubernetes.io/name: {{ include "k8s-event-logger.name" . }}
8-
{{- include "k8s-event-logger.labels" . | nindent 4 }}
6+
{{ include "k8s-event-logger.labels" . | indent 4 }}
7+
{{- with .Values.annotations }}
8+
annotations:
9+
{{- toYaml . | nindent 4 }}
10+
{{- end }}
911
spec:
1012
replicas: 1
1113
selector:
1214
matchLabels:
13-
app.kubernetes.io/name: {{ include "k8s-event-logger.name" . }}
14-
app.kubernetes.io/instance: {{ .Release.Name }}
15+
{{- include "k8s-event-logger.selectorLabels" . | nindent 6 }}
1516
template:
1617
metadata:
1718
{{- with .Values.podAnnotations }}
@@ -20,7 +21,7 @@ spec:
2021
{{- end }}
2122
labels:
2223
app.kubernetes.io/name: {{ include "k8s-event-logger.name" . }}
23-
app.kubernetes.io/instance: {{ .Release.Name }}
24+
{{- include "k8s-event-logger.labels" . | nindent 8 }}
2425
{{- if .Values.podLabels }}
2526
{{ toYaml .Values.podLabels | indent 8 }}
2627
{{- end }}
@@ -29,13 +30,25 @@ spec:
2930
imagePullSecrets:
3031
{{- toYaml . | nindent 8 }}
3132
{{- end }}
33+
{{- if .Values.podSecurityContext }}
34+
securityContext:
35+
{{- toYaml .Values.securityContext | nindent 8 }}
36+
{{- end }}
3237
serviceAccountName: {{ include "k8s-event-logger.fullname" . }}
3338
containers:
34-
- name: {{ .Values.image.containerName }}
35-
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
39+
- name: {{ .Values.containerName}}
40+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
41+
{{- if .Values.service.enabled }}
42+
ports:
43+
- name: metrics
44+
containerPort: {{ .Values.metrics.port }}
45+
protocol: TCP
46+
{{- end }}
3647
imagePullPolicy: {{ .Values.image.pullPolicy }}
48+
{{- if .Values.podSecurityContext }}
3749
securityContext:
38-
{{- toYaml .Values.securityContext | nindent 12 }}
50+
{{- toYaml .Values.podSecurityContext | nindent 12 }}
51+
{{- end }}
3952
env:
4053
{{- range $key, $value := .Values.env }}
4154
- name: {{ $key }}

chart/templates/service.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{- if .Values.service.enabled }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ include "k8s-event-logger.fullname" . }}
6+
labels:
7+
{{- include "k8s-event-logger.labels" . | nindent 4 }}
8+
annotations:
9+
prometheus.io/scrape: "true"
10+
prometheus.io/port: "{{ .Values.service.port }}"
11+
prometheus.io/path: "/metrics"
12+
spec:
13+
type: {{ .Values.service.type }}
14+
ports:
15+
- port: {{ .Values.service.port }}
16+
targetPort: metrics
17+
protocol: TCP
18+
name: metrics
19+
selector:
20+
{{- include "k8s-event-logger.selectorLabels" . | nindent 4 }}
21+
{{- end }}

chart/templates/serviceaccount.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ kind: ServiceAccount
22
apiVersion: v1
33
metadata:
44
name: {{ include "k8s-event-logger.fullname" . }}
5-
namespace: {{ .Release.Namespace }}
65
labels:
76
app.kubernetes.io/name: {{ include "k8s-event-logger.name" . }}
87
helm.sh/chart: {{ include "k8s-event-logger.chart" . }}

chart/templates/servicemonitor.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{{- if .Values.serviceMonitor.enabled }}
2+
apiVersion: monitoring.coreos.com/v1
3+
kind: ServiceMonitor
4+
metadata:
5+
name: {{ include "k8s-event-logger.fullname" . }}
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "k8s-event-logger.labels" . | nindent 4 }}
9+
{{- with .Values.serviceMonitor.labels }}
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
selector:
14+
matchLabels:
15+
{{- include "k8s-event-logger.selectorLabels" . | nindent 6 }}
16+
endpoints:
17+
- port: metrics
18+
path: {{ .Values.service.metricsPath | default "/metrics" }}
19+
interval: {{ .Values.serviceMonitor.interval }}
20+
scrapeTimeout: {{ .Values.serviceMonitor.scrapeTimeout }}
21+
{{- with .Values.serviceMonitor.metricRelabelings }}
22+
metricRelabelings:
23+
{{- toYaml . | nindent 6 }}
24+
{{- end }}
25+
{{- with .Values.serviceMonitor.relabelings }}
26+
relabelings:
27+
{{- toYaml . | nindent 6 }}
28+
{{- end }}
29+
namespaceSelector:
30+
matchNames:
31+
- {{ .Release.Namespace }}
32+
{{- end }}

chart/values.yaml

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,25 @@
1+
containerName: k8s-event-logger
12
image:
2-
containerName: app
33
repository: maxrocketinternet/k8s-event-logger
4-
tag: "2.3"
4+
# image.tag -- Overrides the image tag whose default is the chart appVersion.
5+
# tag: "2.0"
56
pullPolicy: IfNotPresent
67

78
resources:
89
requests:
910
cpu: 10m
10-
memory: 32Mi
11+
memory: 128Mi
1112
limits:
1213
cpu: 100m
1314
memory: 128Mi
1415

16+
# env -- A map of environment variables
1517
env: {}
1618
args: []
17-
imagePullSecrets: []
18-
nameOverride: ""
19-
fullnameOverride: ""
20-
nodeSelector: {}
21-
tolerations: []
22-
affinity: {}
23-
podLabels: {}
24-
podAnnotations: {}
25-
securityContext:
19+
20+
securityContext: {}
21+
22+
podSecurityContext:
2623
readOnlyRootFilesystem: true
2724
runAsNonRoot: true
2825
runAsUser: 10001
@@ -33,3 +30,36 @@ securityContext:
3330
- ALL
3431
seccompProfile:
3532
type: RuntimeDefault
33+
34+
imagePullSecrets: []
35+
nameOverride: ""
36+
fullnameOverride: ""
37+
nodeSelector: {}
38+
tolerations: []
39+
affinity: {}
40+
podLabels: {}
41+
annotations: {}
42+
podAnnotations: {}
43+
44+
service:
45+
enabled: false
46+
type: ClusterIP
47+
port: 8080
48+
targetPort: 8080
49+
50+
metrics:
51+
enabled: false
52+
port: 8080
53+
54+
serviceMonitor:
55+
enabled: false
56+
interval: 30s
57+
scrapeTimeout: 10s
58+
labels: {}
59+
metricRelabelings: []
60+
61+
clusterRole:
62+
rules:
63+
- apiGroups: [ "" ]
64+
resources: [ "events" ]
65+
verbs: [ "get", "list", "watch" ]

0 commit comments

Comments
 (0)