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

use strict security context #155

Merged
merged 1 commit into from
Jun 1, 2023
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/minecraft-bedrock/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: minecraft-bedrock
version: 2.0.2
version: 2.1.0
appVersion: SeeValues
home: https://minecraft.net/
description: Minecraft server
Expand Down
8 changes: 8 additions & 0 deletions charts/minecraft-bedrock/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ spec:
imagePullSecrets:
- name: {{ .Values.image.pullSecret }}
{{- end }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if .Values.initContainers }}
initContainers:
{{- toYaml .Values.initContainers | nindent 8 }}
Expand Down Expand Up @@ -139,14 +141,20 @@ spec:
protocol: UDP

volumeMounts:
- name: tmp
mountPath: /tmp
- name: datadir
mountPath: /data
{{- range .Values.extraVolumes }}
{{- if .volumeMounts }}
{{- toYaml .volumeMounts | nindent 8 }}
{{- end }}
{{- end }}
securityContext:
{{- toYaml .Values.securityContext | nindent 10 }}
volumes:
- name: tmp
emptyDir: {}
- name: datadir
{{- if .Values.persistence.dataDir.enabled }}
persistentVolumeClaim:
Expand Down
15 changes: 15 additions & 0 deletions charts/minecraft-bedrock/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,21 @@ tolerations: []

affinity: {}

podSecurityContext:
runAsUser: 1000
runAsGroup: 3000
runAsNonRoot: true
fsGroup: 2000
Comment on lines +27 to +29
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@uhthomas I had missed this before: why did you choose group ID 3000 to run and group ID for the filesystem? It seems to be causing issues like #164

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is standard as recommended by the official Kubernetes documentation.

https://kubernetes.io/docs/tasks/configure-pod-container/security-context/

uid=1000 gid=3000 groups=2000

The idea is that there is as little permission as possible.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for following up.

seccompProfile:
type: RuntimeDefault

securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false

# Most of these map to environment variables. See Minecraft for details:
# https://hub.docker.com/r/itzg/minecraft-server/
livenessProbe:
Expand Down
2 changes: 1 addition & 1 deletion charts/minecraft-proxy/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: minecraft-proxy
version: 3.2.0
version: 3.3.0
appVersion: SeeValues
description: Minecraft proxy server (BungeeCord, Waterfall, Velocity, etc.)
keywords:
Expand Down
9 changes: 7 additions & 2 deletions charts/minecraft-proxy/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ spec:
- name: {{ .Values.image.pullSecret }}
{{- end }}
securityContext:
runAsUser: {{ .Values.securityContext.runAsUser }}
fsGroup: {{ .Values.securityContext.fsGroup }}
{{- toYaml .Values.podSecurityContext | nindent 8 }}
initContainers: {{- toYaml .Values.initContainers | nindent 8 }}
containers:
- name: {{ template "proxy.fullname" . }}
Expand Down Expand Up @@ -151,6 +150,8 @@ spec:
{{- end }}
{{- end }}
volumeMounts:
- name: tmp
uhthomas marked this conversation as resolved.
Show resolved Hide resolved
mountPath: /tmp
- name: datadir
mountPath: /server
{{- if .Values.minecraftProxy.config }}
Expand All @@ -163,10 +164,14 @@ spec:
{{- toYaml .volumeMounts | nindent 8 }}
{{- end }}
{{- end }}
securityContext:
{{- toYaml .Values.securityContext | nindent 10 }}
{{- if .Values.sidecarContainers }}
{{- toYaml .Values.sidecarContainers | nindent 6 }}
{{- end }}
volumes:
- name: tmp
emptyDir: {}
- name: datadir
{{- if .Values.persistence.dataDir.enabled }}
persistentVolumeClaim:
Expand Down
78 changes: 44 additions & 34 deletions charts/minecraft-proxy/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,21 @@ resources:
memory: 512Mi
cpu: 500m

securityContext:
# Security context settings
podSecurityContext:
runAsUser: 1000
runAsGroup: 1000
runAsGroup: 3000
runAsNonRoot: true
fsGroup: 2000
seccompProfile:
type: RuntimeDefault

securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false

# Most of these map to environment variables. See Minecraft for details:
# https://hub.docker.com/r/itzg/docker-bungeecord/
livenessProbe:
Expand Down Expand Up @@ -176,37 +186,37 @@ minecraftProxy:
# externalTrafficPolicy: Cluster

extraPorts: []
# These options allow you to expose another port from the Minecraft proxy, plugins such
# as NuVotifier (8192) will require this for incoming webhooks
#
# - name: vote
# containerPort: 8192
# protocol: TCP
# service:
# enabled: false
# embedded: false
# annotations: {}
# type: ClusterIP
# ## Set the external port if the rcon serviceType is NodePort
## nodePort:
# loadBalancerIP: ""
# loadBalancerSourceRanges: []
# externalTrafficPolicy: Cluster
# port: 8192
# ingress:
# ingressClassName: nginx
# enabled: false
# annotations:
## Deprecated way for specifying the ingressClass. Kube.version < 1.18
## kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
# hosts:
# - name: vote.local
# path: /
# tls:
# - secretName: vote-tls
# hosts:
# - vote.local
# These options allow you to expose another port from the Minecraft proxy, plugins such
# as NuVotifier (8192) will require this for incoming webhooks
#
# - name: vote
# containerPort: 8192
# protocol: TCP
# service:
# enabled: false
# embedded: false
# annotations: {}
# type: ClusterIP
# ## Set the external port if the rcon serviceType is NodePort
## nodePort:
# loadBalancerIP: ""
# loadBalancerSourceRanges: []
# externalTrafficPolicy: Cluster
# port: 8192
# ingress:
# ingressClassName: nginx
# enabled: false
# annotations:
## Deprecated way for specifying the ingressClass. Kube.version < 1.18
## kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
# hosts:
# - name: vote.local
# path: /
# tls:
# - secretName: vote-tls
# hosts:
# - vote.local

## Additional minecraft container environment variables
## Values can be either variable values or `valueFrom` yaml
Expand Down
2 changes: 1 addition & 1 deletion charts/minecraft/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: minecraft
version: 4.7.4
version: 4.8.0
appVersion: SeeValues
home: https://minecraft.net/
description: Minecraft server
Expand Down
15 changes: 12 additions & 3 deletions charts/minecraft/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ spec:
- name: {{ .Values.image.pullSecret }}
{{- end }}
securityContext:
runAsUser: {{ .Values.securityContext.runAsUser }}
fsGroup: {{ .Values.securityContext.fsGroup }}
{{- toYaml .Values.podSecurityContext | nindent 8 }}
{{- if .Values.initContainers }}
initContainers:
{{- toYaml .Values.initContainers | nindent 8 }}
Expand Down Expand Up @@ -119,6 +118,8 @@ spec:
{{- end }}
{{- end }}
volumeMounts:
- name: tmp
mountPath: /tmp
- name: datadir
mountPath: /data
readOnly: true
Expand All @@ -133,6 +134,8 @@ spec:
{{- toYaml .volumeMounts | nindent 8 }}
{{- end }}
{{- end }}
securityContext:
{{- toYaml .Values.securityContext | nindent 10 }}
{{- end }}
- name: {{ template "minecraft.fullname" . }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
Expand Down Expand Up @@ -321,7 +324,7 @@ spec:
{{- end }}
{{- end }}
{{- end }}


{{- range $key, $value := .Values.extraEnv }}
{{- if kindIs "map" $value }}
Expand Down Expand Up @@ -357,6 +360,8 @@ spec:
{{- end }}
{{- end }}
volumeMounts:
- name: tmp
mountPath: /tmp
- name: datadir
mountPath: /data
{{- if (and .Values.persistence.dataDir.enabled .Values.persistence.dataDir.subPath) }}
Expand All @@ -370,10 +375,14 @@ spec:
{{- toYaml .volumeMounts | nindent 8 }}
{{- end }}
{{- end }}
securityContext:
{{- toYaml .Values.securityContext | nindent 10 }}
{{- if .Values.sidecarContainers }}
{{- toYaml .Values.sidecarContainers | nindent 6 }}
{{- end }}
volumes:
- name: tmp
emptyDir: {}
- name: datadir
{{- if .Values.persistence.dataDir.enabled }}
persistentVolumeClaim:
Expand Down
15 changes: 13 additions & 2 deletions charts/minecraft/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,21 @@ tolerations: []

affinity: {}

securityContext:
# Security context settings
podSecurityContext:
runAsUser: 1000
runAsGroup: 3000
runAsNonRoot: true
fsGroup: 2000
seccompProfile:
type: RuntimeDefault

securityContext:
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false

# Most of these map to environment variables. See Minecraft for details:
# https://hub.docker.com/r/itzg/minecraft-server/
livenessProbe:
Expand Down
2 changes: 1 addition & 1 deletion charts/rcon-web-admin/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: rcon-web-admin
home: https://github.com/rcon-web-admin/rcon-web-admin
description: RCon Web UI for managing game servers
type: application
version: 1.0.0
version: 1.1.0
appVersion: "0.14.1-1"
keywords:
- game
Expand Down
8 changes: 7 additions & 1 deletion charts/rcon-web-admin/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ spec:
serviceAccountName: {{ include "rcon-web-admin.fullname" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
volumes:
- name: db
emptyDir: {}
containers:
- name: {{ .Chart.Name }}
securityContext:
Expand All @@ -35,7 +38,7 @@ spec:
- name: RWA_USERNAME
value: {{ .Values.rconWeb.username | default "admin" | quote }}
- name: RWA_PASSWORD
valueFrom:
valueFrom:
secretKeyRef:
name: {{ .Values.rconWeb.passwordExistingSecret | default (include "rcon-web-admin.fullname" .) }}
key: {{ .Values.rconWeb.passwordKey | default "password" }}
Expand Down Expand Up @@ -102,6 +105,9 @@ spec:
- name: ws
containerPort: 4327
protocol: TCP
volumeMounts:
- name: db
mountPath: /opt/rcon-web-admin/db
livenessProbe:
httpGet:
path: /
Expand Down
20 changes: 11 additions & 9 deletions charts/rcon-web-admin/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ fullnameOverride: ""
podAnnotations: {}

podSecurityContext:
{}
# fsGroup: 2000
runAsUser: 1000
runAsGroup: 3000
runAsNonRoot: true
fsGroup: 2000
seccompProfile:
type: RuntimeDefault

securityContext:
{}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
capabilities:
drop:
- ALL
readOnlyRootFilesystem: true
allowPrivilegeEscalation: false

# This will expose 2 different services - http and websockets
# If you want to know why it's separate - ask developer of original project
Expand Down