| local kube = import '../../../../kube/hscloud.libsonnet'; |
| |
| { |
| local top = self, |
| local cfg = top.cfg, |
| |
| cfg:: { |
| name: 'palworld-palid', |
| secrets_name: 'palworld', |
| namespace: 'personal-palid', |
| // https://github.com/jammsen/docker-palworld-dedicated-server |
| // Build from 30.01.2024 |
| image: 'jammsen/palworld-dedicated-server:b41946c', |
| storage_class_name: 'waw-hdd-redundant-3', |
| game_path: '/palworld', |
| game_port: 8211, |
| game_port_2: 27015, |
| rcon_port: 25575, |
| // LoadBalancerIP |
| public_ip: '185.236.240.55', |
| }, |
| |
| local ns = kube.Namespace(cfg.namespace), |
| |
| secretRefs:: { |
| // Uses basic auth |
| adminPassword: { secretKeyRef: { name: cfg.secrets_name, key: 'admin_password' } }, |
| |
| }, |
| |
| deployment: ns.Contain(kube.Deployment(cfg.name)) { |
| spec+: { |
| template+: { |
| spec+: { |
| volumes_: { |
| palworld: top.game_storage.volume, |
| }, |
| containers_: { |
| default: kube.Container('default') { |
| livenessProbe: { |
| exec: { |
| command: [ |
| '/bin/bash', |
| '-c', |
| 'rconcli save', |
| 'rconcli "broadcast IMPORTANT:Rebooting-server-in-5-minutes!"', |
| 'sleep 5min', |
| 'rconcli save', |
| 'rconcli "shutdown 10 REBOOTING"', |
| ], |
| }, |
| failureThreshold: 1, |
| periodSeconds: 21600, |
| }, |
| resources: { |
| requests: { |
| cpu: '4', |
| memory: '32Gi', |
| }, |
| limits: { |
| memory: '34Gi', |
| }, |
| }, |
| image: cfg.image, |
| ports_: { |
| game_port: { containerPort: cfg.game_port, protocol: 'UDP' }, |
| game_port_2: { containerPort: cfg.game_port_2, protocol: 'UDP' }, |
| rcon: { |
| containerPort: cfg.rcon_port, |
| }, |
| }, |
| env_: { |
| ALWAYS_UPDATE_ON_START: true, |
| MAX_PLAYERS: 32, |
| MULTITHREAD_ENABLED: true, |
| COMMUNITY_SERVER: false, |
| RCON_ENABLED: true, |
| RCON_PORT: cfg.rcon_port, |
| PUBLIC_IP: cfg.public_ip, |
| PUBLIC_PORT: cfg.game_port, |
| SERVER_NAME: 'hswaw and friends', |
| SERVER_DESCRIPTION: 'Totally not war and building crimes', |
| SERVER_PASSWORD: '2137', |
| ADMIN_PASSWORD: top.secretRefs.adminPassword, |
| |
| // game settings |
| // Limit server ticks to 60fps to reduce rubber banding (default is 120) |
| NETSERVERMAXTICKRATE: 60, |
| ENABLE_NON_LOGIN_PENALTY: false, |
| REGION: 'eu', |
| |
| }, |
| volumeMounts_: { |
| palworld: { mountPath: cfg.game_path }, |
| }, |
| }, |
| }, |
| }, |
| }, |
| }, |
| }, |
| |
| game_storage: ns.Contain(kube.PersistentVolumeClaim(cfg.name)) { |
| storage:: '100Gi', |
| storageClass:: cfg.storage_class_name, |
| }, |
| |
| |
| service: ns.Contain(kube.Service(cfg.name)) { |
| target:: top.deployment, |
| spec+: { |
| ports: [ |
| { |
| name: 'game', |
| port: cfg.game_port, |
| targetPort: cfg.game_port, |
| protocol: 'UDP', |
| }, |
| { |
| name: 'game-2', |
| port: cfg.game_port_2, |
| targetPort: cfg.game_port_2, |
| protocol: 'UDP', |
| }, |
| ], |
| type: 'LoadBalancer', |
| externalTrafficPolicy: 'Local', |
| // loadBalancerIP: cfg.public_ip, |
| }, |
| }, |
| |
| } |