Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server.properties not overwriten with env values #2638

Closed
MarvinKalchschmidt opened this issue Feb 5, 2024 · 1 comment
Closed

server.properties not overwriten with env values #2638

MarvinKalchschmidt opened this issue Feb 5, 2024 · 1 comment

Comments

@MarvinKalchschmidt
Copy link

Describe the problem

Hello itzg!

First and foremost: amazing work, I love how simple it is to setup a server with your image!
I'm currently working on hosting a minecraft server in a VPC cluster on IBM Cloud using HashiCorp Terraform for the provisioning.
So far I was able to create and connect to the server. I now set up some environment variables that are supposed to overwrite certain values in the server.properties file, because I want a certain seed)

The env variables were present in the container, but not in the server.properties file. I then tried to set "REPLACE_ENV_VARIABLES" to TRUE but got the same result. The server.properties file is not overwritten.

I'm probably just doing something wrong and this is not a bug with Terraform and your docker image, but I don't know what else it could be and I'm kinda running out of time for my submission ^^"

I'm happy to provide any additional information if need be.

Container definition

resource "kubernetes_deployment" "minecraft_server" {
  metadata {
    name      = var.kube_prefix
    namespace = kubernetes_namespace.minecraft_namespace.metadata.0.name
  }

  spec {
    replicas               = var.replicas
    revision_history_limit = 1

    selector {
      match_labels = {
        app = "${var.kube_prefix}"
      }
    }

    template {
      metadata {
        name = var.kube_prefix

        labels = {
          app = "${var.kube_prefix}"
        }
      }

      spec {
        container {
          name              = var.kube_prefix
          image             = var.minecraft_server_image
          image_pull_policy = var.image_pull_policy

          port {
            name           = var.port_name
            container_port = var.server_port
          }

          env {
            name  = "EULA"
            value = "TRUE"
          }

          env {
            name  = "REPLACE_ENV_VARIABLES"
            value = "TRUE"
          }

          dynamic "env" {
            for_each = var.minecraft_server_properties
            content {
              name  = env.value.name
              value = env.value.value
            }
          }

          env {
            name  = "OPS"
            value = var.operators_list
          }

          volume_mount {
            name       = "${var.kube_prefix}-data"
            mount_path = "/data"
          }

          liveness_probe {
            exec {
              command = ["/usr/local/bin/mc-monitor", "status", "--host", "localhost"]
            }

            initial_delay_seconds = 120
            period_seconds        = 60
          }

          readiness_probe {
            exec {
              command = ["/usr/local/bin/mc-monitor", "status", "--host", "localhost"]
            }

            initial_delay_seconds = 60
            period_seconds        = 5
            failure_threshold     = 20
          }

        }

        volume {
          name = "${var.kube_prefix}-data"
          empty_dir {

          }
        }
      }
    }
  }
}

Container logs

kubectl describe pod minecraft-server-7d487956-zq962
Name:             minecraft-server-7d487956-zq962
Namespace:        minecraft-server-namespace
Priority:         0
Service Account:  default
Node:             10.0.0.10/10.0.0.10
Start Time:       Mon, 05 Feb 2024 23:27:47 +0100
Labels:           app=minecraft-server
                  pod-template-hash=7d487956
Annotations:      cni.projectcalico.org/containerID: 49847ddba6d4da9fe22c88c8f9fee7c1b7b3f3307f85a8020a3d7e659a9b124d
                  cni.projectcalico.org/podIP: 
                  cni.projectcalico.org/podIPs: 
Status:           Running
IP:               
IPs:
  IP:           
Controlled By:  ReplicaSet/minecraft-server-7d487956
Containers:
  minecraft-server:
    Container ID:   containerd://981c6a7ff3f9dd2cd44a0fdc600845ffa7231e008b4205d66dfcfdf6de670b06
    Image:          itzg/minecraft-server
    Image ID:       docker.io/itzg/minecraft-server@sha256:78981d6671280fcaa1f7f26b8be7619770d882f1c60c423a399552a357b425dd
    Port:           25565/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Mon, 05 Feb 2024 23:27:48 +0100
    Ready:          True
    Restart Count:  0
    Liveness:       exec [/usr/local/bin/mc-monitor status --host localhost] delay=120s timeout=1s period=60s #success=1 #failure=3
    Readiness:      exec [/usr/local/bin/mc-monitor status --host localhost] delay=60s timeout=1s period=5s #success=1 #failure=20
    Environment:
      EULA:                   TRUE
      REPLACE_ENV_VARIABLES:  TRUE
      allow-flight:           false
      allow-nether:           true
      difficulty:             easy
      gamemode:               survival
      generate-structures:    true
      hardcore:               false
      level-name:             Minecraft on Kubernetes
      level-seed:             903249166344263133
      max-players:            10
      motd:                   Deployed with Terraform!!!
      pvp:                    true
      rcon.password:
      rcon.port:              25575
      server-ip:
      server-port:            25565
      spawn-animals:          true
      spawn-monsters:         true
      spawn-npcs:             true
      spawn-protection:       16
      view-distance:          16
      white-list:             false
      OPS:                    Haikun
    Mounts:
      /data from minecraft-server-data (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-bnbj8 (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             True
  ContainersReady   True
  PodScheduled      True
Volumes:
  minecraft-server-data:
    Type:       EmptyDir (a temporary directory that shares a pod's lifetime)
    Medium:
    SizeLimit:  <unset>
  kube-api-access-bnbj8:
    Type:                    Projected (a volume that contains injected data from multiple sources)
    TokenExpirationSeconds:  3607
    ConfigMapName:           kube-root-ca.crt
    ConfigMapOptional:       <nil>
    DownwardAPI:             true
QoS Class:                   BestEffort
Node-Selectors:              <none>
Tolerations:                 node.kubernetes.io/not-ready:NoExecute op=Exists for 600s
                             node.kubernetes.io/unreachable:NoExecute op=Exists for 600s
Events:
  Type     Reason     Age                     From               Message
  ----     ------     ----                    ----               -------
  Normal   Scheduled  5m53s                   default-scheduler  Successfully assigned minecraft-server-namespace/minecraft-server-7d487956-zq962 to 10.0.0.10
  Normal   Pulled     5m52s                   kubelet            Container image "itzg/minecraft-server" already present on machine
  Normal   Created    5m52s                   kubelet            Created container minecraft-server
  Normal   Started    5m52s                   kubelet            Started container minecraft-server
  Warning  Unhealthy  3m42s (x15 over 4m47s)  kubelet            Readiness probe failed: failed to ping localhost:25565 : EOF
@MarvinKalchschmidt
Copy link
Author

Nevermind, I'm just stupid and used the exact server.properties spelling instead the required uppercase spelling


variable "minecraft_server_properties" {
  description = "List of Minecraft server properties."
  type = list(object({
    name  = string
    value = string
  }))
  default = [
    { name = "allow-flight", value = "false" },
    { name = "allow-nether", value = "true" },
    { name = "difficulty", value = "easy" },
    { name = "gamemode", value = "survival" },
    { name = "generate-structures", value = "true" },
    { name = "hardcore", value = "false" },
    { name = "level-name", value = "Minecraft on Kubernetes" },
    { name = "level-seed", value = "903249166344263133" },
    { name = "max-players", value = "10" },
    { name = "motd", value = "Deployed with Terraform!!!" },
    { name = "pvp", value = "true" },
    { name = "rcon.password", value = "" },
    { name = "rcon.port", value = "25575" },
    { name = "server-ip", value = "" },
    { name = "server-port", value = "25565" },
    { name = "spawn-animals", value = "true" },
    { name = "spawn-monsters", value = "true" },
    { name = "spawn-npcs", value = "true" },
    { name = "spawn-protection", value = "16" },
    { name = "view-distance", value = "16" },
    { name = "white-list", value = "false" },
  ]
}

@MarvinKalchschmidt MarvinKalchschmidt closed this as not planned Won't fix, can't repro, duplicate, stale Feb 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant