Compare commits
	
		
			1 Commits
		
	
	
		
			b61171c21c
			...
			44892ced31
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 44892ced31 | 
@@ -1,11 +1,3 @@
 | 
				
			|||||||
## Setup
 | 
					 | 
				
			||||||
Because minecraft is quite sensitive to io performance, we want the data to be stored on a local disk. But hostpath is not well supported in talos (and is not persistent), so we use an ephemeral volume instead. In order to do this, we create an emptyDir volume and mount it to the pod.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
We use an initContaier that copies the data to the local storage. Afterwards, copying from the local storage back to the persistent storage is handled by a preStop lifecycle event.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
This way, we can have the best of both worlds: fast local storage and persistent storage.
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
## Sending a command
 | 
					## Sending a command
 | 
				
			||||||
```
 | 
					```
 | 
				
			||||||
kubectl exec -it -n minecraft deploy/minecraft-server -- /bin/bash
 | 
					kubectl exec -it -n minecraft deploy/minecraft-server -- /bin/bash
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -9,16 +9,6 @@ spec:
 | 
				
			|||||||
        app: minecraft-server
 | 
					        app: minecraft-server
 | 
				
			||||||
    spec:
 | 
					    spec:
 | 
				
			||||||
      restartPolicy: OnFailure
 | 
					      restartPolicy: OnFailure
 | 
				
			||||||
      initContainers:
 | 
					 | 
				
			||||||
      - name: copy-data-to-local
 | 
					 | 
				
			||||||
        image: alpine
 | 
					 | 
				
			||||||
        command: ["/bin/sh"]
 | 
					 | 
				
			||||||
        args: ["-c", "cp -r /data/* /local-data/"]
 | 
					 | 
				
			||||||
        volumeMounts:
 | 
					 | 
				
			||||||
        - name: local-data
 | 
					 | 
				
			||||||
          mountPath: /local-data
 | 
					 | 
				
			||||||
        - name: minecraft-data
 | 
					 | 
				
			||||||
          mountPath: /data
 | 
					 | 
				
			||||||
      containers:
 | 
					      containers:
 | 
				
			||||||
      - name: minecraft-server
 | 
					      - name: minecraft-server
 | 
				
			||||||
        image: minecraft
 | 
					        image: minecraft
 | 
				
			||||||
@@ -42,7 +32,7 @@ spec:
 | 
				
			|||||||
              name: curseforge-api
 | 
					              name: curseforge-api
 | 
				
			||||||
              key: key
 | 
					              key: key
 | 
				
			||||||
        - name: CF_PAGE_URL
 | 
					        - name: CF_PAGE_URL
 | 
				
			||||||
          value: "https://www.curseforge.com/minecraft/modpacks/vault-hunters-1-18-2/files/6470811"
 | 
					          value: "https://www.curseforge.com/minecraft/modpacks/vault-hunters-1-18-2/files/5925838"
 | 
				
			||||||
        - name: VERSION
 | 
					        - name: VERSION
 | 
				
			||||||
          value: "1.18.2"
 | 
					          value: "1.18.2"
 | 
				
			||||||
        - name: INIT_MEMORY
 | 
					        - name: INIT_MEMORY
 | 
				
			||||||
@@ -59,34 +49,12 @@ spec:
 | 
				
			|||||||
          value: "false"
 | 
					          value: "false"
 | 
				
			||||||
        - name: ENABLE_AUTOSTOP
 | 
					        - name: ENABLE_AUTOSTOP
 | 
				
			||||||
          value: "true"
 | 
					          value: "true"
 | 
				
			||||||
        - name: AUTOSTOP_TIMEOUT_EST
 | 
					 | 
				
			||||||
          value: "1800" # stop 30 min after last disconnect
 | 
					 | 
				
			||||||
        volumeMounts:
 | 
					 | 
				
			||||||
        - name: local-data
 | 
					 | 
				
			||||||
          mountPath: /data
 | 
					 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
      - name: copy-data-to-persistent
 | 
					 | 
				
			||||||
        image: rsync
 | 
					 | 
				
			||||||
        command: ["/bin/sh"]
 | 
					 | 
				
			||||||
        # args: ["-c", "sleep infinity"]
 | 
					 | 
				
			||||||
        args: ["/run-rsync.sh"]
 | 
					 | 
				
			||||||
        volumeMounts:
 | 
					        volumeMounts:
 | 
				
			||||||
        - name: local-data
 | 
					 | 
				
			||||||
          mountPath: /local-data
 | 
					 | 
				
			||||||
        - name: minecraft-data
 | 
					        - name: minecraft-data
 | 
				
			||||||
          mountPath: /persistent-data
 | 
					          mountPath: /data
 | 
				
			||||||
        - name: rsync-config
 | 
					 | 
				
			||||||
          mountPath: /run-rsync.sh
 | 
					 | 
				
			||||||
          subPath: run-rsync.sh
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
      volumes:
 | 
					      volumes:
 | 
				
			||||||
      - name: minecraft-data
 | 
					      - name: minecraft-data
 | 
				
			||||||
        persistentVolumeClaim:
 | 
					        persistentVolumeClaim:
 | 
				
			||||||
          claimName: minecraft-data
 | 
					          claimName: minecraft-data
 | 
				
			||||||
      - name: local-data
 | 
					 | 
				
			||||||
        emptyDir: {}
 | 
					 | 
				
			||||||
      - name: rsync-config
 | 
					 | 
				
			||||||
        configMap:
 | 
					 | 
				
			||||||
          name: rsync-config
 | 
					 | 
				
			||||||
          defaultMode: 0777
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -8,7 +8,6 @@ resources:
 | 
				
			|||||||
  - pvc.yaml
 | 
					  - pvc.yaml
 | 
				
			||||||
  - job.yaml
 | 
					  - job.yaml
 | 
				
			||||||
  - service.yaml
 | 
					  - service.yaml
 | 
				
			||||||
  - rsync.configmap.yaml
 | 
					 | 
				
			||||||
  - curseforge.sealedsecret.yaml
 | 
					  - curseforge.sealedsecret.yaml
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -16,9 +15,3 @@ images:
 | 
				
			|||||||
  - name: minecraft
 | 
					  - name: minecraft
 | 
				
			||||||
    newName: itzg/minecraft-server
 | 
					    newName: itzg/minecraft-server
 | 
				
			||||||
    newTag: java21
 | 
					    newTag: java21
 | 
				
			||||||
  - name: alpine
 | 
					 | 
				
			||||||
    newName: alpine
 | 
					 | 
				
			||||||
    newTag: "3.21"
 | 
					 | 
				
			||||||
  - name: rsync
 | 
					 | 
				
			||||||
    newName: eeacms/rsync
 | 
					 | 
				
			||||||
    newTag: "2.6"
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,42 +0,0 @@
 | 
				
			|||||||
apiVersion: v1
 | 
					 | 
				
			||||||
kind: ConfigMap
 | 
					 | 
				
			||||||
metadata:
 | 
					 | 
				
			||||||
  name: rsync-config
 | 
					 | 
				
			||||||
data:
 | 
					 | 
				
			||||||
  run-rsync.sh: |-
 | 
					 | 
				
			||||||
    #!/bin/sh
 | 
					 | 
				
			||||||
    set -eu
 | 
					 | 
				
			||||||
    echo "Starting rsync..."
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    no_change_count=0
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    while [ "$no_change_count" -lt 3 ]; do
 | 
					 | 
				
			||||||
      # use the i flag to get per line output of each change
 | 
					 | 
				
			||||||
      rsync_output=$(rsync -avzi --delete /local-data/ /persistent-data/)
 | 
					 | 
				
			||||||
      # echo "$rsync_output"
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      # in this format rsync outputs at least 4 lines:
 | 
					 | 
				
			||||||
      # ---
 | 
					 | 
				
			||||||
      # sending incremental file list
 | 
					 | 
				
			||||||
      #
 | 
					 | 
				
			||||||
      # sent 145,483 bytes  received 717 bytes  26,581.82 bytes/sec
 | 
					 | 
				
			||||||
      # total size is 708,682,765  speedup is 4,847.35
 | 
					 | 
				
			||||||
      # ---
 | 
					 | 
				
			||||||
      # even though a non-zero number of bytes is sent, no changes were made
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      line_count=$(echo "$rsync_output" | wc -l)
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      if [ "$line_count" -eq 4 ]; then
 | 
					 | 
				
			||||||
        echo "Rsync output was: $rsync_output"
 | 
					 | 
				
			||||||
        no_change_count=$((no_change_count + 1))
 | 
					 | 
				
			||||||
        echo "No changes detected. Incrementing no_change_count to $no_change_count."
 | 
					 | 
				
			||||||
      else
 | 
					 | 
				
			||||||
        no_change_count=0
 | 
					 | 
				
			||||||
        echo "Changes detected. Resetting no_change_count to 0."
 | 
					 | 
				
			||||||
      fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
      echo "Rsync completed. Sleeping for 10 minutes..."
 | 
					 | 
				
			||||||
      sleep 600
 | 
					 | 
				
			||||||
    done
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    echo "No changes detected for 3 consecutive runs. Exiting."
 | 
					 | 
				
			||||||
@@ -21,7 +21,7 @@ helmCharts:
 | 
				
			|||||||
  - name: redis
 | 
					  - name: redis
 | 
				
			||||||
    releaseName: redis
 | 
					    releaseName: redis
 | 
				
			||||||
    repo: https://charts.bitnami.com/bitnami
 | 
					    repo: https://charts.bitnami.com/bitnami
 | 
				
			||||||
    version: 20.13.2
 | 
					    version: 20.13.0
 | 
				
			||||||
    valuesInline:
 | 
					    valuesInline:
 | 
				
			||||||
      auth:
 | 
					      auth:
 | 
				
			||||||
        enabled: false
 | 
					        enabled: false
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,48 +0,0 @@
 | 
				
			|||||||
apiVersion: apps/v1
 | 
					 | 
				
			||||||
kind: Deployment
 | 
					 | 
				
			||||||
metadata:
 | 
					 | 
				
			||||||
  name: stump
 | 
					 | 
				
			||||||
spec:
 | 
					 | 
				
			||||||
  replicas: 1
 | 
					 | 
				
			||||||
  selector:
 | 
					 | 
				
			||||||
    matchLabels:
 | 
					 | 
				
			||||||
      app: stump
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  template:
 | 
					 | 
				
			||||||
    metadata:
 | 
					 | 
				
			||||||
      labels:
 | 
					 | 
				
			||||||
        app: stump
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    spec:
 | 
					 | 
				
			||||||
      containers:
 | 
					 | 
				
			||||||
      - name: stump
 | 
					 | 
				
			||||||
        image: stump
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        resources:
 | 
					 | 
				
			||||||
          requests:
 | 
					 | 
				
			||||||
            memory: "64Mi"
 | 
					 | 
				
			||||||
            cpu: "250m"
 | 
					 | 
				
			||||||
          limits:
 | 
					 | 
				
			||||||
            memory: "128Mi"
 | 
					 | 
				
			||||||
            cpu: "500m"
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
        ports:
 | 
					 | 
				
			||||||
        - containerPort: 10801
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        envFrom:
 | 
					 | 
				
			||||||
        - configMapRef:
 | 
					 | 
				
			||||||
            name: stump-config
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        volumeMounts:
 | 
					 | 
				
			||||||
        - name: stump-data
 | 
					 | 
				
			||||||
          mountPath: /data
 | 
					 | 
				
			||||||
        - name: stump-config
 | 
					 | 
				
			||||||
          mountPath: /config
 | 
					 | 
				
			||||||
        
 | 
					 | 
				
			||||||
      volumes:
 | 
					 | 
				
			||||||
      - name: stump-config
 | 
					 | 
				
			||||||
        persistentVolumeClaim:
 | 
					 | 
				
			||||||
          claimName: stump-config
 | 
					 | 
				
			||||||
      - name: stump-data
 | 
					 | 
				
			||||||
        persistentVolumeClaim:
 | 
					 | 
				
			||||||
          claimName: stump-data
 | 
					 | 
				
			||||||
@@ -1,17 +0,0 @@
 | 
				
			|||||||
apiVersion: traefik.io/v1alpha1
 | 
					 | 
				
			||||||
kind: IngressRoute
 | 
					 | 
				
			||||||
metadata:
 | 
					 | 
				
			||||||
  name: stump-ingressroute
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
spec:
 | 
					 | 
				
			||||||
  entryPoints:
 | 
					 | 
				
			||||||
    - websecure
 | 
					 | 
				
			||||||
  routes:
 | 
					 | 
				
			||||||
  - match: Host(`stump.kluster.moll.re`)
 | 
					 | 
				
			||||||
    kind: Rule
 | 
					 | 
				
			||||||
    services:
 | 
					 | 
				
			||||||
    - name: stump-web
 | 
					 | 
				
			||||||
      port: 10801
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  tls:
 | 
					 | 
				
			||||||
    certResolver: default-tls 
 | 
					 | 
				
			||||||
@@ -1,17 +0,0 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
apiVersion: kustomize.config.k8s.io/v1beta1
 | 
					 | 
				
			||||||
kind: Kustomization
 | 
					 | 
				
			||||||
resources: 
 | 
					 | 
				
			||||||
  - namespace.yaml
 | 
					 | 
				
			||||||
  - pvc.yaml
 | 
					 | 
				
			||||||
  - stump-config.configmap.yaml
 | 
					 | 
				
			||||||
  - deployment.yaml
 | 
					 | 
				
			||||||
  - service.yaml
 | 
					 | 
				
			||||||
  - ingress.yaml
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace: stump
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
images:
 | 
					 | 
				
			||||||
  - name: stump
 | 
					 | 
				
			||||||
    newName: aaronleopold/stump
 | 
					 | 
				
			||||||
    newTag: "0.0.10"
 | 
					 | 
				
			||||||
@@ -1,4 +0,0 @@
 | 
				
			|||||||
apiVersion: v1
 | 
					 | 
				
			||||||
kind: Namespace
 | 
					 | 
				
			||||||
metadata:
 | 
					 | 
				
			||||||
  name: placeholder
 | 
					 | 
				
			||||||
@@ -1,23 +0,0 @@
 | 
				
			|||||||
kind: PersistentVolumeClaim
 | 
					 | 
				
			||||||
apiVersion: v1
 | 
					 | 
				
			||||||
metadata:
 | 
					 | 
				
			||||||
  name: stump-data
 | 
					 | 
				
			||||||
spec:
 | 
					 | 
				
			||||||
  storageClassName: "nfs-client"
 | 
					 | 
				
			||||||
  accessModes:
 | 
					 | 
				
			||||||
    - ReadWriteOnce
 | 
					 | 
				
			||||||
  resources:
 | 
					 | 
				
			||||||
    requests:
 | 
					 | 
				
			||||||
      storage: 10Gi
 | 
					 | 
				
			||||||
---
 | 
					 | 
				
			||||||
kind: PersistentVolumeClaim
 | 
					 | 
				
			||||||
apiVersion: v1
 | 
					 | 
				
			||||||
metadata:
 | 
					 | 
				
			||||||
  name: stump-config
 | 
					 | 
				
			||||||
spec:
 | 
					 | 
				
			||||||
  storageClassName: "nfs-client"
 | 
					 | 
				
			||||||
  accessModes:
 | 
					 | 
				
			||||||
    - ReadWriteOnce
 | 
					 | 
				
			||||||
  resources:
 | 
					 | 
				
			||||||
    requests:
 | 
					 | 
				
			||||||
      storage: 10Gi
 | 
					 | 
				
			||||||
@@ -1,10 +0,0 @@
 | 
				
			|||||||
apiVersion: v1
 | 
					 | 
				
			||||||
kind: Service
 | 
					 | 
				
			||||||
metadata:
 | 
					 | 
				
			||||||
  name: stump-web
 | 
					 | 
				
			||||||
spec:
 | 
					 | 
				
			||||||
  selector:
 | 
					 | 
				
			||||||
    app: stump
 | 
					 | 
				
			||||||
  ports:
 | 
					 | 
				
			||||||
  - port: 10801
 | 
					 | 
				
			||||||
    targetPort: 10801
 | 
					 | 
				
			||||||
@@ -1,8 +0,0 @@
 | 
				
			|||||||
apiVersion: v1
 | 
					 | 
				
			||||||
kind: ConfigMap
 | 
					 | 
				
			||||||
metadata:
 | 
					 | 
				
			||||||
  name: stump-config
 | 
					 | 
				
			||||||
data:
 | 
					 | 
				
			||||||
  STUMP_ENABLE_UPLOAD: "true"
 | 
					 | 
				
			||||||
  STUMP_CONFIG_DIR: /config
 | 
					 | 
				
			||||||
  ENABLE_KOREADER_SYNC: "true"
 | 
					 | 
				
			||||||
@@ -29,5 +29,5 @@ helmCharts:
 | 
				
			|||||||
  - name: prometheus-node-exporter
 | 
					  - name: prometheus-node-exporter
 | 
				
			||||||
    releaseName: prometheus-node-exporter
 | 
					    releaseName: prometheus-node-exporter
 | 
				
			||||||
    repo: https://prometheus-community.github.io/helm-charts
 | 
					    repo: https://prometheus-community.github.io/helm-charts
 | 
				
			||||||
    version: 4.45.3
 | 
					    version: 4.45.2
 | 
				
			||||||
    valuesFile: prometheus-node-exporter.values.yaml
 | 
					    valuesFile: prometheus-node-exporter.values.yaml
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -13,6 +13,6 @@ namespace: traefik-system
 | 
				
			|||||||
helmCharts:
 | 
					helmCharts:
 | 
				
			||||||
  - name: traefik
 | 
					  - name: traefik
 | 
				
			||||||
    releaseName: traefik
 | 
					    releaseName: traefik
 | 
				
			||||||
    version: 35.2.0
 | 
					    version: 35.1.0
 | 
				
			||||||
    valuesFile: values.yaml
 | 
					    valuesFile: values.yaml
 | 
				
			||||||
    repo: https://traefik.github.io/charts
 | 
					    repo: https://traefik.github.io/charts
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -41,6 +41,5 @@ resources:
 | 
				
			|||||||
  - paperless/
 | 
					  - paperless/
 | 
				
			||||||
  - recipes/
 | 
					  - recipes/
 | 
				
			||||||
  - rss/
 | 
					  - rss/
 | 
				
			||||||
  - stump/
 | 
					 | 
				
			||||||
  - todos/
 | 
					  - todos/
 | 
				
			||||||
  - whoami/
 | 
					  - whoami/
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,18 +0,0 @@
 | 
				
			|||||||
apiVersion: argoproj.io/v1alpha1
 | 
					 | 
				
			||||||
kind: Application
 | 
					 | 
				
			||||||
metadata:
 | 
					 | 
				
			||||||
  name: stump-application
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
spec:
 | 
					 | 
				
			||||||
  project: apps
 | 
					 | 
				
			||||||
  destination:
 | 
					 | 
				
			||||||
    server: https://kubernetes.default.svc
 | 
					 | 
				
			||||||
    namespace: stump
 | 
					 | 
				
			||||||
  syncPolicy:
 | 
					 | 
				
			||||||
    automated:
 | 
					 | 
				
			||||||
      prune: true
 | 
					 | 
				
			||||||
      selfHeal: true
 | 
					 | 
				
			||||||
  sources:
 | 
					 | 
				
			||||||
    - repoURL: ssh://git@git.kluster.moll.re:2222/remoll/k3s-infra.git
 | 
					 | 
				
			||||||
      targetRevision: main
 | 
					 | 
				
			||||||
      path: apps/stump
 | 
					 | 
				
			||||||
@@ -1,4 +0,0 @@
 | 
				
			|||||||
apiVersion: kustomize.config.k8s.io/v1beta1
 | 
					 | 
				
			||||||
kind: Kustomization
 | 
					 | 
				
			||||||
resources:
 | 
					 | 
				
			||||||
  - application.yaml
 | 
					 | 
				
			||||||
		Reference in New Issue
	
	Block a user