commit 0ca51b452a430820c15bb0a8424c6d65eb7db349 Author: eric o meehan Date: Thu Aug 8 11:24:22 2024 -0400 v0.0.1 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..335ec95 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.tar.gz diff --git a/README.md b/README.md new file mode 100644 index 0000000..a4f0dea --- /dev/null +++ b/README.md @@ -0,0 +1,38 @@ +Gondwana +========= + +Ansible role to deploy Gondwana MineCraft server on Kubernetes. + +Requirements +------------ + +A Kubernetes cluster. + +Role Variables +-------------- + +target_namespace: a namespace in which to deploy this application (will be created) + +Dependencies +------------ + +geerlingguy.containerd +geerlingguy.kubernetes + +Example Playbook +---------------- + + - hosts: servers + roles: + - { role: ericomeehan.gondwana, target_namespace: prod } + +License +------- + +BSD + +Author Information +------------------ + +Eric O'Neill Meehan +https://www.eom.dev/ diff --git a/defaults/main.yml b/defaults/main.yml new file mode 100644 index 0000000..ff7d079 --- /dev/null +++ b/defaults/main.yml @@ -0,0 +1,3 @@ +--- +# defaults file for ericomeehan.minecraft.eom.dev +target_namespace: test diff --git a/files/server.properties b/files/server.properties new file mode 100644 index 0000000..8a904f8 --- /dev/null +++ b/files/server.properties @@ -0,0 +1,59 @@ +#Minecraft server properties +#Mon May 27 13:39:37 UTC 2024 +allow-flight=false +allow-nether=true +broadcast-console-to-ops=true +broadcast-rcon-to-ops=true +difficulty=hard +enable-command-block=true +enable-jmx-monitoring=false +enable-query=false +enable-rcon=false +enable-status=true +enforce-secure-profile=true +enforce-whitelist=true +entity-broadcast-range-percentage=100 +force-gamemode=false +function-permission-level=2 +gamemode=survival +generate-structures=true +generator-settings={} +hardcore=false +hide-online-players=false +initial-disabled-packs= +initial-enabled-packs=vanilla +level-name=Gondwana +level-seed=-5079912890610012924 +level-type=minecraft\:large_biomes +log-ips=true +max-chained-neighbor-updates=1000000 +max-players=20 +max-tick-time=60000 +max-world-size=29999984 +motd=A Minecraft server by eom.dev +network-compression-threshold=256 +online-mode=true +op-permission-level=4 +player-idle-timeout=0 +prevent-proxy-connections=false +pvp=true +query.port=25565 +rate-limit=0 +rcon.password= +rcon.port=25575 +require-resource-pack=false +resource-pack= +resource-pack-prompt= +resource-pack-sha1= +server-ip= +server-port=25565 +simulation-distance=10 +spawn-animals=true +spawn-monsters=true +spawn-npcs=true +spawn-protection=16 +sync-chunk-writes=true +text-filtering-config= +use-native-transport=true +view-distance=10 +white-list=true diff --git a/files/whitelist.json b/files/whitelist.json new file mode 100644 index 0000000..a395217 --- /dev/null +++ b/files/whitelist.json @@ -0,0 +1,27 @@ +[ + { + "uuid": "94e6d0fc-bd44-4f50-ae67-cb9a7b3a4050", + "name": "TopHatRick" + }, + { + "uuid": "8f2a59e5-84ef-46a2-8eec-7988171e6e1f", + "name": "PVitamin" + }, + { + "uuid": "a7b53bb0-ed66-4129-9c41-d8b51d383978", + "name": "BloodRavenGhola" + }, + { + "uuid": "01188fed-cb2a-4fb7-b9a3-c43132bb8a30", + "name": "ThisNurseKills" + }, + { + "uuid": "29ace271-a0b8-44be-aa73-61826da768aa", + "name": "ActuallyItsLars" + }, + { + "uuid": "adac3ea5-bdd8-44d5-bc26-bf0e5f7790bf", + "name": "thegreatyamwar" + } +] + diff --git a/handlers/main.yml b/handlers/main.yml new file mode 100644 index 0000000..019ca4f --- /dev/null +++ b/handlers/main.yml @@ -0,0 +1,2 @@ +--- +# handlers file for ericomeehan.minecraft.eom.dev diff --git a/meta/main.yml b/meta/main.yml new file mode 100644 index 0000000..c572acc --- /dev/null +++ b/meta/main.yml @@ -0,0 +1,52 @@ +galaxy_info: + author: your name + description: your role description + company: your company (optional) + + # If the issue tracker for your role is not on github, uncomment the + # next line and provide a value + # issue_tracker_url: http://example.com/issue/tracker + + # Choose a valid license ID from https://spdx.org - some suggested licenses: + # - BSD-3-Clause (default) + # - MIT + # - GPL-2.0-or-later + # - GPL-3.0-only + # - Apache-2.0 + # - CC-BY-4.0 + license: license (GPL-2.0-or-later, MIT, etc) + + min_ansible_version: 2.1 + + # If this a Container Enabled role, provide the minimum Ansible Container version. + # min_ansible_container_version: + + # + # Provide a list of supported platforms, and for each platform a list of versions. + # If you don't wish to enumerate all versions for a particular platform, use 'all'. + # To view available platforms and versions (or releases), visit: + # https://galaxy.ansible.com/api/v1/platforms/ + # + # platforms: + # - name: Fedora + # versions: + # - all + # - 25 + # - name: SomePlatform + # versions: + # - all + # - 1.0 + # - 7 + # - 99.99 + + galaxy_tags: [] + # List tags for your role here, one per line. A tag is a keyword that describes + # and categorizes the role. Users find roles by searching for tags. Be sure to + # remove the '[]' above, if you add tags to this list. + # + # NOTE: A tag is limited to a single word comprised of alphanumeric characters. + # Maximum 20 tags per role. + +dependencies: [] + # List your role dependencies here, one per line. Be sure to remove the '[]' above, + # if you add dependencies to this list. diff --git a/tasks/deploy-production.yml b/tasks/deploy-production.yml new file mode 100644 index 0000000..9c2d1ef --- /dev/null +++ b/tasks/deploy-production.yml @@ -0,0 +1,124 @@ +--- +# tasks file for deploy-production.yml +- name: Create persistent volume for gondwanamc production + k8s: + state: present + definition: + apiVersion: v1 + kind: PersistentVolume + metadata: + name: pv-gondwanamc-production + spec: + capacity: + storage: 8Gi + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + storageClassName: standard + hostPath: + path: /data/store-0/pv-gondwanamc-production + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - alpha-worker-0 + +- name: Unpack gondwanamc world data to the production persistent volume + unpack: + src: Gondwana.tar.gz + dest: /data/store-0/pv-gondwanamc-production + copy: true + +- name: Copy server properties to production persistent volume + copy: + src: server.properties + dest: /data/store-0/pv-gondwanamc-production + +- name: Copy whitelist to production persistent volume + copy: + src: whitelist.json + dest: /data/store-0/pv-gondwanamc-production + +- name: Create persistent volume claim for gondwanamc production volume + k8s: + state: present + definition: + apiVersion: v1 + kind: PersistentVolumeClaim + metadata: + name: pv-claim-gondwanamc-production + namespace: production + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 8Gi + storageClassName: standard + volumeName: pv-gondwanamc-production + +- name: Create a production Deployment + k8s: + definition: + apiVersion: apps/v1 + kind: Deployment + metadata: + name: minecraft-deployment + namespace: production + spec: + replicas: 1 + selector: + matchLabels: + app: gondwanamc.com + template: + metadata: + labels: + app: gondwanamc.com + spec: + containers: + - name: openminecraft + image: itzg/minecraft-server + volumeMounts: + - name: pv-gondwanamc-production + mountPath: /data + ports: + - containerPort: 25565 + - containerPort: 24454 + env: + - name: EULA + value: "TRUE" + - name: TYPE + value: "FABRIC" + - name: MODS + value: "https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/fabric,https://cdn.modrinth.com/data/bWrNNfkb/versions/D4KXqjtC/Floodgate-Fabric-2.2.3-SNAPSHOT%2Bbuild.28.jar,https://www.curseforge.com/api/v1/mods/306612/files/5510851/download,https://www.curseforge.com/api/v1/mods/416089/files/5500955/download" + - name: MEMORY + value: "16G" + volumes: + - name: pv-gondwanamc-production + persistentVolumeClaim: + claimName: pv-claim-gondwanamc-production + +- name: Expose Deployment as a Service in production + k8s: + definition: + apiVersion: v1 + kind: Service + metadata: + name: service-gondwanamc-com + namespace: production + spec: + selector: + app: gondwanamc.com + ports: + - port: 24454 + protocol: TCP + name: minecraft-port-24454 + nodePort: "{{ nodePorts[gondwanamc-24454] }}" + - port: 25565 + protocol: TCP + name: minecraft-port-25565 + nodePort: "{{ nodePorts[gondwanamc-25565] }}" + type: NodePort diff --git a/tasks/deploy-testing.yml b/tasks/deploy-testing.yml new file mode 100644 index 0000000..4c0a299 --- /dev/null +++ b/tasks/deploy-testing.yml @@ -0,0 +1,104 @@ +--- +# tasks file for ericomeehan.minecraft.eom.dev +- name: Create persistent volume for gondwanamc testing + k8s: + state: present + definition: + apiVersion: v1 + kind: PersistentVolume + metadata: + name: pv-gondwanamc-testing + spec: + capacity: + storage: 1Gi + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + storageClassName: standard + hostPath: + path: /data/store-0/pv-gondwanamc-testing + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - alpha-worker-0 + +- name: Create persistent volume claim for gondwanamc testing volume + k8s: + state: present + definition: + apiVersion: v1 + kind: PersistentVolumeClaim + metadata: + name: pv-claim-gondwanamc-testing + namespace: testing + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi + storageClassName: standard + volumeName: pv-gondwanamc-testing + +- name: Create a testing Deployment + k8s: + definition: + apiVersion: apps/v1 + kind: Deployment + metadata: + name: minecraft-deployment + namespace: testing + spec: + replicas: 1 + selector: + matchLabels: + app: gondwanamc.com + template: + metadata: + labels: + app: gondwanamc.com + spec: + containers: + - name: openminecraft + image: itzg/minecraft-server + volumeMounts: + - name: pv-gondwanamc-testing + mountPath: /data + ports: + - containerPort: 25565 + - containerPort: 24454 + env: + - name: EULA + value: "TRUE" + - name: TYPE + value: "FABRIC" + - name: MODS + value: "https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/fabric,https://cdn.modrinth.com/data/bWrNNfkb/versions/D4KXqjtC/Floodgate-Fabric-2.2.3-SNAPSHOT%2Bbuild.28.jar,https://www.curseforge.com/api/v1/mods/306612/files/5510851/download,https://www.curseforge.com/api/v1/mods/416089/files/5500955/download" + volumes: + - name: pv-gondwanamc-testing + persistentVolumeClaim: + claimName: pv-claim-gondwanamc-testing + +- name: Expose Deployment as a Service in testing + k8s: + definition: + apiVersion: v1 + kind: Service + metadata: + name: service-gondwanamc-com + namespace: testing + spec: + selector: + app: gondwanamc.com + ports: + - port: 24454 + protocol: TCP + name: minecraft-port-24454 + - port: 25565 + protocol: TCP + name: minecraft-port-25565 + type: ClusterIP diff --git a/tasks/main.yml b/tasks/main.yml new file mode 100644 index 0000000..c7f3008 --- /dev/null +++ b/tasks/main.yml @@ -0,0 +1,117 @@ +--- +# tasks file for ericomeehan.gondwana +# TODO: Create configmaps for configurations +- name: Create gondwana namespace + k8s: + state: present + definition: + apiVersion: v1 + kind: Namespace + metadata: + name: "gondwana-{{ target_namespace }}" + +- name: Create persistent volume for gondwana + k8s: + state: present + definition: + apiVersion: v1 + kind: PersistentVolume + metadata: + name: gondwana-mc-pv + spec: + capacity: + storage: 32Gi + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + storageClassName: standard + hostPath: + path: "/data/store-0/gondwana/mc" + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: kubernetes.io/hostname + operator: In + values: + - alpha-worker-0 + +- name: Create persistent volume claim for gondwana volume + k8s: + state: present + definition: + apiVersion: v1 + kind: PersistentVolumeClaim + metadata: + name: mc-pvc + namespace: "gondwana-{{ target_namespace }}" + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 8Gi + storageClassName: standard + volumeName: gondwana-mc-pv + +- name: Create a Deployment + k8s: + definition: + apiVersion: apps/v1 + kind: Deployment + metadata: + name: mc-deploy + namespace: "gondwana-{{ target_namespace }}" + spec: + replicas: 1 + selector: + matchLabels: + app: mc + template: + metadata: + labels: + app: mc + spec: + containers: + - name: minecraft + image: itzg/minecraft-server + volumeMounts: + - name: data + mountPath: /data + ports: + - containerPort: 25565 + - containerPort: 24454 + protocol: UDP + env: + - name: EULA + value: "TRUE" + - name: TYPE + value: "FABRIC" + - name: MODS + value: "https://download.geysermc.org/v2/projects/geyser/versions/latest/builds/latest/downloads/fabric,https://cdn.modrinth.com/data/bWrNNfkb/versions/D4KXqjtC/Floodgate-Fabric-2.2.3-SNAPSHOT%2Bbuild.28.jar,https://www.curseforge.com/api/v1/mods/306612/files/5510851/download,https://www.curseforge.com/api/v1/mods/416089/files/5500955/download" + - name: MEMORY + value: "8G" + volumes: + - name: data + persistentVolumeClaim: + claimName: mc-pvc + +- name: Expose Deployment as a Service + k8s: + definition: + apiVersion: v1 + kind: Service + metadata: + name: mc-svc + namespace: "gondwana-{{ target_namespace }}" + spec: + selector: + app: mc + ports: + - port: 24454 + protocol: UDP + name: mc-port-24454 + - port: 25565 + protocol: TCP + name: mc-port-25565 + type: NodePort diff --git a/tests/inventory b/tests/inventory new file mode 100644 index 0000000..878877b --- /dev/null +++ b/tests/inventory @@ -0,0 +1,2 @@ +localhost + diff --git a/tests/test.yml b/tests/test.yml new file mode 100644 index 0000000..30cc88a --- /dev/null +++ b/tests/test.yml @@ -0,0 +1,5 @@ +--- +- hosts: localhost + remote_user: root + roles: + - ericomeehan.minecraft.eom.dev diff --git a/vars/main.yml b/vars/main.yml new file mode 100644 index 0000000..27e60e7 --- /dev/null +++ b/vars/main.yml @@ -0,0 +1,2 @@ +--- +# vars file for ericomeehan.minecraft.eom.dev