Skip to content

About

Repository for the GitOps workshop using Paper at the Cybersecurity Center at MSU Denver

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

40 Commits

Folders and files

Repository files navigation

The Cybersecurity Center

MSU Denver GitOps Workshop

Deploy a PaperMC Minecraft server to DigitalOcean Kubernetes using GitOps principles.

Kubernetes ArgoCD Docker GitHub Actions OpenTofu DigitalOcean Envoy Gateway PaperMC

Prerequisites

Note About Minecraft Version

Note: The server runs Minecraft 1.21.11.

In the Minecraft Launcher, create an installation for version 1.21.11 (Installations → New installation) and use it to connect. The latest client version will not join a 1.21.11 server.

Lab Environment Setup

Fork the repository

  1. Fork this repository to your GitHub account.

  2. GitHub disables workflows on forks by default. Go to the Actions tab in your fork and click "I understand my workflows, enable them".

  3. The workflow runs two jobs on every push: secret-scan and build. The secret-scan job uses TruffleHog to scan your git history for leaked credentials (like your DigitalOcean token) and blocks the build if it finds any. Make a small commit to main to trigger the workflow, then verify both jobs pass. Once complete, your container image will be available at ghcr.io/<your-github-username>/msud-cmute-gitops-workshop:latest.

  4. By default, the package GitHub builds is private and your cluster will not be able to pull it. Go to your fork's Packages → msud-cmute-gitops-workshop → Package settings → Change visibility → Public.

Provision your cluster

  1. Install and authenticate doctl:
doctl auth init --access-token <YOUR_DO_TOKEN>
  1. Provision your DOKS cluster:
cd infra/tofu
cp terraform.tfvars.example terraform.tfvars
  1. Edit terraform.tfvars — replace <YOUR_NAME> in cluster_name with your name (lowercase, no spaces).

  2. Apply:

tofu init
tofu plan
tofu apply

Cluster creation takes ~8 minutes. Grab some water.

  1. Save your kubeconfig:
doctl kubernetes cluster kubeconfig save paper-<YOUR_NAME>

Example:

doctl kubernetes cluster kubeconfig save paper-test
  1. Verify access:
kubectl get nodes

You should see a single node in Ready status.

Example:

NAME             STATUS   ROLES    AGE   VERSION
default-37gop8   Ready    <none>   14m   v1.36.0

Bootstrap cluster infrastructure

  1. Install the Gateway API CRDs and Envoy Gateway:
kubectl apply --server-side --force-conflicts \
  -f https://github.com/kubernetes-sigs/gateway-api/releases/download/v1.5.1/experimental-install.yaml

You should see:

customresourcedefinition.apiextensions.k8s.io/backendtlspolicies.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/gatewayclasses.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/gateways.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/grpcroutes.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/httproutes.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/listenersets.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/referencegrants.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/tcproutes.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/tlsroutes.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/udproutes.gateway.networking.k8s.io serverside-applied
validatingadmissionpolicy.admissionregistration.k8s.io/safe-upgrades.gateway.networking.k8s.io serverside-applied
validatingadmissionpolicybinding.admissionregistration.k8s.io/safe-upgrades.gateway.networking.k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/xbackendtrafficpolicies.gateway.networking.x-k8s.io serverside-applied
customresourcedefinition.apiextensions.k8s.io/xmeshes.gateway.networking.x-k8s.io serverside-applied
helm install eg oci://docker.io/envoyproxy/gateway-helm \
  --version v1.8.2 \
  -n envoy-gateway-system \
  --create-namespace \
  --skip-crds
kubectl apply -f infra/envoy-gateway/gatewayclass.yaml

Verify Envoy Gateway is running and the GatewayClass is accepted:

kubectl get pods -n envoy-gateway-system
kubectl get gatewayclass eg
NAME   CONTROLLER                                      ACCEPTED   AGE
eg     gateway.envoyproxy.io/gatewayclass-controller   True       14s
  1. Install cert-manager:
kubectl apply --server-side -f https://github.com/cert-manager/cert-manager/releases/download/v1.21.0/cert-manager.yaml
kubectl wait --for=condition=available deployment/cert-manager -n cert-manager --timeout=120s
  1. Create the DigitalOcean DNS-01 secret and ClusterIssuer (use the same DO token from earlier):

NOTE: BE SURE TO REPLACE THE EMAIL LINE!!!

kubectl create secret generic digitalocean-dns \
  --namespace cert-manager \
  --from-literal=access-token=<YOUR_DO_TOKEN>

Edit infra/cert-manager/clusterissuer.yaml and replace <YOUR_EMAIL> with your email. Then run:

kubectl apply -f infra/cert-manager/clusterissuer.yaml
  1. Install ArgoCD:
kubectl create namespace argocd
kubectl apply -n argocd --server-side -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml
  1. Verify ArgoCD is running:
kubectl wait --for=condition=available deployment/argocd-server -n argocd --timeout=120s

Prepare ArgoCD for the shared Gateway

The single paper-gateway (defined in k8s/gateway.yaml) has two listeners: a TCP listener for Minecraft and an HTTPS listener for the ArgoCD UI. They share the same LoadBalancer IP.

  1. Tell ArgoCD not to terminate TLS itself (the Gateway does it):
kubectl patch deployment argocd-server -n argocd --type='json' \
  -p='[{"op": "add", "path": "/spec/template/spec/containers/0/args/-", "value": "--insecure"}]'
kubectl rollout status deployment/argocd-server -n argocd
  1. Edit k8s/argocd-httproute.yaml and replace <YOUR_NAME> with your name, then apply:
kubectl apply -f k8s/argocd-httproute.yaml

Deploy with ArgoCD

  1. Look at all files in k8s/:

    • namespace.yaml
    • configmap.yaml
    • persistentvolumeclaim.yaml
    • deployment.yaml IMPORTANT: replace <YOUR_GITHUB_USERNAME> with your GitHub username (must be lowercase)
    • service.yaml
    • gateway.yaml IMPORTANT: replace <YOUR_NAME> in the ArgoCD HTTPS listener hostname
    • tcproute.yaml
    • certificate.yaml IMPORTANT: replace <YOUR_NAME> in both certs (matches your DNS records below)
  2. In argocd/application.yaml, look at the file and replace <YOUR_GITHUB_USERNAME> with your GitHub username.

  3. Check that you didn't miss any placeholders:

grep -rn "YOUR_NAME\|YOUR_GITHUB" k8s/ argocd/ && echo "^^ FIX THESE BEFORE CONTINUING" || echo "all placeholders replaced"
  1. Commit and push:
git add -A
git commit -m "chore: configure k8s manifests with my values"
git push
  1. Apply the ArgoCD application:
kubectl apply -f argocd/application.yaml
  1. Watch ArgoCD deploy everything:
kubectl get applications -n argocd
kubectl get pods -n paper

The paper pod takes 1–2 minutes to become 1/1 Ready (the startup probe waits for the Minecraft server to boot).

Expose the server

All traffic (Minecraft and the ArgoCD UI) flows through the single Gateway LoadBalancer.

  1. Get your Gateway's external IP:
kubectl get gateway paper-gateway -n paper

The ADDRESS field takes 1–3 minutes to appear while DigitalOcean provisions the load balancer. Your certificates take another 1–3 minutes to become Ready — check with:

kubectl get certificates -n paper
  1. (Optional) Verify the Minecraft port is reachable through the Gateway:
timeout 3 bash -c '</dev/tcp/<GATEWAY_EXTERNAL_IP>/25565' && echo OPEN || echo CLOSED

If this prints OPEN, Envoy is routing TCP traffic to your server. If it prints CLOSED, wait a minute and try again before debugging.

  1. Create a DNS record for ArgoCD pointing to the Gateway IP:
doctl compute domain records create cmute.cloud \
  --record-type A \
  --record-name "argocd.<YOUR_NAME>.mc.labs" \
  --record-data <GATEWAY_EXTERNAL_IP> \
  --record-ttl 300
  1. Create a DNS record for your Minecraft server pointing to the same Gateway IP:
doctl compute domain records create cmute.cloud \
  --record-type A \
  --record-name "<YOUR_NAME>.mc.labs" \
  --record-data <GATEWAY_EXTERNAL_IP> \
  --record-ttl 300
  1. Get the initial ArgoCD admin password and log in at https://argocd.<YOUR_NAME>.mc.labs.cmute.cloud:
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
  1. Connect with your Minecraft client (version 1.21.11) to <YOUR_NAME>.mc.labs.cmute.cloud.

Test GitOps

Make a change and watch ArgoCD sync it automatically.

  1. Edit k8s/configmap.yaml. Change max-players to 50.

  2. Edit k8s/deployment.yaml. Change the configmap-hash annotation to any new value (ex: "2"). This triggers a pod restart so Minecraft picks up the new config.

  3. Commit and push.

  4. Watch the sync:

kubectl get pods -n paper

Within about 3 minutes, ArgoCD will detect the change and roll out a new pod automatically. You'll briefly be disconnected from the server while the pod restarts — that's the deployment happening. Watch it live in the ArgoCD UI.

Extras

Add Prometheus metrics and a Grafana dashboard for your server: extras/observability

Cleanup

Cluster teardown is handled by the instructor after the workshop. Leave your cluster running.

Here is my trivial comment!

About

Repository for the GitOps workshop using Paper at the Cybersecurity Center at MSU Denver

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages