├── .gitmodules ├── README.md ├── build └── Dockerfile ├── bungee-op ├── build │ └── Dockerfile ├── deploy │ ├── crds │ │ ├── mcserverhosting.net_bungeedeployments_crd.yaml │ │ └── mcserverhosting.net_v2_bungeedeployment_cr.yaml │ ├── operator.yaml │ ├── role.yaml │ ├── role_binding.yaml │ └── service_account.yaml ├── helm-charts │ └── bungee-deployment └── watches.yaml ├── deploy ├── crds │ ├── deployments.mcserverhosting.net_bungee_crd.yaml │ ├── deployments.mcserverhosting.net_ns_crd.yaml │ ├── deployments.mcserverhosting.net_server_crd.yaml │ └── deployments.mcserverhosting.net_sftp_crd.yaml ├── examples │ ├── 1.18+.yaml │ ├── bungee.yaml │ ├── restriction.yaml │ ├── server.yaml │ └── sftp.yaml ├── operator.yaml ├── role.yaml ├── role_binding.yaml └── service_account.yaml ├── server-op ├── build │ └── Dockerfile ├── deploy │ ├── crds │ │ ├── mcserverhosting.net_minecraftservers_crd.yaml │ │ └── mcserverhosting.net_v2_minecraftserver_cr.yaml │ ├── operator.yaml │ ├── role.yaml │ ├── role_binding.yaml │ └── service_account.yaml ├── helm-charts │ └── server-deployment │ │ ├── .helmignore │ │ ├── Chart.yaml │ │ ├── README.md │ │ ├── README.md.gotmpl │ │ ├── magma-example.yaml │ │ ├── templates │ │ ├── host-keys.yaml │ │ ├── preinstall.yaml │ │ ├── server-config.yaml │ │ ├── server-statefulset.yaml │ │ ├── service-external-name.yaml │ │ ├── service.yaml │ │ └── tests │ │ │ ├── domain-ownership-text.yaml │ │ │ └── test-server-connection.yaml │ │ ├── values-minimal-example.yaml │ │ └── values.yaml └── watches.yaml └── watches.yaml /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "charts"] 2 | path = charts 3 | url = https://github.com/mcserverhosting-net/charts 4 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | `kubectl create -f mcsh-operator/deploy/crds` 3 | 4 | ``` 5 | root@vps207526:~/mcsh-op/mcsh-operator/deploy/crds# kubectl get crd | grep mcserverhosting.net 6 | bungeeservers.deployments.mcserverhosting.net 2020-03-30T11:51:41Z 7 | minecraftservers.deployments.mcserverhosting.net 2020-03-30T11:51:12Z 8 | restrictions.deployments.mcserverhosting.net 2020-03-30T11:51:12Z 9 | sftpservers.deployments.mcserverhosting.net 2020-03-30T11:51:12Z 10 | ``` 11 | 12 | Ensure you [create a pull secret based on existing docker credentials](https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/#registry-secret-existing-credentials) as [github requires login for pulls](https://github.community/t5/How-to-use-Git-and-GitHub/Error-response-from-daemon-unauthorized-when-I-m-trying-to-pull/m-p/37129/highlight/true#M9382). 13 | 14 | `kubectl create -f mcsh-operator/deploy` 15 | 16 | ``` 17 | {"level":"info","ts":1585569489.7739913,"logger":"controller-runtime.controller","msg":"Starting Controller","controller":"restriction-controller"} 18 | {"level":"info","ts":1585569489.7740645,"logger":"controller-runtime.controller","msg":"Starting workers","controller":"restriction-controller","worker count":1} 19 | {"level":"info","ts":1585569489.7745423,"logger":"controller-runtime.controller","msg":"Starting Controller","controller":"minecraftserver-controller"} 20 | {"level":"info","ts":1585569489.7745798,"logger":"controller-runtime.controller","msg":"Starting workers","controller":"minecraftserver-controller","worker count":1} 21 | {"level":"info","ts":1585569489.7751055,"logger":"controller-runtime.controller","msg":"Starting Controller","controller":"sftpserver-controller"} 22 | {"level":"info","ts":1585569489.775135,"logger":"controller-runtime.controller","msg":"Starting workers","controller":"sftpserver-controller","worker count":1} 23 | {"level":"info","ts":1585569489.7751753,"logger":"controller-runtime.controller","msg":"Starting Controller","controller":"bungeeserver-controller"} 24 | {"level":"info","ts":1585569489.775251,"logger":"controller-runtime.controller","msg":"Starting workers","controller":"bungeeserver-controller","worker count":1} 25 | ``` 26 | -------------------------------------------------------------------------------- /build/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM quay.io/operator-framework/helm-operator:v0.17.0 2 | 3 | COPY watches.yaml ${HOME}/watches.yaml 4 | COPY charts/ ${HOME}/charts/ -------------------------------------------------------------------------------- /bungee-op/build/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM quay.io/operator-framework/helm-operator:v0.17.0 2 | 3 | COPY watches.yaml ${HOME}/watches.yaml 4 | COPY helm-charts/ ${HOME}/helm-charts/ 5 | -------------------------------------------------------------------------------- /bungee-op/deploy/crds/mcserverhosting.net_bungeedeployments_crd.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apiextensions.k8s.io/v1 2 | kind: CustomResourceDefinition 3 | metadata: 4 | name: bungeedeployments.mcserverhosting.net 5 | spec: 6 | group: mcserverhosting.net 7 | names: 8 | kind: BungeeDeployment 9 | shortNames: 10 | - bungee 11 | - bs 12 | - bungees 13 | listKind: BungeeDeploymentList 14 | plural: bungeedeployments 15 | singular: bungeedeployment 16 | scope: Namespaced 17 | versions: 18 | - name: v2 19 | schema: 20 | openAPIV3Schema: 21 | type: object 22 | x-kubernetes-preserve-unknown-fields: true 23 | served: true 24 | storage: true 25 | subresources: 26 | status: {} 27 | -------------------------------------------------------------------------------- /bungee-op/deploy/crds/mcserverhosting.net_v2_bungeedeployment_cr.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: mcserverhosting.net/v2 2 | kind: BungeeDeployment 3 | metadata: 4 | name: example-bungeedeployment 5 | spec: 6 | # Default values copied from \helm-charts\bungee-deployment\values.yaml 7 | 8 | config: 9 | memory: 10 | initial: 500M 11 | max: 1G 12 | network: 13 | domainName: bungee.mcserverhosting.red 14 | routeName: bungee.mcserverhosting.red 15 | jar: https://firebasestorage.googleapis.com/v0/b/mchostingnet-202204.appspot.com/o/FlameCord.jar?alt=media&token=9a8ba3db-7847-4d62-9a7f-10f65fe54601 16 | jarName: FlameCord.jar 17 | online: true 18 | plugins: 19 | - https://ci.viaversion.com/job/ViaVersion/lastSuccessfulBuild/artifact/jar/target/ViaVersion-2.2.3.jar 20 | - https://ci.viaversion.com/job/ViaVersion-Abstraction/lastSuccessfulBuild/artifact/jar/target/ViaVersion-3.0.0-SNAPSHOT.jar 21 | - https://ci.viaversion.com/view/ViaBackwards/job/ViaBackwards/lastSuccessfulBuild/artifact/all/target/viabackwards-all-2.4.0-SNAPSHOT.jar 22 | - https://ci.viaversion.com/view/ViaRewind/job/ViaRewind-DEV/lastSuccessfulBuild/artifact/all/target/viarewind-all-1.5.0-SNAPSHOT.jar 23 | 24 | -------------------------------------------------------------------------------- /bungee-op/deploy/operator.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: bungee-op 5 | spec: 6 | replicas: 1 7 | selector: 8 | matchLabels: 9 | name: bungee-op 10 | template: 11 | metadata: 12 | labels: 13 | name: bungee-op 14 | spec: 15 | serviceAccountName: bungee-op 16 | containers: 17 | - name: bungee-op 18 | resources: 19 | requests: 20 | memory: 50Mi 21 | cpu: 50m 22 | limits: 23 | memory: 100Mi 24 | cpu: 100m 25 | image: docker.io/quantomworks/bungee-operator 26 | imagePullPolicy: Always 27 | env: 28 | - name: WATCH_NAMESPACE 29 | value: "" 30 | - name: POD_NAME 31 | valueFrom: 32 | fieldRef: 33 | fieldPath: metadata.name 34 | - name: OPERATOR_NAME 35 | value: "bungee-op" 36 | -------------------------------------------------------------------------------- /bungee-op/deploy/role.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: Role 3 | metadata: 4 | creationTimestamp: null 5 | name: bungee-op 6 | rules: 7 | - apiGroups: 8 | - "" 9 | resources: 10 | - namespaces 11 | verbs: 12 | - get 13 | - apiGroups: 14 | - "" 15 | resources: 16 | - configmaps 17 | - secrets 18 | verbs: 19 | - '*' 20 | - apiGroups: 21 | - "" 22 | resources: 23 | - events 24 | verbs: 25 | - create 26 | - apiGroups: 27 | - "" 28 | resources: 29 | - services 30 | verbs: 31 | - '*' 32 | - apiGroups: 33 | - apps 34 | resources: 35 | - statefulsets 36 | verbs: 37 | - '*' 38 | - apiGroups: 39 | - monitoring.coreos.com 40 | resources: 41 | - servicemonitors 42 | verbs: 43 | - get 44 | - create 45 | - apiGroups: 46 | - apps 47 | resourceNames: 48 | - bungee-op 49 | resources: 50 | - deployments/finalizers 51 | verbs: 52 | - update 53 | - apiGroups: 54 | - "" 55 | resources: 56 | - pods 57 | verbs: 58 | - get 59 | - apiGroups: 60 | - apps 61 | resources: 62 | - replicasets 63 | - deployments 64 | verbs: 65 | - get 66 | - apiGroups: 67 | - mcserverhosting.net 68 | resources: 69 | - '*' 70 | verbs: 71 | - create 72 | - delete 73 | - get 74 | - list 75 | - patch 76 | - update 77 | - watch 78 | -------------------------------------------------------------------------------- /bungee-op/deploy/role_binding.yaml: -------------------------------------------------------------------------------- 1 | kind: RoleBinding 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | metadata: 4 | name: bungee-op 5 | subjects: 6 | - kind: ServiceAccount 7 | name: bungee-op 8 | roleRef: 9 | kind: Role 10 | name: bungee-op 11 | apiGroup: rbac.authorization.k8s.io 12 | -------------------------------------------------------------------------------- /bungee-op/deploy/service_account.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: bungee-op 5 | -------------------------------------------------------------------------------- /bungee-op/helm-charts/bungee-deployment: -------------------------------------------------------------------------------- 1 | ../../charts/bungee-deployment -------------------------------------------------------------------------------- /bungee-op/watches.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - group: mcserverhosting.net 3 | version: v2 4 | kind: BungeeDeployment 5 | chart: helm-charts/bungee-deployment 6 | -------------------------------------------------------------------------------- /deploy/crds/deployments.mcserverhosting.net_bungee_crd.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apiextensions.k8s.io/v1 2 | kind: CustomResourceDefinition 3 | metadata: 4 | name: bungeeservers.deployments.mcserverhosting.net 5 | spec: 6 | group: deployments.mcserverhosting.net 7 | versions: 8 | - name: v1 9 | served: true 10 | storage: true 11 | schema: 12 | openAPIV3Schema: 13 | type: object 14 | x-kubernetes-preserve-unknown-fields: true 15 | scope: Namespaced 16 | names: 17 | plural: bungeeservers 18 | singular: bungeeserver 19 | kind: BungeeServer 20 | shortNames: 21 | - bungee 22 | - bs 23 | - bungees -------------------------------------------------------------------------------- /deploy/crds/deployments.mcserverhosting.net_ns_crd.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apiextensions.k8s.io/v1 2 | kind: CustomResourceDefinition 3 | metadata: 4 | name: restrictions.deployments.mcserverhosting.net 5 | spec: 6 | group: deployments.mcserverhosting.net 7 | versions: 8 | - name: v1 9 | served: true 10 | storage: true 11 | schema: 12 | openAPIV3Schema: 13 | type: object 14 | x-kubernetes-preserve-unknown-fields: true 15 | scope: Namespaced 16 | names: 17 | plural: restrictions 18 | singular: restriction 19 | kind: Restriction 20 | shortNames: 21 | - restriction 22 | - res 23 | - restrictions -------------------------------------------------------------------------------- /deploy/crds/deployments.mcserverhosting.net_server_crd.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apiextensions.k8s.io/v1 2 | kind: CustomResourceDefinition 3 | metadata: 4 | name: minecraftservers.deployments.mcserverhosting.net 5 | spec: 6 | group: deployments.mcserverhosting.net 7 | versions: 8 | - name: v1 9 | served: true 10 | storage: true 11 | schema: 12 | openAPIV3Schema: 13 | type: object 14 | x-kubernetes-preserve-unknown-fields: true 15 | scope: Namespaced 16 | names: 17 | plural: minecraftservers 18 | singular: minecraftserver 19 | kind: MinecraftServer 20 | shortNames: 21 | - mcserver 22 | - mcs 23 | - mc 24 | - mcservers 25 | -------------------------------------------------------------------------------- /deploy/crds/deployments.mcserverhosting.net_sftp_crd.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apiextensions.k8s.io/v1 2 | kind: CustomResourceDefinition 3 | metadata: 4 | name: sftpservers.deployments.mcserverhosting.net 5 | spec: 6 | group: deployments.mcserverhosting.net 7 | versions: 8 | - name: v1 9 | served: true 10 | storage: true 11 | schema: 12 | openAPIV3Schema: 13 | type: object 14 | x-kubernetes-preserve-unknown-fields: true 15 | scope: Namespaced 16 | names: 17 | plural: sftpservers 18 | singular: sftpserver 19 | kind: SFTPServer 20 | shortNames: 21 | - sftp 22 | - sftps 23 | - ssh 24 | - sshs 25 | -------------------------------------------------------------------------------- /deploy/examples/1.18+.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: mcserverhosting.net/v2 2 | kind: MinecraftServer 3 | metadata: 4 | name: play 5 | spec: 6 | fixPerms: true 7 | javaOverride: "17" 8 | config: 9 | icon: 10 | modpack: 11 | mods: 12 | motd: 13 | removeOldMods: false 14 | resourcePack: 15 | sha: 16 | url: 17 | server: 18 | gameSettings: 19 | announcePlayerAchievements: true 20 | commandBlocks: true 21 | difficulty: null 22 | flight: true 23 | hardcore: false 24 | nether: true 25 | pvp: false 26 | snooper: true 27 | maxTickTime: 20000 28 | network: 29 | maxPlayers: 50 30 | onlineMode: true 31 | query: true 32 | restrictions: 33 | forceGamemode: true 34 | ops: 35 | whitelist: 36 | world: 37 | generateStructures: true 38 | generatorSettings: 39 | level: 40 | mode: 41 | name: 42 | restrictions: 43 | maxBuildHeight: 256 44 | maxSize: 1000 45 | spawnProtection: 0 46 | viewDistance: 32 47 | seed: 48 | spawnAnimals: true 49 | spawnNpcs: true 50 | url: 51 | groupID: 1000 52 | javaargs: 53 | args: 54 | argsdd: fml.queryResult:confirm Dlog4j2.formatMsgNoLookups=true 55 | argsxx: -XX:+UseLargePagesInMetaspace -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions 56 | -XX:MaxGCPauseMillis=100 -XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 57 | -XX:G1MaxNewSizePercent=80 -XX:G1MixedGCLiveThresholdPercent=50 -XX:+AlwaysPreTouch 58 | -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap 59 | minecraft: 60 | eula: true 61 | memory: 62 | buffer: 1000 63 | initial: 64 | max: 65 | version: 66 | network: 67 | domainName: 68 | online: true 69 | overrideOnStartup: false 70 | runtime: 71 | servercore: 72 | properties: 73 | url: 74 | version: 75 | redownload: false 76 | type: 77 | userID: 1001 -------------------------------------------------------------------------------- /deploy/examples/bungee.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: mcserverhosting.net/v2 2 | kind: BungeeDeployment 3 | metadata: 4 | name: example-bungeedeployment 5 | spec: 6 | config: 7 | memory: 8 | # config.memory.initial -- initial memory for the proxy server. memory must end in G or M. 9 | initial: 500M 10 | # config.memory.max -- max memory for the proxy server. memory must end in G or M. 11 | max: 1G 12 | network: 13 | # config.network.domainName -- The DNS name your players will connect by 14 | domainName: bungee.mcserverhosting.red 15 | # config.network.routeName -- The DNS name that will route to your node's IP address. 16 | routeName: bungee.mcserverhosting.red 17 | groupID: 1000 18 | jar: 19 | #link for the proxy server 20 | online: true 21 | #true for on, false for off 22 | type: CUSTOM 23 | userID: 1001 24 | -------------------------------------------------------------------------------- /deploy/examples/restriction.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: deployments.mcserverhosting.net/v1 2 | kind: Restriction 3 | metadata: 4 | name: example-restriction 5 | spec: 6 | user: sfxworks@gmail.com 7 | ports: 10 8 | servers: 3 9 | memory: 3Gi 10 | storage: 10Gi 11 | -------------------------------------------------------------------------------- /deploy/examples/server.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: mcserverhosting.net/v2 2 | kind: MinecraftServer 3 | metadata: 4 | #server name 5 | name: example-server 6 | spec: 7 | #controls some of the server.properties options 8 | config: 9 | icon: 10 | modpack: 11 | mods: 12 | motd: 13 | removeOldMods: false 14 | resourcePack: 15 | sha: 16 | url: 17 | server: 18 | gameSettings: 19 | announcePlayerAchievements: true 20 | commandBlocks: true 21 | difficulty: null 22 | flight: true 23 | hardcore: false 24 | nether: true 25 | pvp: false 26 | snooper: true 27 | maxTickTime: 20000 28 | network: 29 | maxPlayers: 50 30 | onlineMode: true 31 | query: true 32 | restrictions: 33 | forceGamemode: true 34 | ops: 35 | whitelist: 36 | world: 37 | generateStructures: true 38 | generatorSettings: 39 | level: 40 | mode: 41 | name: 42 | restrictions: 43 | maxBuildHeight: 256 44 | maxSize: 1000 45 | spawnProtection: 0 46 | viewDistance: 32 47 | seed: 48 | spawnAnimals: true 49 | spawnNpcs: true 50 | url: 51 | groupID: 1000 52 | javaargs: 53 | args: 54 | argsdd: fml.queryResult:confirm 55 | argsxx: -XX:+UseLargePagesInMetaspace -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions 56 | -XX:MaxGCPauseMillis=100 -XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 57 | -XX:G1MaxNewSizePercent=80 -XX:G1MixedGCLiveThresholdPercent=50 -XX:+AlwaysPreTouch 58 | -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:+UseLargePages 59 | -XX:LargePageSizeInBytes=2m 60 | minecraft: 61 | eula: true 62 | memory: 63 | #The max and minimum (initial) of memory, hugePages are set to 512M for all 64 | #note: ssh server takes 250M of the plan 65 | hugePages: 512M 66 | #hugePages are set to 512 for all unless your on 1.18+ 67 | initial: 68 | max: 69 | version: 70 | #version of minecraft 71 | network: 72 | domainName: 73 | #leave blank if no custom domain 74 | #if ports are needed the following can be kept, 75 | #if not required for plugins to use, feel feel free to remove 76 | # ports: 77 | # - name: 78 | # port: 79 | # protocol: 80 | online: true 81 | #true for on, false for off 82 | overrideOnStartup: false 83 | pages: true 84 | runtime: 85 | servercore: 86 | properties: 87 | url: 88 | version: 89 | redownload: false 90 | type: 91 | #types offered by us are: 92 | #VANILLA, FORGE, SPIGOT, TUINITY, MAGMA, MOHIST, CATSERVER, 93 | #SPONGEVANILLA, FABRIC, and PAPER 94 | userID: 1001 95 | -------------------------------------------------------------------------------- /deploy/examples/sftp.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: mcserverhosting.net/v2 2 | kind: SFTPServer 3 | metadata: 4 | name: 5 | #name for the sftp server 6 | spec: 7 | online: true 8 | #true for on, false for off 9 | users: 10 | 11 | - groupID: 1000 12 | userID: 1001 13 | publicKey: 14 | #publickey can be found by using the guide: https://mcserverhosting.net/support/post/how-to-access-minecraft-server-files/ 15 | username: 16 | #names should be fully lowercase -------------------------------------------------------------------------------- /deploy/operator.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: mcsh-operator 5 | spec: 6 | replicas: 1 7 | selector: 8 | matchLabels: 9 | name: mcsh-operator 10 | template: 11 | metadata: 12 | labels: 13 | name: mcsh-operator 14 | spec: 15 | serviceAccountName: mcsh-operator 16 | containers: 17 | - name: mcsh-operator 18 | image: docker.io/quantomworks/mc-operator:v3 19 | imagePullPolicy: Always 20 | resources: 21 | requests: 22 | cpu: 100m 23 | memory: 100Mi 24 | limits: 25 | cpu: 100m 26 | memory: 100Mi 27 | env: 28 | - name: WATCH_NAMESPACE 29 | value: "" 30 | - name: POD_NAME 31 | valueFrom: 32 | fieldRef: 33 | fieldPath: metadata.name 34 | - name: OPERATOR_NAME 35 | value: "mcsh-operator" -------------------------------------------------------------------------------- /deploy/role.yaml: -------------------------------------------------------------------------------- 1 | #TODO vs cluster-admin role -------------------------------------------------------------------------------- /deploy/role_binding.yaml: -------------------------------------------------------------------------------- 1 | kind: ClusterRoleBinding 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | metadata: 4 | name: mcsh-operator 5 | subjects: 6 | - kind: ServiceAccount 7 | name: mcsh-operator 8 | namespace: default 9 | roleRef: 10 | kind: ClusterRole 11 | name: cluster-admin 12 | apiGroup: rbac.authorization.k8s.io 13 | -------------------------------------------------------------------------------- /deploy/service_account.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: mcsh-operator 5 | -------------------------------------------------------------------------------- /server-op/build/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM quay.io/operator-framework/helm-operator:v0.17.0 2 | 3 | COPY watches.yaml ${HOME}/watches.yaml 4 | COPY helm-charts/ ${HOME}/helm-charts/ 5 | -------------------------------------------------------------------------------- /server-op/deploy/crds/mcserverhosting.net_minecraftservers_crd.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apiextensions.k8s.io/v1 2 | kind: CustomResourceDefinition 3 | metadata: 4 | name: minecraftservers.mcserverhosting.net 5 | spec: 6 | group: mcserverhosting.net 7 | names: 8 | kind: MinecraftServer 9 | shortNames: 10 | - mcserver 11 | - mcs 12 | - mc 13 | - mcservers 14 | - mcserv 15 | listKind: MinecraftServerList 16 | plural: minecraftservers 17 | singular: minecraftserver 18 | scope: Namespaced 19 | versions: 20 | - name: v2 21 | schema: 22 | openAPIV3Schema: 23 | x-kubernetes-preserve-unknown-fields: true 24 | type: object 25 | properties: 26 | online: 27 | type: string 28 | pattern: ^(?i)(true|false)$ 29 | default: "true" 30 | minecraft: 31 | type: object 32 | properties: 33 | eula: 34 | type: string 35 | pattern: ^(?i)(true|false)$ 36 | default: "false" 37 | version: 38 | type: string 39 | default: LATEST 40 | memory: 41 | type: object 42 | properties: 43 | initial: 44 | type: string 45 | default: 1G 46 | max: 47 | type: string 48 | default: 1G 49 | hugePages: 50 | type: string 51 | default: 125M 52 | network: 53 | type: object 54 | properties: 55 | domainName: 56 | type: string 57 | pattern: ^((?!mcserverhosting|mcsh|minecraftserverhosting).)*$ #custom domain must not mach or contain our primary domains 58 | served: true 59 | storage: true 60 | subresources: 61 | status: {} 62 | additionalPrinterColumns: 63 | - name: version 64 | type: string 65 | description: The core minecraft version the server is running 66 | jsonPath: .minecraft.version 67 | - name: XMS 68 | type: string 69 | description: The minimum amount of memory your server is requesting 70 | jsonPath: .minecraft.memory.initial 71 | - name: XMX 72 | type: string 73 | description: The maximum amount of memory your server is requesting 74 | jsonPath: .minecraft.memory.max 75 | - name: Age 76 | type: date 77 | jsonPath: .metadata.creationTimestamp 78 | -------------------------------------------------------------------------------- /server-op/deploy/crds/mcserverhosting.net_v2_minecraftserver_cr.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: mcserverhosting.net/v2 2 | kind: MinecraftServer 3 | metadata: 4 | name: server-name 5 | spec: 6 | config: 7 | icon: 8 | modpack: 9 | mods: 10 | motd: 11 | removeOldMods: false 12 | resourcePack: 13 | sha: 14 | url: 15 | server: 16 | gameSettings: 17 | announcePlayerAchievements: true 18 | commandBlocks: true 19 | difficulty: null 20 | flight: true 21 | hardcore: false 22 | nether: false 23 | pvp: false 24 | snooper: true 25 | maxTickTime: 20000 26 | network: 27 | maxPlayers: 2020 28 | onlineMode: true 29 | query: true 30 | restrictions: 31 | forceGamemode: true 32 | ops: 33 | whitelist: 34 | world: 35 | generateStructures: false 36 | generatorSettings: 37 | level: 38 | mode: 39 | name: 40 | restrictions: 41 | maxBuildHeight: 256 42 | maxSize: 1000 43 | spawnProtection: 0 44 | viewDistance: 32 45 | seed: 46 | spawnAnimals: false 47 | spawnNpcs: false 48 | url: 49 | groupID: 999 50 | java: 51 | args: 52 | argsdd: fml.queryResult:confirm 53 | argsxx: -XX:+UseLargePagesInMetaspace -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions 54 | -XX:MaxGCPauseMillis=100 -XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 55 | -XX:G1MaxNewSizePercent=80 -XX:G1MixedGCLiveThresholdPercent=50 -XX:+AlwaysPreTouch 56 | -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:+UseLargePages 57 | -XX:LargePageSizeInBytes=2m 58 | minecraft: 59 | eula: true 60 | memory: 61 | hugePages: 256M 62 | initial: 1G 63 | max: 3500M 64 | version: LATEST 65 | network: 66 | domainName: play.yourdomain.com 67 | online: true 68 | overrideOnStartup: false 69 | pages: true 70 | runtime: 71 | servercore: 72 | properties: 73 | url: 74 | version: 75 | redownload: false 76 | type: VANILLA 77 | userID: 1000 78 | 79 | -------------------------------------------------------------------------------- /server-op/deploy/operator.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: Deployment 3 | metadata: 4 | name: server-op 5 | spec: 6 | replicas: 1 7 | selector: 8 | matchLabels: 9 | name: server-op 10 | template: 11 | metadata: 12 | labels: 13 | name: server-op 14 | spec: 15 | serviceAccountName: server-op 16 | containers: 17 | - name: server-op 18 | resources: 19 | requests: 20 | memory: 50Mi 21 | cpu: 50m 22 | limits: 23 | memory: 100Mi 24 | cpu: 100m 25 | image: docker.io/quantomworks/server-operator 26 | imagePullPolicy: Always 27 | env: 28 | - name: WATCH_NAMESPACE 29 | value: "" 30 | - name: IP 31 | value: "51.222.70.233" 32 | - name: TLD 33 | value: mcsh.red 34 | - name: RUNTIME 35 | value: runsc 36 | - name: POD_NAME 37 | valueFrom: 38 | fieldRef: 39 | fieldPath: metadata.name 40 | - name: OPERATOR_NAME 41 | value: "server-op" 42 | -------------------------------------------------------------------------------- /server-op/deploy/role.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: rbac.authorization.k8s.io/v1 2 | kind: Role 3 | metadata: 4 | creationTimestamp: null 5 | name: server-op 6 | rules: 7 | - apiGroups: 8 | - "" 9 | resources: 10 | - namespaces 11 | verbs: 12 | - get 13 | - apiGroups: 14 | - "" 15 | resources: 16 | - configmaps 17 | - secrets 18 | verbs: 19 | - '*' 20 | - apiGroups: 21 | - "" 22 | resources: 23 | - events 24 | verbs: 25 | - create 26 | - apiGroups: 27 | - "" 28 | resources: 29 | - configmaps 30 | - services 31 | verbs: 32 | - '*' 33 | - apiGroups: 34 | - apps 35 | resources: 36 | - statefulsets 37 | verbs: 38 | - '*' 39 | - apiGroups: 40 | - monitoring.coreos.com 41 | resources: 42 | - servicemonitors 43 | verbs: 44 | - get 45 | - create 46 | - apiGroups: 47 | - apps 48 | resourceNames: 49 | - server-op 50 | resources: 51 | - deployments/finalizers 52 | verbs: 53 | - update 54 | - apiGroups: 55 | - "" 56 | resources: 57 | - pods 58 | verbs: 59 | - get 60 | - apiGroups: 61 | - apps 62 | resources: 63 | - replicasets 64 | - deployments 65 | verbs: 66 | - get 67 | - apiGroups: 68 | - mcserverhosting.net 69 | resources: 70 | - '*' 71 | verbs: 72 | - create 73 | - delete 74 | - get 75 | - list 76 | - patch 77 | - update 78 | - watch 79 | -------------------------------------------------------------------------------- /server-op/deploy/role_binding.yaml: -------------------------------------------------------------------------------- 1 | kind: RoleBinding 2 | apiVersion: rbac.authorization.k8s.io/v1 3 | metadata: 4 | name: server-op 5 | subjects: 6 | - kind: ServiceAccount 7 | name: server-op 8 | roleRef: 9 | kind: Role 10 | name: server-op 11 | apiGroup: rbac.authorization.k8s.io 12 | -------------------------------------------------------------------------------- /server-op/deploy/service_account.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ServiceAccount 3 | metadata: 4 | name: server-op 5 | -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/.helmignore: -------------------------------------------------------------------------------- 1 | # Patterns to ignore when building packages. 2 | # This supports shell glob matching, relative path matching, and 3 | # negation (prefixed with !). Only one pattern per line. 4 | .DS_Store 5 | # Common VCS dirs 6 | .git/ 7 | .gitignore 8 | .bzr/ 9 | .bzrignore 10 | .hg/ 11 | .hgignore 12 | .svn/ 13 | # Common backup files 14 | *.swp 15 | *.bak 16 | *.tmp 17 | *~ 18 | # Various IDEs 19 | .project 20 | .idea/ 21 | *.tmproj 22 | .vscode/ 23 | -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/Chart.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v2 2 | name: server-deployment 3 | version: 3.0.3 4 | kubeVersion: "> 1.15.0" 5 | description: A server deployment deployment for MCSH. Includes statefulset. 6 | type: application 7 | keywords: 8 | - mcserverhosting 9 | - server 10 | home: https://mcserverhosting.net/ 11 | sources: 12 | - https://github.com/mcserverhosting-net/charts 13 | maintainers: 14 | - name: sfxworks 15 | email: sfxworks@gmail.com 16 | url: sfxworks.net 17 | icon: https://avatars0.githubusercontent.com/u/49386422 18 | appVersion: 2.2.2 19 | deprecated: false -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/README.md: -------------------------------------------------------------------------------- 1 | ![Status](https://prow.mcserverhosting.net/badge.svg?jobs=lint-server-deployment) 2 | 3 | server-deployment 4 | ================= 5 | MCSH Minecraft Server Deployment 6 | 7 | Current chart version is `3.4` 8 | 9 | 10 | 11 | 12 | 13 | ## Chart Values 14 | 15 | | Key | Type | Default | Description | 16 | |-----|------|---------|-------------| 17 | | bukkit.url | string | `nil` | can be used to reference a bukkit jar via http/s | 18 | | config.console | bool | `true` | | 19 | | config.icon | string | `nil` | The icon displayed for your minecraft servers by the client and cabable query services | 20 | | config.memory.initial | string | `"6G"` | initial memory for the minecraft server. memory must end in G or M. | 21 | | config.memory.max | string | `"24G"` | max memory for the minecraft server. memory must end in G or M. | 22 | | config.modpack | string | `nil` | takes a custom set of jars in a zip file and extracts them into the mods directory | 23 | | config.mods | string | `nil` | takes a comma separated list of urls of jars and places them in the mods directory | 24 | | config.motd | string | `nil` | the minecraft servers message of the day | 25 | | config.removeOldMods | bool | `false` | removes any old mods that are had before applying new ones when mods is defined | 26 | | config.server.gameSettings.announcePlayerAchievements | bool | `true` | | 27 | | config.server.gameSettings.commandBlocks | bool | `true` | | 28 | | config.server.gameSettings.difficulty | string | `nil` | | 29 | | config.server.gameSettings.flight | bool | `true` | | 30 | | config.server.gameSettings.hardcore | bool | `false` | | 31 | | config.server.gameSettings.nether | bool | `false` | | 32 | | config.server.gameSettings.pvp | bool | `false` | | 33 | | config.server.gameSettings.snooper | bool | `true` | | 34 | | config.server.maxTickTime | int | `20000` | | 35 | | config.server.network.maxPlayers | int | `2020` | | 36 | | config.server.network.onlineMode | bool | `false` | | 37 | | config.server.network.query | bool | `true` | | 38 | | config.server.restrictions.forceGamemode | bool | `true` | | 39 | | config.server.restrictions.ops | string | `nil` | | 40 | | config.server.restrictions.whitelist | string | `nil` | | 41 | | config.world.generateStructures | bool | `false` | | 42 | | config.world.generatorSettings | string | `nil` | | 43 | | config.world.level | string | `"FLAT"` | | 44 | | config.world.mode | string | `"adventure"` | | 45 | | config.world.name | string | `"superflat"` | | 46 | | config.world.restrictions.maxBuildHeight | int | `256` | | 47 | | config.world.restrictions.maxSize | int | `1000` | | 48 | | config.world.restrictions.spawnProtection | int | `0` | | 49 | | config.world.restrictions.viewDistance | int | `32` | | 50 | | config.world.seed | string | `nil` | | 51 | | config.world.spawnAnimals | bool | `false` | | 52 | | config.world.spawnNpcs | bool | `false` | | 53 | | config.world.url | string | `nil` | will download a zip file of a world and extract it | 54 | | curseforge.modpack.url | string | `nil` | Immediately applies a CurseForge modpack via url | 55 | | custom.url | string | `nil` | can be used to reference a custom server jar via url or local directory | 56 | | domainName | string | `nil` | | 57 | | eula | bool | `true` | agrees to eula | 58 | | fabric.installer | string | `nil` | can be used reference a installer already in the minecraft server directory. | 59 | | fabric.url | string | `nil` | | 60 | | fabric.version | string | `nil` | version of fabric server chosen | 61 | | forceRedownload | bool | `false` | forces redwonload for VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, CURSEFORGE, SPONGEVANILLA server types | 62 | | forge.installer | string | `nil` | can be used reference an installer jar already in the minecraft server directory. | 63 | | forge.url | string | `nil` | can be used to reference an installer via url | 64 | | forge.version | string | `nil` | defaults to recommended version based on base version selection. Can be changed to a number. | 65 | | ftb.legacy | bool | `false` | launch mode. May fix issues for older modpacks when running into "unable to launch forgemodloader" errors | 66 | | ftb.modpack.url | string | `nil` | Immediately applies a FTB modpack via url | 67 | | groupID | int | `999` | | 68 | | online | bool | `true` | server online value. If false, server will be shutoff and not count against any quota. | 69 | | overrideOnStartup | bool | `true` | dif true, will rewrite the server.properties file when passed here. always runs on first install. | 70 | | routeName | string | `nil` | | 71 | | runtime | string | `nil` | | 72 | | spigot.build | bool | `false` | If URL isn't defined, will build spigot from source repository. | 73 | | spigot.url | string | `nil` | can be used to reference a spigot jar via http/s | 74 | | spongevanilla.branch | string | `nil` | | 75 | | spongevanilla.version | string | `nil` | version of sponge vanilla chosen | 76 | | type | string | `"PAPER"` | sets the type of server. Possible values are VANILLA, FORGE, BUKKIT, SPIGOT, CURSEFORGE, SPONGEVANILLA, PAPER, FTB, and FABRIC | 77 | | userID | int | `1000` | | 78 | | version | string | `"LATEST"` | sets the base version of minecraft. Options are SNAPSHOT, LATEST, or a specific version. | 79 | -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/README.md.gotmpl: -------------------------------------------------------------------------------- 1 | ![Status](https://prow.mcserverhosting.net/badge.svg?jobs=lint-server-deployment) 2 | 3 | {{ template "chart.header" . }} 4 | {{ template "chart.description" . }} 5 | 6 | {{ template "chart.versionLine" . }} 7 | 8 | {{ template "chart.sourceLinkLine" . }} 9 | 10 | {{ template "chart.requirementsSection" . }} 11 | 12 | {{ template "chart.valuesSection" . }} 13 | -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/magma-example.yaml: -------------------------------------------------------------------------------- 1 | # online -- server online value. If false, server will be shutoff and not count against any quota. 2 | online: true 3 | # eula -- agrees to eula 4 | eula: true 5 | # version -- sets the base version of minecraft. Options are SNAPSHOT, LATEST, or a specific version. 6 | version: LATEST 7 | # type -- sets the type of server. Possible values are VANILLA, FORGE, BUKKIT, SPIGOT, CURSEFORGE, SPONGEVANILLA, PAPER, FTB, and FABRIC 8 | type: CUSTOM 9 | custom: 10 | # custom.url -- can be used to reference a custom server jar via url or local directory 11 | url: https://github.com/magmafoundation/Magma/releases/download/v8d2a711/Magma-8d2a711-server.jar 12 | 13 | domainName: magma.thepixelmc.net 14 | routeName: magma.thepixelmc.net 15 | 16 | config: 17 | console: true 18 | # config.modpack -- takes a custom set of jars in a zip file and extracts them into the mods directory 19 | modpack: 20 | # config.mods -- takes a comma separated list of urls of jars and places them in the mods directory 21 | mods: 22 | # config.removeOldMods -- removes any old mods that are had before applying new ones when mods is defined 23 | removeOldMods: false 24 | memory: 25 | # config.memory.initial -- initial memory for the minecraft server. memory must end in G or M. 26 | initial: 3G 27 | # config.memory.max -- max memory for the minecraft server. memory must end in G or M. 28 | max: 5G 29 | # config.icon -- The icon displayed for your minecraft servers by the client and cabable query services 30 | icon: 31 | # config.motd -- the minecraft servers message of the day 32 | motd: 33 | #config.server -- general server.properties. see https://minecraft.gamepedia.com/Server.properties for specifics 34 | server: 35 | maxTickTime: 20000 36 | restrictions: 37 | ops: 38 | whitelist: 39 | forceGamemode: true 40 | network: 41 | maxPlayers: 2020 42 | query: true 43 | onlineMode: true 44 | gameSettings: 45 | hardcore: false 46 | snooper: true 47 | difficulty: 48 | commandBlocks: true 49 | announcePlayerAchievements: true 50 | nether: false 51 | flight: true 52 | pvp: false 53 | resourcePack: 54 | url: https://firebasestorage.googleapis.com/v0/b/mchostingnet-202204.appspot.com/o/KDesp%201.15%20v1.9.zip?alt=media&token=2a9e2133-a553-4433-bae7-824d964d1c7c 55 | sha: 56 | world: 57 | name: superflat 58 | restrictions: 59 | maxBuildHeight: 256 60 | maxSize: 1000 61 | viewDistance: 32 62 | spawnProtection: 0 63 | mode: adventure 64 | level: FLAT 65 | generatorSettings: 66 | seed: 67 | spawnAnimals: false 68 | spawnNpcs: false 69 | generateStructures: false 70 | # config.world.url -- will download a zip file of a world and extract it 71 | url: 72 | # overrideOnStartup -- dif true, will rewrite the server.properties file when passed here. always runs on first install. 73 | overrideOnStartup: true 74 | # forceRedownload -- forces redwonload for VANILLA, FORGE, BUKKIT, SPIGOT, PAPER, CURSEFORGE, SPONGEVANILLA server types 75 | forceRedownload: false -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/templates/host-keys.yaml: -------------------------------------------------------------------------------- 1 | #Todo- generate hostkeys -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/templates/preinstall.yaml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mcserverhosting-net/mc-operator/33350ccb378a24ac9fd6d44975b777f6be113c9b/server-op/helm-charts/server-deployment/templates/preinstall.yaml -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/templates/server-config.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: ConfigMap 3 | metadata: 4 | name: {{ .Release.Name }} 5 | data: 6 | SERVER_NAME: {{ .Release.Name }} 7 | USE_LARGE_PAGES: {{ default false (.Values.pages | toString) | quote }} 8 | {{- with .Values.minecraft }} 9 | {{- if eq (trunc -1 .memory.initial) "G" }} 10 | INIT_MEMORY: {{ sub (mul (trimSuffix "G" .memory.initial) 1000) 200 }}M 11 | MAX_MEMORY: {{ sub (mul (trimSuffix "G" .memory.max) 1000) 200 }}M 12 | {{- else}} 13 | INIT_MEMORY: {{max (sub (trimSuffix "M" .memory.initial) 200 ) 200}}M 14 | MAX_MEMORY: {{max (sub (trimSuffix "M" .memory.max) 200 ) 200}}M 15 | {{- end }} 16 | EULA: {{ default false (.eula | toString) | quote }} 17 | VERSION: {{ default "LATEST" .version | quote }} 18 | {{- end }} 19 | {{- with .Values.servercore }} 20 | TYPE: {{ default "VANILLA" .type | quote }} 21 | FORCE_REDOWNLOAD: {{ default false .redownload | quote }} 22 | {{- if .properties }} 23 | {{- if .properties.version }} 24 | {{- if eq .type "FORGE" }} 25 | FORGEVERSION: {{ .properties.version | quote }} 26 | {{- end }} 27 | {{- if eq .type "SPONGEVANILLA" }} 28 | SPONGEVERSION: {{ .properties.version | quote }} 29 | {{- end }} 30 | {{- if eq .type "FABRIC" }} 31 | FABRICVERSION: {{ .properties.version | quote }} 32 | {{- end }} 33 | {{- end }} 34 | {{- if .properties.url }} 35 | {{- if eq .type "FORGE" }} 36 | FORGE_INSTALLER_URL: {{ .properties.url }} 37 | {{- end }} 38 | {{- if eq .type "BUKKIT" }} 39 | BUKKIT_DOWNLOAD_URL: {{ .properties.url }} 40 | {{- end }} 41 | {{- if eq .type "SPIGOT" }} 42 | SPIGOT_DOWNLOAD_URL: {{ .properties.url }} 43 | {{- end }} 44 | {{- if eq .type "CURSEFORGE" }} 45 | CF_SERVER_MOD: {{ .properties.url }} 46 | {{- end }} 47 | {{- if eq .type "FTB" }} 48 | FTB_SERVER_MOD: {{ .properties.url }} 49 | {{- end }} 50 | {{- if eq .type "FABRIC" }} 51 | FABRIC_INSTALLER_URL: {{ .properties.url }} 52 | {{- end }} 53 | {{- if eq .type "CUSTOM" }} 54 | CUSTOM_SERVER: {{ .properties.url }} 55 | {{- end }} 56 | {{- end }} 57 | {{- end }} 58 | {{- end }} 59 | 60 | {{- with .Values.config }} 61 | OVERRIDE_SERVER_PROPERTIES: {{ default false ( .overrideOnStartup ) | quote }} 62 | ICON: {{ default "https://mcserverhosting.net/favicon.ico" .icon }} 63 | {{- if .modpack }} 64 | MODPACK: {{ .modpack }} 65 | {{- end }} 66 | MOTD: {{ default "Your new MCSH minecraft server!" .motd }} 67 | {{- if .mods }} 68 | MODS: {{ .mods }} 69 | {{- end }} 70 | REMOVE_OLD_MODS: {{ default true ( .removeOldMods | toString ) | quote }} 71 | CONSOLE: {{ default true ( .console | toString ) | quote }} 72 | GUI: "false" 73 | {{- with .server }} 74 | OPS: {{ default .restrictions.ops "sfxworks" }} 75 | ENABLE_QUERY: {{ default true ( .network.query | toString ) | quote }} 76 | MAX_PLAYERS: {{ default "2020" .network.maxPlayers | quote }} 77 | ALLOW_NETHER: {{ default true ( .gameSettings.nether | toString ) | quote }} 78 | DIFFICULTY: {{ .gameSettings.difficulty | default "hard" }} 79 | ANNOUNCE_PLAYER_ACHIEVEMENTS: {{ default true ( .gameSettings.announcePlayerAchievements | toString ) | quote }} 80 | ENABLE_COMMAND_BLOCK: {{ default true ( .gameSettings.commandBlocks| toString ) | quote }} 81 | FORCE_GAMEMODE: {{ default false .restrictions.forceGamemode | quote }} 82 | HARDCORE: {{ default true ( .gameSettings.hardcore | toString ) | quote }} 83 | SNOOPER_ENABLED: {{ default true ( .gameSettings.snooper | toString ) | quote }} 84 | MAX_TICK_TIME: {{ default "20000" .maxTickTime | quote}} 85 | PVP: {{ default true ( .gameSettings.pvp | toString ) | quote }} 86 | ONLINE_MODE: {{ default true ( .network.onlineMode | toString ) | quote }} 87 | {{- if .restrictions.whitelist }} 88 | WHITELIST: {{ .restrictions.whitelist }} 89 | {{- end }} 90 | {{- end }} 91 | {{- with .world }} 92 | {{- if .restrictions.maxSize }} 93 | MAX_WORLD_SIZE: {{ .restrictions.maxSize | quote }} 94 | {{- end }} 95 | MAX_BUILD_HEIGHT: {{ default 256 .restrictions.maxBuildHeight | quote }} 96 | GENERATE_STRUCTURES: {{ default true ( .generateStructures| toString ) | quote }} 97 | SPAWN_ANIMALS: {{ default true ( .spawnAnimals | toString ) | quote }} 98 | SPAWN_NPCS: {{ default true ( .spawnNpcs| toString ) | quote }} 99 | SPAWN_PROTECTION: {{ default true ( .restrictions.spawnProtection | toString ) | quote }} 100 | {{- if .restrictions.viewDistance }} 101 | VIEW_DISTANCE: {{ .restrictions.viewDistance | quote }} 102 | {{- end }} 103 | {{- if .seed }} 104 | SEED: {{ .seed | quote }} 105 | {{- end }} 106 | MODE: {{ .mode | default "Survival"}} 107 | LEVEL_TYPE: {{ default "DEFAULT" .level | quote }} 108 | {{- if .generatorSettings }} 109 | GENERATOR_SETTINGS: {{ .generatorSettings }} 110 | {{- end }} 111 | LEVEL: {{ .name | default "mcshworld" }} 112 | {{- if .url }} 113 | WORLD: {{ .url }} 114 | {{- end }} 115 | {{- end }} 116 | {{- end }} 117 | 118 | {{- if .Values.javaargs }} 119 | {{- if .Values.javaargs.argsdd }} 120 | JVM_DD_OPTS: fml.queryResult:confirm 121 | {{- end }} 122 | {{- if .Values.javaargs.argsxx }} 123 | JVM_XX_OPTS: -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap 124 | {{- end }} 125 | {{- if .Values.javaargs.args }} 126 | JVM_OPTS: fml.queryResult:confirm 127 | {{- end }} 128 | {{- end }} -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/templates/server-statefulset.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: apps/v1 2 | kind: StatefulSet 3 | metadata: 4 | name: {{ .Release.Name }} 5 | spec: 6 | serviceName: {{ .Release.Name }} 7 | selector: 8 | matchLabels: 9 | app: {{ .Release.Name }} 10 | {{- if .Values.online }} 11 | replicas: 1 12 | {{- else }} 13 | replicas: 0 14 | {{- end }} 15 | template: 16 | metadata: 17 | labels: 18 | app: {{ .Release.Name }} 19 | spec: 20 | {{- if .Values.runtime }} 21 | runtimeClassName: {{ .Values.runtime }} 22 | {{- end }} 23 | securityContext: 24 | runAsUser: {{ .Values.userID | default 1000 }} 25 | runAsGroup: {{ .Values.groupID | default 999 }} 26 | terminationGracePeriodSeconds: 30 27 | nodeSelector: 28 | node-role.kubernetes.io/game: "" 29 | containers: 30 | - name: {{ .Release.Name }} 31 | securityContext: 32 | allowPrivilegeEscalation: false 33 | envFrom: 34 | - configMapRef: 35 | name: {{ .Release.Name }} 36 | startupProbe: 37 | tcpSocket: 38 | port: minecraft-tcp 39 | failureThreshold: 30 40 | periodSeconds: 10 41 | readinessProbe: 42 | tcpSocket: 43 | port: minecraft-tcp 44 | periodSeconds: 10 45 | failureThreshold: 1 46 | livenessProbe: 47 | tcpSocket: 48 | port: minecraft-tcp 49 | periodSeconds: 10 50 | failureThreshold: 1 51 | {{- if .Values.servercore.type }} 52 | {{- if eq .Values.servercore.type "VANILLA" }} 53 | image: docker.io/itzg/minecraft-server:adopt13 54 | {{- else }} 55 | image: docker.io/itzg/minecraft-server:latest 56 | {{- end }} 57 | {{- end }} 58 | tty: true 59 | stdin: true 60 | imagePullPolicy: IfNotPresent 61 | terminationMessagePolicy: FallbackToLogsOnError 62 | resources: 63 | limits: 64 | memory: {{ .Values.minecraft.memory.max }}i 65 | {{- if .Values.pages }} 66 | hugepages-2Mi: {{ .Values.minecraft.memory.hugePages }}i 67 | {{- end }} 68 | requests: 69 | memory: {{ .Values.minecraft.memory.initial }}i 70 | cpu: 100m 71 | ports: 72 | - containerPort: 25565 73 | name: minecraft-udp 74 | protocol: UDP 75 | - containerPort: 25565 76 | name: minecraft-tcp 77 | protocol: TCP 78 | volumeMounts: 79 | - name: minecraft-volume 80 | mountPath: /data 81 | subPath: servers/{{ .Release.Name }} 82 | - name: minecraft-volume 83 | mountPath: /web 84 | subPath: web 85 | restartPolicy: Always 86 | volumes: 87 | - name: minecraft-volume 88 | persistentVolumeClaim: 89 | claimName: ns-pvc 90 | readOnly: false 91 | {{- if .Values.pages }} 92 | - name: hugepage-2mi 93 | emptyDir: 94 | medium: HugePages-2Mi 95 | {{- end }} -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/templates/service-external-name.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ .Release.Name }}-external 5 | annotations: 6 | {{- if .Values.network }} 7 | {{- if .Values.network.domainName }} 8 | #Integration option for external dns 9 | external-dns.alpha.kubernetes.io/hostname: {{ .Values.network.domainName }} 10 | {{- else }} 11 | #Integration option for external dns 12 | external-dns.alpha.kubernetes.io/hostname: {{ .Release.Name }}.{{ .Release.Namespace }}.{{.Values.tld}} 13 | {{- end }} 14 | {{- end }} 15 | labels: 16 | type: {{ .Release.Name }} 17 | spec: 18 | type: ExternalName 19 | {{- if .Values.ip }} 20 | externalName: {{ .Values.ip }} 21 | {{- end }} -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/templates/service.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: v1 2 | kind: Service 3 | metadata: 4 | name: {{ .Release.Name }} 5 | annotations: 6 | {{- if .Values.network }} 7 | {{- if .Values.network.domainName }} 8 | #Integration option for mc-router 9 | mc-router.itzg.me/externalServerName: {{ .Values.network.domainName }} 10 | {{- else }} 11 | #Integration option for mc-router 12 | mc-router.itzg.me/externalServerName: {{ .Release.Name }}.{{ .Release.Namespace }}.{{.Values.tld}} 13 | {{- end }} 14 | {{- end }} 15 | labels: 16 | type: {{ .Release.Name }} 17 | spec: 18 | type: ClusterIP 19 | ports: 20 | - name: minecraft-tcp 21 | port: 25565 22 | protocol: TCP 23 | - name: minecraft-udp 24 | port: 25565 25 | protocol: UDP 26 | selector: 27 | app: {{ .Release.Name }} -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/templates/tests/domain-ownership-text.yaml: -------------------------------------------------------------------------------- 1 | #TODO domain ownership identified by querying txt record. If NXDOMAIN, apply text record. 2 | #If true, compare namespace. If match, proceed to adjust dns records and complete pre-install/preupgrade hook. 3 | #If any end end abrupt -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/templates/tests/test-server-connection.yaml: -------------------------------------------------------------------------------- 1 | apiVersion: batch/v1 2 | kind: Job 3 | metadata: 4 | name: {{ .Release.Name }}-connection-test 5 | annotations: 6 | helm.sh/hook: test 7 | spec: 8 | template: 9 | spec: 10 | containers: 11 | - name: main 12 | image: itzg/mc-monitor:0.5.0 13 | args: 14 | - status 15 | - --host 16 | - {{ .Release.Name }} 17 | restartPolicy: OnFailure 18 | backoffLimit: 4 19 | -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/values-minimal-example.yaml: -------------------------------------------------------------------------------- 1 | servers: 2 | - name: server-1 3 | online: true 4 | eula: true 5 | config: 6 | memory: 7 | initial: 1G 8 | max: 1G -------------------------------------------------------------------------------- /server-op/helm-charts/server-deployment/values.yaml: -------------------------------------------------------------------------------- 1 | # online -- server online value. If false, server will be shutoff and not count against any quota. 2 | online: true 3 | 4 | minecraft: 5 | # eula -- agrees to eula 6 | eula: true 7 | # minecraft.version -- sets the base version of minecraft. Options are SNAPSHOT, LATEST, or a specific version. 8 | version: LATEST 9 | memory: 10 | # minecraft.memory.initial -- initial memory for the minecraft server. memory must end in G or M. 11 | initial: 1G 12 | # minecraft.memory.max -- max memory for the minecraft server. memory must end in G or M. 13 | max: 4G 14 | hugePages: 125M 15 | 16 | servercore: 17 | # type -- sets the type of server. Possible values are VANILLA, FORGE, BUKKIT, SPIGOT, CURSEFORGE, SPONGEVANILLA, PAPER, FTB, and FABRIC 18 | type: VANILLA 19 | # forceRedownload -- forces redwonload for core server types 20 | redownload: false 21 | properties: 22 | url: 23 | version: 24 | 25 | network: 26 | domainName: 27 | 28 | java: 29 | args: 30 | argsdd: fml.queryResult:confirm 31 | argsxx: -XX:+UseLargePagesInMetaspace -XX:+UseG1GC -XX:+UnlockExperimentalVMOptions -XX:MaxGCPauseMillis=100 -XX:+DisableExplicitGC -XX:TargetSurvivorRatio=90 -XX:G1NewSizePercent=50 -XX:G1MaxNewSizePercent=80 -XX:G1MixedGCLiveThresholdPercent=50 -XX:+AlwaysPreTouch -XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap -XX:+UseLargePages -XX:LargePageSizeInBytes=2m 32 | #Based on https://www.redhat.com/en/blog/optimizing-rhel-8-run-java-implementation-minecraft-server 33 | 34 | config: 35 | # config.modpack -- takes a custom set of jars in a zip file and extracts them into the mods directory 36 | modpack: 37 | # config.mods -- takes a comma separated list of urls of jars and places them in the mods directory 38 | mods: 39 | # config.removeOldMods -- removes any old mods that are had before applying new ones when mods is defined 40 | removeOldMods: false 41 | # config.icon -- The icon displayed for your minecraft servers by the client and cabable query services 42 | icon: 43 | # config.motd -- the minecraft servers message of the day 44 | motd: 45 | #config.server -- general server.properties. see https://minecraft.gamepedia.com/Server.properties for specifics 46 | server: 47 | maxTickTime: 20000 48 | restrictions: 49 | ops: 50 | whitelist: 51 | forceGamemode: true 52 | network: 53 | maxPlayers: 2020 54 | query: true 55 | onlineMode: true 56 | gameSettings: 57 | hardcore: false 58 | snooper: true 59 | difficulty: 60 | commandBlocks: true 61 | announcePlayerAchievements: true 62 | nether: false 63 | flight: true 64 | pvp: false 65 | resourcePack: 66 | url: 67 | sha: 68 | world: 69 | name: 70 | restrictions: 71 | maxBuildHeight: 256 72 | maxSize: 1000 73 | viewDistance: 32 74 | spawnProtection: 0 75 | mode: 76 | level: 77 | generatorSettings: 78 | seed: 79 | spawnAnimals: false 80 | spawnNpcs: false 81 | generateStructures: false 82 | # config.world.url -- will download a zip file of a world and extract it 83 | url: 84 | # overrideOnStartup -- dif true, will rewrite the server.properties file when passed here. always runs on first install. 85 | overrideOnStartup: true 86 | 87 | #Cluster admin values 88 | runtime: 89 | userID: 1000 90 | groupID: 1001 91 | # pages -- Enable the use of hugepages 92 | pages: true 93 | tld: 94 | ip: -------------------------------------------------------------------------------- /server-op/watches.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - group: mcserverhosting.net 3 | version: v2 4 | kind: MinecraftServer 5 | chart: helm-charts/server-deployment 6 | overrideValues: 7 | ip: $IP 8 | tld: $TLD 9 | runtime: $RUNTIME 10 | -------------------------------------------------------------------------------- /watches.yaml: -------------------------------------------------------------------------------- 1 | --- 2 | - version: v1 3 | group: deployments.mcserverhosting.net 4 | kind: MinecraftServer 5 | chart: charts/server-deployment 6 | - version: v1 7 | group: deployments.mcserverhosting.net 8 | kind: SFTPServer 9 | chart: charts/sftp-deployment 10 | - version: v1 11 | group: deployments.mcserverhosting.net 12 | kind: BungeeServer 13 | chart: charts/bungee-deployment 14 | - version: v1 15 | group: deployments.mcserverhosting.net 16 | kind: Restriction 17 | chart: charts/namespace-lock --------------------------------------------------------------------------------