Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Minecraft installation on Kubernetes via Ansible and Helm
# 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
You can’t perform that action at this time.