From 325fe3fb18f87cef1f86b859e192c25a6f252427 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?G=C3=B6ran=20P=C3=B6hner?= <goeran.poehner@gmail.com>
Date: Thu, 19 Oct 2023 15:45:19 +0200
Subject: [PATCH] Updated redis chart for Redis .6.14 and added networkpolicy
 feature

---
 charts/redis/Chart.yaml                   |  4 ++--
 charts/redis/README.md                    | 10 +++++++++
 charts/redis/RELEASENOTES.md              |  1 +
 charts/redis/templates/networkpolicy.yaml | 25 +++++++++++++++++++++++
 4 files changed, 38 insertions(+), 2 deletions(-)
 create mode 100644 charts/redis/templates/networkpolicy.yaml

diff --git a/charts/redis/Chart.yaml b/charts/redis/Chart.yaml
index 457263c8..0ca1379c 100644
--- a/charts/redis/Chart.yaml
+++ b/charts/redis/Chart.yaml
@@ -8,7 +8,7 @@ maintainers:
   - name: groundhog2k
 
 # This is the chart version
-version: "0.7.3"
+version: "0.4.18"
 
 # This is the version number of the application being deployed.
-appVersion: "7.2.1"
+appVersion: "6.2.14"
diff --git a/charts/redis/README.md b/charts/redis/README.md
index ab82db27..a649bead 100644
--- a/charts/redis/README.md
+++ b/charts/redis/README.md
@@ -181,6 +181,16 @@ helm uninstall my-release
 | storage.className | string | `nil` | Storage class name |
 | storage.keepPvc | bool | `false` | Keep a created Persistent volume claim when uninstalling the helm chart (only for `useDeploymentWhenNonHA`) |
 
+## Network policies
+
+Allows to define optional network policies for [ingress and egress](https://kubernetes.io/docs/concepts/services-networking/network-policies/)
+The policyTypes will be automatically set
+
+| Key | Type | Default | Description |
+|-----|------|---------|-------------|
+| networkPolicy.ingress | object | `{}` | Ingress network policies |
+| networkPolicy.egress | object | `{}` | Egress network policies |
+
 ## Redis parameters
 
 | Key | Type | Default | Description |
diff --git a/charts/redis/RELEASENOTES.md b/charts/redis/RELEASENOTES.md
index a64486e5..5578896f 100644
--- a/charts/redis/RELEASENOTES.md
+++ b/charts/redis/RELEASENOTES.md
@@ -10,6 +10,7 @@
 | 0.4.15 | 6.2.11 | Added option to use Deployment instead of StatefulSet for Non-HA deployments - thx @tim-hanssen |
 | 0.4.16 | 6.2.12 | Upgraded to Redis 6.2.12 |
 | 0.4.17 | 6.2.13 | Upgraded to Redis 6.2.13 |
+| 0.4.18 | 6.2.14 | Upgraded to Redis 6.2.14 |
 | 0.5.0 | 7.0.0 | Upgraded to Redis 7.0.0 |
 | 0.5.1 | 7.0.1 | Upgraded to Redis 7.0.1 |
 | 0.5.2 | 7.0.2 | Upgraded to Redis 7.0.2 |
diff --git a/charts/redis/templates/networkpolicy.yaml b/charts/redis/templates/networkpolicy.yaml
new file mode 100644
index 00000000..28ceb540
--- /dev/null
+++ b/charts/redis/templates/networkpolicy.yaml
@@ -0,0 +1,25 @@
+{{- with .Values.networkPolicy }}
+apiVersion: networking.k8s.io/v1
+kind: NetworkPolicy
+metadata:
+  name: {{ include "redis.fullname" $ }}
+spec:
+  podSelector:
+    matchLabels:
+      {{- include "redis.selectorLabels" $ | nindent 6 }}
+  policyTypes:
+  {{- if .ingress }}
+    - Ingress
+  {{- end }}
+  {{- if .egress }}
+    - Egress
+  {{- end }}
+  {{- with .ingress }}
+  ingress:
+    {{- toYaml . | nindent 4 }}
+  {{- end }}
+  {{- with .egress }}
+  egress:
+    {{- toYaml . | nindent 4 }}
+  {{- end }}
+{{- end }}
-- 
GitLab