Minecraft
Quelle joie pour moi de déployer un serveur minecraft dans K8S !
En prérequits à ce tuto :
- https://docs.nehemiebarkia.fr/books/kubernetes/page/avec-cilium
- https://docs.nehemiebarkia.fr/books/kubernetes/page/longhorn
Déclaration du PVC :
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: minecraft-srv-01-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn
resources:
requests:
storage: 50Gi
EOF
Déploiement & service minecraft :
cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: hello-world
namespace: default
spec:
replicas: 2
selector:
matchLabels:
app: hello-world
template:
metadata:
labels:
app: hello-world
spec:
containers:
- name: hello
image: hashicorp/http-echo:latest
args:
- "-text=Hello from Cilium VIP 👋"
- "-listen=:8080"
ports:
- containerPort: 8080
volumeMounts:
- name: storage-volume
mountPath: /data
volumes:
- name: storage-volume
persistentVolumeClaim:
claimName: longhorn-hello-pvc
---
apiVersion: v1
kind: Service
metadata:
name: hello-world
namespace: default
labels:
expose: "true"
annotations:
lbipam.cilium.io/ips: "192.168.1.2" # IP fixe dans le pool
spec:
type: LoadBalancer
selector:
app: hello-world
ports:
- port: 80
targetPort: 8080
EOF