Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add network policies to Uptime Kuma #182

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/uptime-kuma/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ name: uptime-kuma
sources:
- https://github.com/louislam/uptime-kuma
type: application
version: 2.20.0
version: 2.21.0
13 changes: 9 additions & 4 deletions charts/uptime-kuma/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# uptime-kuma

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

A self-hosted Monitoring tool like "Uptime-Robot".

Expand Down Expand Up @@ -47,13 +47,18 @@ A self-hosted Monitoring tool like "Uptime-Robot".
| livenessProbe.successThreshold | int | `1` | |
| livenessProbe.timeoutSeconds | int | `2` | |
| nameOverride | string | `""` | |
| networkPolicy | object | `{"allowExternal":true,"egress":true,"enabled":false,"ingress":true,"namespaceSelector":{}}` | Create a NetworkPolicy |
| networkPolicy.allowExternal | bool | `true` | Allow incoming connections only from specific Pods When set to true, the geoserver will accept connections from any source. When false, only Pods with the label {{ include "geoserver.fullname" . }}-client=true will have network access |
| networkPolicy.egress | bool | `true` | Enable/disable Egress policy type |
| networkPolicy.enabled | bool | `false` | Enable/disable Network Policy |
| networkPolicy.ingress | bool | `true` | Enable/disable Ingress policy type |
| networkPolicy.namespaceSelector | object | `{}` | Selects particular namespaces for which all Pods are allowed as ingress sources |
| nodeSelector | object | `{}` | |
| podAnnotations | object | `{}` | |
| podEnv[0].name | string | `"UPTIME_KUMA_PORT"` | |
| podEnv[0].value | string | `"3001"` | |
| podEnv | list | `[]` | |
| podLabels | object | `{}` | |
| podSecurityContext | object | `{}` | |
| priorityClassName | string | `""` | Use this option to set custom PriorityClass to the created deployment |
| priorityClassName | string | `""` | Use this option to set custom PriorityClass to the created deployment ref: https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass |
| readinessProbe.enabled | bool | `true` | |
| readinessProbe.exec.command | list | `[]` | |
| readinessProbe.failureThreshold | int | `3` | |
Expand Down
7 changes: 7 additions & 0 deletions charts/uptime-kuma/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ app.kubernetes.io/name: {{ include "uptime-kuma.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Port of the Uptime Kuma container
*/}}
{{- define "uptime-kuma.port" -}}
3001
{{- end }}

{{/*
Create the name of the service account to use
*/}}
Expand Down
2 changes: 1 addition & 1 deletion charts/uptime-kuma/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ spec:
{{- end }}
ports:
- name: http
containerPort: 3001
containerPort: {{ include "uptime-kuma.port" . }}
protocol: TCP
{{ if or .Values.volume.enabled .Values.additionalVolumeMounts -}}
volumeMounts:
Expand Down
37 changes: 37 additions & 0 deletions charts/uptime-kuma/templates/netpol.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- if .Values.networkPolicy.enabled }}
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: {{ include "uptime-kuma.fullname" . }}
labels:
{{- include "uptime-kuma.labels" . | nindent 4 }}
spec:
podSelector:
matchLabels:
{{- include "uptime-kuma.selectorLabels" . | nindent 6 }}
policyTypes:
{{- if .Values.networkPolicy.ingress }}
- Ingress
{{- end }}
{{- if .Values.networkPolicy.egress }}
- Egress
{{- end }}
egress:
- {}
{{- if .Values.networkPolicy.ingress }}
ingress:
- ports:
- port: {{ include "uptime-kuma.port" . }}
protocol: TCP
{{- if not .Values.networkPolicy.allowExternal }}
from:
- podSelector:
matchLabels:
{{ include "uptime-kuma.fullname" . }}-client: "true"
{{- with .Values.networkPolicy.namespaceSelector }}
- namespaceSelector:
{{- toYaml . | nindent 10 }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/uptime-kuma/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: 3001
targetPort: {{ include "uptime-kuma.port" . }}
protocol: TCP
{{- with .Values.service.nodePort }}
nodePort: {{ . }}
Expand Down
8 changes: 5 additions & 3 deletions charts/uptime-kuma/templates/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,15 @@ spec:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- with .Values.podEnv }}
env:
- name: "UPTIME_KUMA_PORT"
value: {{ include "uptime-kuma.port" . }}
{{- with .Values.podEnv }}
{{- toYaml . | nindent 12 }}
{{- end }}
ports:
- name: http
containerPort: 3001
containerPort: {{ include "uptime-kuma.port" . }}
protocol: TCP
{{ if or .Values.volume.enabled .Values.additionalVolumeMounts -}}
volumeMounts:
Expand All @@ -81,7 +83,7 @@ spec:
readinessProbe:
httpGet:
path: /
port: 3001
port: {{ include "uptime-kuma.port" . }}
scheme: HTTP
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds}}
{{- end }}
Expand Down
27 changes: 23 additions & 4 deletions charts/uptime-kuma/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ podAnnotations: {}
podLabels:
{}
# app: uptime-kuma
podEnv:
# a default port must be set. required by container
- name: "UPTIME_KUMA_PORT"
value: "3001"
podEnv: []
# optional additional environment variables
# - name: "A_VARIABLE"
# value: "a-value"

podSecurityContext:
{}
Expand Down Expand Up @@ -207,3 +207,22 @@ dnsConfig: {}
# -- Use this option to set custom PriorityClass to the created deployment
# ref: https://kubernetes.io/docs/concepts/scheduling-eviction/pod-priority-preemption/#priorityclass
priorityClassName: ""

# -- Create a NetworkPolicy
networkPolicy:
# -- Enable/disable Network Policy
enabled: false
# -- Enable/disable Ingress policy type
ingress: true
# -- Enable/disable Egress policy type
egress: true
# -- Allow incoming connections only from specific Pods
# When set to true, the geoserver will accept connections from any source.
# When false, only Pods with the label {{ include "geoserver.fullname" . }}-client=true will have network access
allowExternal: true
# -- Selects particular namespaces for which all Pods are allowed as ingress sources
namespaceSelector: {}
# matchLabels:
# role: frontend
# matchExpressions:
# - {key: role, operator: In, values: [frontend]}
Loading