Renegade-Master / zomboid-dedicated-server

Linux based Docker image containing a Dedicated Server for Project Zomboid.
https://hub.docker.com/r/renegademaster/zomboid-dedicated-server
Other
177 stars 60 forks source link

Server installation fails on K8s #26

Closed Marahin closed 2 years ago

Marahin commented 2 years ago

Describe the bug Hello! I am trying to deploy PZ using this image on Kubernetes (with storage being mounted through NFS), however the installation steps are failing.

To Reproduce Steps to reproduce the behavior:

  1. Create all necessary Kubernetes manifests:
    ---
    apiVersion: apps/v1
    kind: Deployment
    metadata:
    annotations: {}
    labels:
    name: zomboid
    name: zomboid
    namespace: zomboid
    spec:
    minReadySeconds: 30
    replicas: 1
    revisionHistoryLimit: 10
    selector:
    matchLabels:
      name: zomboid
    strategy:
    rollingUpdate:
      maxSurge: 0
      maxUnavailable: 1
    type: RollingUpdate
    template:
    metadata:
      annotations: {}
      labels:
        name: zomboid
    spec:
      containers:
      - args: []
        env: []
        image: renegademaster/zomboid-dedicated-server:latest
        imagePullPolicy: Always
        name: zomboid
        ports:
        - containerPort: 8766
          name: game
        - containerPort: 16261
          name: query
        - containerPort: 27015
          name: rcon
        stdin: false
        tty: false
        volumeMounts:
        - mountPath: /home/steam/Zomboid
          name: config
        - mountPath: /home/steam/ZomboidDedicatedServer
          name: data
      imagePullSecrets: []
      initContainers: []
      securityContext:
        runAsGroup: 1017
        runAsUser: 1017
      terminationGracePeriodSeconds: 30
      volumes:
      - name: config
        persistentVolumeClaim:
          claimName: zomboid-config-pvc
      - name: data
        persistentVolumeClaim:
          claimName: zomboid-data-pvc
    ---
    apiVersion: v1
    kind: Namespace
    metadata:
    annotations: {}
    labels:
    name: zomboid
    name: zomboid
    ---
    apiVersion: v1
    kind: PersistentVolume
    metadata:
    annotations: {}
    labels:
    name: zomboid-config-pv
    name: zomboid-config-pv
    namespace: zomboid
    spec:
    accessModes:
    - ReadWriteOnce
    capacity:
    storage: 5Gi
    mountOptions:
    - nfsvers=4
    nfs:
    path: /mnt/ssd-pool/zomboid/config
    server: storagemaster.local
    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
    annotations:
    volume.beta.kubernetes.io/mount-options: dir_mode=0777,file_mode=0777,uid=1017,gid=1017
    labels:
    name: zomboid-config-pvc
    name: zomboid-config-pvc
    namespace: zomboid
    spec:
    accessModes:
    - ReadWriteOnce
    resources:
    requests:
      storage: 5Gi
    storageClassName: ""
    volumeName: zomboid-config-pv
    ---
    apiVersion: v1
    kind: PersistentVolumeClaim
    metadata:
    annotations:
    volume.beta.kubernetes.io/mount-options: dir_mode=0777,file_mode=0777,uid=1017,gid=1017
    labels:
    name: zomboid-data-pvc
    name: zomboid-data-pvc
    namespace: zomboid
    spec:
    accessModes:
    - ReadWriteOnce
    resources:
    requests:
      storage: 50Gi
    storageClassName: ""
    volumeName: zomboid-data-pv
    ---
    apiVersion: v1
    kind: PersistentVolume
    metadata:
    annotations: {}
    labels:
    name: zomboid-data-pv
    name: zomboid-data-pv
    namespace: zomboid
    spec:
    accessModes:
    - ReadWriteOnce
    capacity:
    storage: 50Gi
    mountOptions:
    - nfsvers=4
    nfs:
    path: /mnt/ssd-pool/zomboid/data
    server: storagemaster.local
  2. Ensure NFS is available and path /mnt/ssd-pool/zomboid has two subdirectories: data and config, both set to chown 1017:1017 (zomboid:zomboid)
  3. Apply the manifests

Expected behavior Container starting up, eventually running the server.

Actual behavior Container fails to run steamcmd.sh due to lack of permissions (the script is owned by steam:steam user, and when I run id steam within the container, it resolves to 1000:1000 - while the container runtime is already set to 1017:1017, which is zomboid:zomboid user).

### Setting variables...

### Updating Folder Permissions...

### Folder Permissions updated.

### Applying Pre Install Configuration...
sed: couldn't open temporary file /home/steam/sedABDtJB: Permission denied

### Pre Install Configuration applied.

### Updating Project Zomboid Server...
/home/steam/run_server.sh: line 130: /home/steam/steamcmd.sh: Permission denied

### Project Zomboid Server updated.

### Checking if this is the first run...

### This is the first run.
Starting server for 60 seconds

### Starting Project Zomboid Server...
timeout: failed to run command '/home/steam/ZomboidDedicatedServer/start-server.sh': No such file or directory

### Project Zomboid Server stopped.

### First run check complete.

### Applying Post Install Configuration...
/home/steam/Zomboid/Server/ZomboidServer.ini not found!
/home/steam/Zomboid/Server/ZomboidServer.ini not found!
/home/steam/Zomboid/Server/ZomboidServer.ini not found!
/home/steam/Zomboid/Server/ZomboidServer.ini not found!
/home/steam/Zomboid/Server/ZomboidServer.ini not found!
/home/steam/Zomboid/Server/ZomboidServer.ini not found!
/home/steam/Zomboid/Server/ZomboidServer.ini not found!
/home/steam/Zomboid/Server/ZomboidServer.ini not found!
/home/steam/Zomboid/Server/ZomboidServer.ini not found!
/home/steam/Zomboid/Server/ZomboidServer.ini not found!
/home/steam/Zomboid/Server/ZomboidServer.ini not found!
/home/steam/Zomboid/Server/ZomboidServer.ini not found!
sed: can't read /home/steam/ZomboidDedicatedServer/ProjectZomboid64.json: No such file or directory

### Post Install Configuration applied.

### Starting Project Zomboid Server...
timeout: failed to run command '/home/steam/ZomboidDedicatedServer/start-server.sh': No such file or directory

### Project Zomboid Server stopped.

Screenshots If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

Additional context Add any other context about the problem here.

Marahin commented 2 years ago

In order to get past this issue, what I had to do is match uid and gid set in Dockerfile to the ones of my NFS user (1017). https://github.com/Marahin/zomboid-dedicated-server/commit/f322c954c4082c735b6b5a46c0c229b5971d0dd1

Is there any way to achieve that without having to resolve to build my custom image?

Renegade-Master commented 2 years ago

Hey, thanks for trying this out on K8S. I was meaning to give it a go, but never got around to it properly.

To be honest, I would say you are running into much the same issue that #19 and #24 are suffering from. I need to revise how I am handling folder permissions as there is definitely something going wrong between the SteamCMD base image, and the user actually deploying the Zomboid Container.

I am quite busy at the moment with other things, so I may not be able to address this particularly quickly. I would say that fixing the permissions issue will fix most of the problems people have been seeing.

If you have any ideas in the meantime, please feel free to make a PR on this or the SteamCMD repo that is reachable from my profile. 🙂

Is there any way to achieve that without having to resolve to build my custom image?

You should be able to override those if you set the build arguments for the Image.

And the worst you should have to do is to build the steamcmd-minimal image with your own IDs. Not ideal, I know. This is part of what I want to address.

Renegade-Master commented 2 years ago

Please comment or reopen if your issue still exists in the most recent version: 2.0.0