feat: add Kubernetes multiplayer security baseline

This commit is contained in:
Josh Creek
2026-08-31 21:21:55 +01:00
parent 79e66c7a95
commit 88b5ffedb2
9 changed files with 236 additions and 4 deletions
@@ -0,0 +1,59 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: control-plane
labels:
app.kubernetes.io/name: control-plane
spec:
replicas: 2
selector:
matchLabels:
app.kubernetes.io/name: control-plane
template:
metadata:
labels:
app.kubernetes.io/name: control-plane
spec:
serviceAccountName: control-plane
automountServiceAccountToken: false
securityContext:
runAsNonRoot: true
runAsUser: 10001
runAsGroup: 10001
seccompProfile:
type: RuntimeDefault
containers:
- name: control-plane
image: ghcr.io/cosmic-clash/control-plane@sha256:0000000000000000000000000000000000000000000000000000000000000000
ports:
- name: http
containerPort: 8080
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop: [ALL]
resources:
requests:
cpu: 100m
memory: 128Mi
limits:
cpu: 1
memory: 512Mi
env:
- name: DATABASE_PASSWORD
valueFrom:
secretKeyRef:
name: cosmic-clash-database
key: password
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: cosmic-clash-redis
key: password
- name: STEAM_PUBLISHER_KEY
valueFrom:
secretKeyRef:
name: cosmic-clash-steam
key: publisher-key
+10
View File
@@ -0,0 +1,10 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: cosmic-clash
resources:
- namespace.yaml
- service-accounts.yaml
- rbac.yaml
- network-policies.yaml
- control-plane-deployment.yaml
+9
View File
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Namespace
metadata:
name: cosmic-clash
labels:
pod-security.kubernetes.io/enforce: restricted
pod-security.kubernetes.io/audit: restricted
pod-security.kubernetes.io/warn: restricted
+67
View File
@@ -0,0 +1,67 @@
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny-ingress-egress
spec:
podSelector: {}
policyTypes: [Ingress, Egress]
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: control-plane-allowed-flows
spec:
podSelector:
matchLabels:
app.kubernetes.io/name: control-plane
policyTypes: [Ingress, Egress]
ingress:
- from:
- namespaceSelector: {}
podSelector:
matchLabels:
app.kubernetes.io/name: edge-gateway
ports:
- protocol: TCP
port: 8080
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: data
podSelector:
matchLabels:
app.kubernetes.io/name: postgres
ports:
- protocol: TCP
port: 5432
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: data
podSelector:
matchLabels:
app.kubernetes.io/name: redis
ports:
- protocol: TCP
port: 6379
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: agones-system
ports:
- protocol: TCP
port: 443
- ports:
- protocol: UDP
port: 53
- protocol: TCP
port: 53
to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
podSelector:
matchLabels:
k8s-app: kube-dns
+24
View File
@@ -0,0 +1,24 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: control-plane-agones-allocator
namespace: agones-system
rules:
- apiGroups: ["allocation.agones.dev"]
resources: ["gameserverallocations"]
verbs: ["create"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: cosmic-clash-control-plane-agones-allocator
namespace: agones-system
subjects:
- kind: ServiceAccount
name: control-plane
namespace: cosmic-clash
roleRef:
kind: Role
name: control-plane-agones-allocator
apiGroup: rbac.authorization.k8s.io
+14
View File
@@ -0,0 +1,14 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: control-plane
namespace: cosmic-clash
automountServiceAccountToken: false
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: match-server
namespace: cosmic-clash
automountServiceAccountToken: false