Created
September 24, 2020 18:01
-
-
Save geerlingguy/2f4b0c06b4b696c8983b82dda655adf3 to your computer and use it in GitHub Desktop.
Minecraft installation on Kubernetes via Ansible and Helm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Minecraft Server deployment for Kubernetes clusters via Ansible's Helm module. | |
# | |
# The Helm module is part of the Kubernetes collection. Install it with: | |
# | |
# ansible-galaxy collection install community.kubernetes | |
# | |
# Then run the playbook: | |
# | |
# ansible-playbook main.yml | |
# | |
# This playbook assumes the following: | |
# | |
# 1. Your default ~/.kube/config points to a running Kubernetes cluster; | |
# otherwise set the K8S_AUTH_KUBECONFIG environment variable to the path to | |
# the correct kubeconfig). | |
# | |
# 2. You already have Helm and Ansible installed locally. | |
--- | |
- hosts: localhost | |
connection: local | |
gather_facts: false | |
tasks: | |
- name: Create minecraft namespace. | |
community.kubernetes.k8s: | |
name: minecraft | |
api_version: v1 | |
kind: Namespace | |
state: present | |
- name: Add itzg chart repo. | |
community.kubernetes.helm_repository: | |
name: itzg | |
repo_url: "https://itzg.github.io/minecraft-server-charts/" | |
- name: Deploy Minecraft Helm chart. | |
community.kubernetes.helm: | |
name: minecraft | |
chart_ref: itzg/minecraft | |
chart_version: '2.0.7' | |
release_namespace: minecraft | |
state: present | |
values: | |
minecraftServer: | |
eula: true | |
Difficulty: easy | |
motd: "Welcome to Minecraft deployed via Helm and Ansible!" | |
serviceType: NodePort | |
- name: Get Minecraft server NodePort. | |
community.kubernetes.k8s_info: | |
api_version: v1 | |
name: minecraft-minecraft | |
kind: Service | |
namespace: minecraft | |
register: service | |
- name: Print Minecraft server NodePort. | |
debug: | |
msg: "Minecraft NodePort: {{ service.resources[0].spec.ports[0].nodePort }}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment