diff --git a/zombi/minecraft/.helmignore b/zombi/minecraft/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/zombi/minecraft/.helmignore @@ -0,0 +1,23 @@ +# Patterns to ignore when building packages. +# This supports shell glob matching, relative path matching, and +# negation (prefixed with !). Only one pattern per line. +.DS_Store +# Common VCS dirs +.git/ +.gitignore +.bzr/ +.bzrignore +.hg/ +.hgignore +.svn/ +# Common backup files +*.swp +*.bak +*.tmp +*.orig +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode/ diff --git a/zombi/minecraft/Chart.yaml b/zombi/minecraft/Chart.yaml new file mode 100644 index 0000000..5a41f92 --- /dev/null +++ b/zombi/minecraft/Chart.yaml @@ -0,0 +1,7 @@ +apiVersion: v2 +name: minecraft +description: Server for the game "minecraft" + +version: 0.1.0 + +appVersion: forge diff --git a/zombi/minecraft/templates/_helpers.tpl b/zombi/minecraft/templates/_helpers.tpl new file mode 100644 index 0000000..00822f4 --- /dev/null +++ b/zombi/minecraft/templates/_helpers.tpl @@ -0,0 +1,52 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "minecraft.name" -}} +{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Create a default fully qualified app name. +We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). +If release name contains chart name it will be used as a full name. +*/}} +{{- define "minecraft.fullname" -}} +{{- if .Values.fullnameOverride }} +{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- $name := default .Chart.Name .Values.nameOverride }} +{{- if contains $name .Release.Name }} +{{- .Release.Name | trunc 63 | trimSuffix "-" }} +{{- else }} +{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} +{{- end }} +{{- end }} +{{- end }} + +{{/* +Create chart name and version as used by the chart label. +*/}} +{{- define "minecraft.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "minecraft.labels" -}} +helm.sh/chart: {{ include "minecraft.chart" . }} +{{ include "minecraft.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "minecraft.selectorLabels" -}} +app.kubernetes.io/name: {{ include "minecraft.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + diff --git a/zombi/minecraft/templates/deployment.yaml b/zombi/minecraft/templates/deployment.yaml new file mode 100644 index 0000000..2d2586b --- /dev/null +++ b/zombi/minecraft/templates/deployment.yaml @@ -0,0 +1,78 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "minecraft.fullname" . }} + labels: + {{- include "minecraft.labels" . | nindent 4 }} +spec: + replicas: 1 + strategy: + type: Recreate # Avoid parallel access to the volume + selector: + matchLabels: + {{- include "minecraft.selectorLabels" . | nindent 6 }} + template: + metadata: + {{- with .Values.podAnnotations }} + annotations: + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "minecraft.selectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: default + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + terminationGracePeriodSeconds: 30 + initContainers: + - name: download + image: alpine:3.12.1 + imagePullPolicy: IfNotPresent + command: + - sh + - -c + - '[[ ! -d /minecraft/world ]] && wget -O- "{{ .Values.downloadURL }}" | tar -x --strip-components=1 -C /minecraft || true' + volumeMounts: + - name: {{ include "minecraft.fullname" . }} + mountPath: /minecraft + resources: + requests: + cpu: 100m + memory: 64Mi + limits: + cpu: 100m + memory: 64Mi + containers: + - name: {{ .Chart.Name }} + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: JAVA_OPTS + value: '-Xms3500m -Xmx3500m' + volumeMounts: + - name: {{ include "minecraft.fullname" . }} + mountPath: /minecraft + ports: + - containerPort: 25565 + name: minecraft + protocol: TCP + resources: + {{- toYaml .Values.resources | nindent 12 }} + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} diff --git a/zombi/minecraft/templates/pvc.yaml b/zombi/minecraft/templates/pvc.yaml new file mode 100644 index 0000000..db9e7a4 --- /dev/null +++ b/zombi/minecraft/templates/pvc.yaml @@ -0,0 +1,20 @@ +{{- if .Values.persistence.enabled }} +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: {{ include "minecraft.fullname" . }} + labels: + {{- include "minecraft.labels" . | nindent 4 }} + annotations: + {{- if .Values.persistence.storageClass }} + volume.beta.kubernetes.io/storage-class: {{ .Values.persistence.storageClass | quote }} + {{- else }} + volume.alpha.kubernetes.io/storage-class: default + {{- end }} +spec: + accessModes: + - {{ .Values.persistence.accessMode | quote }} + resources: + requests: + storage: {{ .Values.persistence.size | quote }} +{{- end }} \ No newline at end of file diff --git a/zombi/minecraft/templates/service.yaml b/zombi/minecraft/templates/service.yaml new file mode 100644 index 0000000..f94f8f0 --- /dev/null +++ b/zombi/minecraft/templates/service.yaml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "minecraft.fullname" . }} + annotations: + external-dns.alpha.kubernetes.io/hostname: {{ .Values.hostname }} + labels: + {{- include "minecraft.labels" . | nindent 4 }} +spec: + type: {{ .Values.service.type }} + {{- with .Values.service.externalTrafficPolicy }} + externalTrafficPolicy: {{ . }} + {{- end }} + ports: + - port: {{ .Values.service.port }} + targetPort: minecraft + protocol: TCP + name: minecraft + selector: + {{- include "minecraft.selectorLabels" . | nindent 4 }} diff --git a/zombi/minecraft/values.yaml b/zombi/minecraft/values.yaml new file mode 100644 index 0000000..e785d47 --- /dev/null +++ b/zombi/minecraft/values.yaml @@ -0,0 +1,49 @@ +# Default values for minecraft. + +image: + repository: zombi/minecraft-forge + tag: "1.16.4-35.1.13" + pullPolicy: IfNotPresent + +imagePullSecrets: [] +nameOverride: "" +fullnameOverride: "" + +hostname: thomasmods.bitmask.me +downloadURL: https://user.zom.bi/paul/thomasmods.tar + +podAnnotations: {} + +service: + type: LoadBalancer + externalTrafficPolicy: Local + port: 25565 + +persistence: + enabled: true + storageClass: default + accessMode: ReadWriteOnce + size: 10Gi + +resources: + # if no requests are specified, limits = requests. + limits: + cpu: 3 + memory: 5Gi + +podSecurityContext: {} + # fsGroup: 2000 + +securityContext: {} + # capabilities: + # drop: + # - ALL + # readOnlyRootFilesystem: true + # runAsNonRoot: true + # runAsUser: 1000 + +nodeSelector: {} + +tolerations: [] + +affinity: {}