Skip to content

Commit

Permalink
Updates to support k8s 1.29.4, newer steamcmd container, DayZ linux d…
Browse files Browse the repository at this point in the history
…edicated server support
  • Loading branch information
razorbladex401 committed Apr 28, 2024
1 parent cf2457a commit 6c4a4db
Show file tree
Hide file tree
Showing 9 changed files with 109 additions and 83 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

Run a DayZ Dedicated Server on Kubernetes.

Will deploy a DayZ Dedicated Server on your K8s cluster. It deploys the linux experimental server and you must use the experimental client to connect to it. Currently this is a vanilla deployment of the server.
Will deploy a DayZ Dedicated Server on your K8s cluster. It deploys the linux server which is now available in the stable branch (main game client), see https://community.bistudio.com/wiki/DayZ:Hosting_a_Linux_Server . Currently this is a vanilla deployment of the server.

Docker container based off the steamcmd container. Read the k8s readme before using.
Docker container based off the steamcmd container. Read the k8s readme before using. It is NOT meant to be fully fleshed out but a starting point for your own server.

# TODO
* Add installing DayZ mod's.
8 changes: 5 additions & 3 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ RUN useradd -m steam \
&& apt-get install -y net-tools \
&& apt-get install -y nano \
&& apt-get install -y vim \
&& apt-get install -y netcat \
&& apt-get install -y dnsutils \
&& apt-get install -y \
lib32gcc1 \
lib32gcc-s1 \
libcap-dev \
libcurl4 \
libcurl4-openssl-dev \
Expand All @@ -21,7 +23,7 @@ USER steam
ENV USER steam
ENV HOME /home/steam
ENV GAME dayz
ENV APPID 1042420
ENV APPID 223350
ENV STEAMACCOUNT anonymous
ENV STEAMPASSWORD ${1:+1}
ENV CPUCOUNT 2
Expand All @@ -30,7 +32,7 @@ ENV PORT 2302
WORKDIR /home/steam

# permissions
RUN mkdir ${HOME}/${game} && \
RUN mkdir ${HOME}/${GAME} && \
mkdir ${HOME}/profile && \
mkdir ${HOME}/battleye && \
chown -R steam:steam ${HOME}
Expand Down
2 changes: 1 addition & 1 deletion docker/entry.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

function updateGame() {
steamcmd \
+force_install_dir ${HOME}/${GAME} \
+login ${STEAMACCOUNT} ${STEAMPASSWORD} \
+force_install_dir ${HOME}/${GAME} \
+app_update ${APPID} \
+quit
}
Expand Down
4 changes: 2 additions & 2 deletions k8s/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# k8s
This has been tested against Kubernetes v1.23.6 with Metallb v0.12.1 and nfs-subdir-external-provisioner v4.0.13.
This has been tested against Kubernetes v1.29.4 with Cilium 1.15.4 (in kubeproxyless mode) and nfs-subdir-external-provisioner v4.0.18.

### configmap.yaml
Contains the serverDZ.cfg and BEServer_x64.cfg files. You'll want to add your own configuration here.
Expand Down Expand Up @@ -27,7 +27,7 @@ Creates the PVC's that the deployment uses. Current PVC's:
Creates the secret that contains the ssh username and password. You have to base64 encode both values.

### svc.yaml
Creates the K8s service that you can use to connect to the pod. Note that in my environment I'm using metallb in layer2 mode. This is enough for my configuration but you may have different needs. The svc.yaml file expects that you will specify the IP for the pod. It creates two services, one for udp and the other for tcp ports.
Creates the service with the appropriate ports needed. Since this is all been tested with cilium you'll want to make sure that you're using a verison that supports loadbalancer type.

### cronjob.yaml
Configures the cronjob that triggers a restart of the deployment every X hours. By default it's set to 12 hours.
Expand Down
85 changes: 56 additions & 29 deletions k8s/configmap.yaml
Original file line number Diff line number Diff line change
@@ -1,38 +1,66 @@
---
---
apiVersion: v1
data:
serverDZ.cfg: |
hostname = "YOUR SERVER NAME";
password = "";
passwordAdmin = "";
maxPlayers = 30;
verifySignatures = 2;
forceSameBuild = 1;
disableVoN = 0;
vonCodeQuality = 20;
disable3rdPerson = 1;
disableCrosshair = 0;
serverTime = "SystemTime";
serverTimeAcceleration = 30;
serverNightTimeAcceleration = 2;
serverTimePersistent = 0;
guaranteedUpdates = 1;
loginQueueConcurrentPlayers = 5;
loginQueueMaxPlayers = 500;
instanceId = 1;
storageAutoFix = 0;
steamQueryPort = 27016;
maxPing = 100;
logFile = "server_console.log";
hostname="YOUR HOSTNAME";
passwordAdmin="YOUR ADMIN PASSWORD";
enableCfgGameplayFile=1
enableWhitelist=0;
maxPlayers=60;
verifySignatures=2;
forceSameBuild=1;
disableVoN=0;
vonCodecQuality=20;
disable3rdPerson=1;
disableCrosshair=0;
serverTime="SystemTime";
serverTimeAcceleration=2.5;
serverNightTimeAcceleration=20;
serverTimePersistent=0;
guaranteedUpdates=1;
loginQueueConcurrentPlayers=5;
loginQueueMaxPlayers=500;
instanceId=1;
storageAutoFix=1;
motd[]=
{
"Under",
"Construction"
};
motdInterval=1;
maxPing=100;
timeStampFormat="Short";
logAverageFps=1;
logMemory=1;
logPlayers=1;
logFile="server_console.log";
adminLogPlayerHitsOnly=0;
adminLogPlacement=0;
adminLogBuildActions=0;
adminLogPlayerList=0;
enableDebugMonitor=0;
allowFilePatching=1;
simulatedPlayersBatch=20;
multithreadedReplication=1;
networkRangeClose=20;
networkRangeNear=150;
networkRangeFar=1000;
networkRangeDistantEffect=4000;
defaultVisibility=1375;
defaultObjectViewDistance=1375;
lightingConfig=0;
disablePersonalLight=1;
disableBaseDamage=0;
disableContainerDamage=0;
class Missions
{
class DayZ
{
template = "dayzOffline.chernarusplus";
};
class DayZ
{
template="dayzOffline.chernarusplus";
};
};
kind: ConfigMap
metadata:
metadata:
name: dayz-server-cfg
namespace: dayz
---
Expand All @@ -46,4 +74,3 @@ kind: ConfigMap
metadata:
name: dayz-beserver-cfg
namespace: dayz

2 changes: 1 addition & 1 deletion k8s/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
namespace: dayz
spec:
concurrencyPolicy: Forbid
schedule: '0 */12 * * *' # Run every 12 hours
schedule: '0 */4 * * *' # Run every 4 hours
jobTemplate:
spec:
backoffLimit: 2
Expand Down
25 changes: 14 additions & 11 deletions k8s/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ spec:
app: dayz
spec:
volumes:
- name: ssh-config
persistentVolumeClaim:
claimName: ssh-config-pvc
- name: dayz-data
persistentVolumeClaim:
claimName: dayz-data-pvc
- name: dayz-profile
persistentVolumeClaim:
claimName: dayz-profile-pvc
- name: ssh-config
persistentVolumeClaim:
claimName: ssh-config-pvc
- name: dayz-server-cfg
configMap:
name: dayz-server-cfg
Expand Down Expand Up @@ -61,11 +61,19 @@ spec:
- name: HOME
value: /home/steam
- name: APPID
value: "1042420"
value: "223350"
- name: STEAMACCOUNT
value: anonymous
valueFrom:
secretKeyRef:
name: steamaccount
key: STEAMACCOUNT
- name: STEAMPASSWORD
valueFrom:
secretKeyRef:
name: steamaccount
key: STEAMPASSWORD
- name: CPUCOUNT
value: "2"
value: "4"
- name: PORT
value: "2302"
- name: openssh-server
Expand All @@ -82,11 +90,6 @@ spec:
value: "false"
- name: PASSWORD_ACCESS
value: "true"
- name: USER_NAME
valueFrom:
secretKeyRef:
name: ssh-sec
key: USER_NAME
- name: USER_PASSWORD
valueFrom:
secretKeyRef:
Expand Down
17 changes: 15 additions & 2 deletions k8s/secrets.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -7,5 +8,17 @@ metadata:
app: dayz
type: Opaque
data:
USER_NAME: <base64 encoded username>
USER_PASSWORD: <base64 encoded password>
USER_NAME: BASE64 USERNAME FOR SSH
USER_PASSWORD: BASE64 PASSWORD
---
apiVersion: v1
kind: Secret
metadata:
name: steamaccount
namespace: dayz
labels:
app: dayz
type: Opaque
data:
STEAMACCOUNT: BASE64 STEAMACCOUNT
STEAMPASSWORD: BASE64 STEAMACCOUNT PASSWORD
43 changes: 13 additions & 30 deletions k8s/svc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,22 @@ kind: Service
metadata:
labels:
app: dayz
name: dayz-udp
name: dayz
namespace: dayz
annotations:
metallb.universe.tf/allow-shared-ip: "YOUR IP HERE"
spec:
ports:
- name: ssh
port: 2222
targetPort: 2222
protocol: TCP
- name: steam-tcp
port: 27016
protocol: TCP
targetPort: 27016
- name: rcon
port: 2310
protocol: TCP
targetPort: 2310
- name: steam
port: 27016
protocol: UDP
Expand All @@ -32,30 +42,3 @@ spec:
selector:
app: dayz
type: LoadBalancer
loadBalancerIP: YOUR IP HERE
---
apiVersion: v1
kind: Service
metadata:
labels:
app: dayz
name: dayz-tcp
namespace: dayz
annotations:
metallb.universe.tf/allow-shared-ip: "YOUR IP HERE"
spec:
ports:
- name: ssh
port: 2222
- name: steam-tcp
port: 27016
protocol: TCP
targetPort: 27016
- name: rcon
port: 2310
protocol: TCP
targetPort: 2310
selector:
app: dayz
type: LoadBalancer
loadBalancerIP: YOUR IP HERE

0 comments on commit 6c4a4db

Please sign in to comment.