local kube = import "k8s/configs/base.libsonnet"; local linuxserver = import "k8s/configs/templates/core/linuxserver.libsonnet"; local images = import "k8s/configs/images.libsonnet"; local probe(delaySeconds) = { initialDelaySeconds: delaySeconds, periodSeconds: 30, tcpSocket: { port: "http", }, }; local WebPort = 25565; local RconPort = 25575; local Params = kube.simpleFieldStruct([ "namespace", "name", "filePath", "dataClaimName", ]) { labels: {}, gatekeeperSidecar: null, lsParams: linuxserver.AppParams { name: $.name, namespace: $.namespace, filePath: $.filePath, templatePath: std.thisFile, baseAppName: "minecraft-server", imageName: "itzg/minecraft-server", labels+: $.labels, gatekeeperSidecar: $.gatekeeperSidecar, env: linuxserver.Env { others: [ kube.NameVal("TYPE", "AUTO_CURSEFORGE"), //kube.NameVal("CF_PAGE_URL", "https://www.curseforge.com/minecraft/modpacks/sevtech-ages"), //kube.NameVal("CF_PAGE_URL", "https://www.curseforge.com/minecraft/modpacks/enigmatica6"), //kube.NameVal("CF_PAGE_URL", "https://www.curseforge.com/minecraft/modpacks/skyfactory-4"), kube.NameVal("CF_PAGE_URL", "https://www.curseforge.com/minecraft/modpacks/all-the-mods-10"), kube.NameVal("EULA", "true"), //kube.NameVal("VERSION", "1.16.5"), //kube.NameVal("VERSION", "1.12.2"), kube.NameVal("VERSION", "1.21.1"), kube.NameVal("CF_API_KEY", "$2a$10$HVmLnTPrGzIYVFvmIKY92.qqeZcwzVk7lfNmoJjDuCSBivw5dO4Fq"), kube.NameVal("MOTD", "Welcome!"), kube.NameVal("DIFFICULTY", "easy"), kube.NameVal("VIEW_DISTANCE", "20"), kube.NameVal("OPS", "LIMIT_ACM"), kube.NameVal("MEMORY", "8G"), kube.NameVal("ALLOW_FLIGHT", "TRUE"), kube.NameVal("ENABLE_RCON", "true"), kube.NameVal("RCON_PASSWORD", "example-password"), kube.NameVal("SNOOPER_ENABLED", "false"), kube.NameVal("MAX_BUILD_HEIGHT", "512"), ] }, services: [ linuxserver.Service { suffix: "ui", spec: { type: "ClusterIP", ports: [ kube.SvcUtil.TCPServicePort("http", 80) { targetPort: WebPort }, ], }, }, linuxserver.Service { suffix: "rcon", spec: kube.SvcUtil.BasicHttpClusterIpSpec(RconPort) }, ], ports: [ kube.DeployUtil.ContainerPort("http", WebPort), kube.DeployUtil.ContainerPort("http-rcon", RconPort), ], pvcs: [ linuxserver.Pvc{ name: "data", mountPath: "/data", bindName: $.dataClaimName, }, ], resources: { requests: { cpu: "2000m", memory: "8000Mi", }, limits: { cpu: "3000m", memory: "10000Mi", }, }, livenessProbe: probe(/*delaySeconds=*/250), readinessProbe: probe(/*delaySeconds=*/250), }, }; local App(params) = linuxserver.App(params.lsParams); { Params: Params, WebPort: WebPort, App(params): App(params), }