MCing documentation
This is the documentation site for MCing. MCing is a Kubernetes operator for Minecraft server.
Getting started
Deploying MCing
-
(Optional) Prepare cert-manager
MCing depends on cert-manager to issue TLS certificate for admission webhooks. If cert-manager is not installed on your cluster, install it as follows:
$ curl -fsLO https://github.com/jetstack/cert-manager/releases/latest/download/cert-manager.yaml $ kubectl apply -f cert-manager.yaml
-
Apply MCing manifests
$ curl -fsLO https://github.com/kmdkuk/MCing/releases/latest/download/install.yaml $ kubectl apply -f install.yaml
Usage
Starting simple server
-
Apply Minecraft Custom Resouce
$ cat <<EOF > minecraft-sample.yaml apiVersion: mcing.kmdkuk.com/v1alpha1 kind: Minecraft metadata: name: minecraft-sample spec: podTemplate: spec: containers: - name: minecraft image: itzg/minecraft-server:java8 env: - name: TYPE value: "SPIGOT" - name: EULA value: "true" serviceTemplate: spec: type: NodePort volumeClaimTemplates: - metadata: name: minecraft-data spec: accessModes: [ "ReadWriteOnce" ] storageClassName: standard resources: requests: storage: 1Gi serverPropertiesConfigMapName: mcing-server-props --- apiVersion: v1 kind: ConfigMap metadata: name: mcing-server-props data: motd: "[this is test]A Vanilla Minecraft Server powered by MCing" pvp: "true" difficulty: "hard" EOF $ kubectl apply -f minecraft-sample.yaml # check resources $ kubectl get minecrafts.mcing.kmdkuk.com minecraft-sample NAME AGE minecraft-sample 2m41s $ kubectl get statefulsets.apps mcing-minecraft-sample NAME READY AGE mcing-minecraft-sample 1/1 2m47s $ kubectl get persistentvolumeclaims minecraft-data-minecraft-sample-0 NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE minecraft-data-mcing-minecraft-sample-0 Bound pvc-220c9ba1-2395-48ed-a18a-c9d3d7788a6c 1Gi RWO standard 3h58m $ kubectl get service NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 12m mcing-minecraft-sample NodePort 10.96.232.50 <none> 25565:30088/TCP,25575:30446/UDP 103s mcing-minecraft-sample-headless ClusterIP None <none> 25565/TCP,25575/UDP 103s $ kubectl get configmaps NAME DATA AGE kube-root-ca.crt 1 13m mcing-minecraft-sample 1 2m47s mcing-server-props 3 2m47s
When you apply Minecraft Custom Resource, several resources will be created.
-
Access the server
MCing does not yet have the ability to customize the Service, so you can use port-forward and other methods to check access to the server.
$ kubectl port-forward svc/minecraft-sample 25565:25565
Configuration by ConfigMap
If you edit the ConfigMap specified by .spec.serverPropertiesConfigMapName
in the Minecraft resource, it will automatically replace server.properties and then execute the /reload
command.
Note: There are some cases where the configuration will not be updated even if you run the /reload
command. (In the case of TYPE=SPIGOT, we have confirmed that the configuration is updated automatically.)
The following ConfigMap can be applied to other JSON configuration files.
apiVersion: v1
kind: ConfigMap
metadata:
name: other-props
data:
banned-ips.json: |
[]
banned-players.json: |
[]
whitelist.json: |
[]
ops.json: |
[]
It can be applied by specifying a name, such as otherConfigMapName: other-props
.
However, these files are updated from the command in actual operation. Therefore, they will be applied if the target files are not present at startup.
(TODO: I'm trying to figure out how to successfully merge the JSON specified in ConfigMap with the JSON that actually exists).
Custom resources
Custom Resources
Sub Resources
- MinecraftList
- MinecraftSpec
- ObjectMeta
- Ops
- PersistentVolumeClaim
- PodTemplateSpec
- ServiceTemplate
- Whitelist
Minecraft
Minecraft is the Schema for the minecrafts API
Field | Description | Scheme | Required |
---|---|---|---|
metadata | metav1.ObjectMeta | false | |
spec | MinecraftSpec | false | |
status | MinecraftStatus | false |
MinecraftList
MinecraftList contains a list of Minecraft
Field | Description | Scheme | Required |
---|---|---|---|
metadata | metav1.ListMeta | false | |
items | []Minecraft | true |
MinecraftSpec
MinecraftSpec defines the desired state of Minecraft
Field | Description | Scheme | Required |
---|---|---|---|
podTemplate | PodTemplate is a Pod template for Minecraft server container. | PodTemplateSpec | true |
volumeClaimTemplates | PersistentVolumeClaimSpec is a specification of PersistentVolumeClaim for persisting data in minecraft. A claim named "minecraft-data" must be included in the list. | []PersistentVolumeClaim | true |
serviceTemplate | ServiceTemplate is a Service template. | *ServiceTemplate | false |
ops | operators on server. exec /op or /deop | Ops | false |
whitelist | whitelist | Whitelist | false |
serverPropertiesConfigMapName | ServerPropertiesConfigMapName is a ConfigMap name of server.properties . | *string | false |
otherConfigMapName | OtherConfigMapName is a ConfigMap name of other configurations file(eg. banned-ips.json, ops.json etc) | *string | false |
ObjectMeta
ObjectMeta is metadata of objects. This is partially copied from metav1.ObjectMeta.
Field | Description | Scheme | Required |
---|---|---|---|
name | Name is the name of the object. | string | false |
labels | Labels is a map of string keys and values. | map[string]string | false |
annotations | Annotations is a map of string keys and values. | map[string]string | false |
Ops
Field | Description | Scheme | Required |
---|---|---|---|
users | user name exec /op or /deop | []string | false |
PersistentVolumeClaim
PersistentVolumeClaim is a user's request for and claim to a persistent volume. This is slightly modified from corev1.PersistentVolumeClaim.
Field | Description | Scheme | Required |
---|---|---|---|
metadata | Standard object's metadata. | ObjectMeta | true |
spec | Spec defines the desired characteristics of a volume requested by a pod author. | corev1.PersistentVolumeClaimSpec | true |
PodTemplateSpec
PodTemplateSpec describes the data a pod should have when created from a template. This is slightly modified from corev1.PodTemplateSpec.
Field | Description | Scheme | Required |
---|---|---|---|
metadata | Standard object's metadata. The name in this metadata is ignored. | ObjectMeta | false |
spec | Specification of the desired behavior of the pod. The name of the MySQL server container in this spec must be minecraft . | corev1.PodSpec | true |
ServiceTemplate
ServiceTemplate define the desired spec and annotations of Service
Field | Description | Scheme | Required |
---|---|---|---|
metadata | Standard object's metadata. Only annotations and labels are valid. | ObjectMeta | false |
spec | Spec is the ServiceSpec | *corev1.ServiceSpec | false |
Whitelist
Field | Description | Scheme | Required |
---|---|---|---|
enabled | exec /whitelist on | bool | true |
users | user name exec /whitelist add or /whitelist remove | []string | false |