Skip to content

Commit

Permalink
feat: add additional ciliumNetworkPolicies in loki helm chart for wor…
Browse files Browse the repository at this point in the history
…ld egress for read, write and backend (#12066)

Signed-off-by: QuantumEnigmaa <[email protected]>
Co-authored-by: Michel Hollands <[email protected]>
  • Loading branch information
QuantumEnigmaa and MichelHollands authored Mar 4, 2024
1 parent b0478e6 commit c1084a1
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 2 deletions.
18 changes: 18 additions & 0 deletions docs/sources/setup/install/helm/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3120,6 +3120,24 @@ null
<td><pre lang="json">
null
</pre>
</td>
</tr>
<tr>
<td>networkPolicy.egressKubeApiserver.enabled</td>
<td>bool</td>
<td>Enable additional cilium egress rules to kube-apiserver for backend.</td>
<td><pre lang="json">
false
</pre>
</td>
</tr>
<tr>
<td>networkPolicy.egressWorld.enabled</td>
<td>bool</td>
<td>Enable additional cilium egress rules to external world for write, read and backend.</td>
<td><pre lang="json">
false
</pre>
</td>
</tr>
<tr>
Expand Down
4 changes: 4 additions & 0 deletions production/helm/loki/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ Entries should include a reference to the pull request that introduced the chang

[//]: # (<AUTOMATED_UPDATES_LOCATOR> : do not remove this line. This locator is used by the CI pipeline to automatically create a changelog entry for each new Loki release. Add other chart versions and respective changelog entries bellow this line.)

## 5.43.4

- [ENHANCEMENT] Add `ciliumnetworkpolicies` with egress to world for write, read and backend.

## 5.43.3

- [ENHANCEMENT] Added missing default values to support ServerSideApply
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: loki
description: Helm chart for Grafana Loki in simple, scalable mode
type: application
appVersion: 2.9.4
version: 5.43.3
version: 5.43.4
home: https://grafana.github.io/helm-charts
sources:
- https://github.com/grafana/loki
Expand Down
2 changes: 1 addition & 1 deletion production/helm/loki/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# loki

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

Helm chart for Grafana Loki in simple, scalable mode

Expand Down
43 changes: 43 additions & 0 deletions production/helm/loki/templates/ciliumnetworkpolicy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,49 @@ spec:
{{- end }}
{{- end }}

{{- if .Values.networkPolicy.egressWorld.enabled }}
{{- $global := . }}
{{- $componentsList := list "read" "write" "backend" }}
{{- range $component := $componentsList }}
{{- with $global }}
---
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
name: {{ include "loki.name" . }}-{{ $component }}-world-egress
namespace: {{ .Release.Namespace }}
spec:
endpointSelector:
matchLabels:
{{- if eq $component "read" }}
{{- include "loki.readSelectorLabels" . | nindent 6 }}
{{- else if eq $component "write" }}
{{- include "loki.writeSelectorLabels" . | nindent 6 }}
{{- else }}
{{- include "loki.backendSelectorLabels" . | nindent 6 }}
{{- end }}
egress:
- toEntities:
- world
{{- end }}
{{- end }}
{{- end }}

{{- if .Values.networkPolicy.egressKubeApiserver.enabled }}
apiVersion: "cilium.io/v2"
kind: CiliumNetworkPolicy
metadata:
name: {{ include "loki.name" . }}-backend-kubeapiserver-egress
namespace: {{ .Release.Namespace }}
spec:
endpointSelector:
matchLabels:
{{- include "loki.backendSelectorLabels" . | nindent 6 }}
egress:
- toEntities:
- kube-apiserver
{{- end }}

{{- end }}

{{- if and .Values.networkPolicy.discovery.port (eq .Values.networkPolicy.flavor "cilium") }}
Expand Down
6 changes: 6 additions & 0 deletions production/helm/loki/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1522,6 +1522,12 @@ networkPolicy:
podSelector: {}
# -- Specifies the namespace the discovery Pods are running in
namespaceSelector: {}
egressWorld:
# -- Enable additional cilium egress rules to external world for write, read and backend.
enabled: false
egressKubeApiserver:
# -- Enable additional cilium egress rules to kube-apiserver for backend.
enabled: false
# -------------------------------------
# Configuration for `minio` child chart
# -------------------------------------
Expand Down

0 comments on commit c1084a1

Please sign in to comment.