Running Jamcaster in GKE autopilot

If you are on an unreliable internet connection but want to stream a Jamulus room, running Jamcaster on Google Kubernetes Engine in autopilot mode can be a cost-efficient way do it. You don’t have to manage virtual machines, and you don’t have to worry about the cost of running the cluster — you only pay for the time Jamcaster spends running.

How much does it cost?

Prerequisites

  • You have a Google Cloud project.

Environment config

GOOGLE_CLOUD_PROJECT=
GOOGLE_CLOUD_REGION=

Create a Google Kubernetes Engine cluster

Create a GKE autopilot cluster:

gcloud container clusters create-auto k8s-playground --region $GOOGLE_CLOUD_REGION

Wait 5 minutes.

Configure Kubectl:

gcloud container clusters get-credentials k8s-playground --region $GOOGLE_CLOUD_REGION

Get the nodes:

kubectl get nodes

Push Docker image to Artifact Repository

This will cost about $0.3 per month to store the Jamcaster image on the cloud.

Create an artifact repository:

gcloud artifacts repositories create jamcaster \
   --repository-format=docker \
   --location=$GOOGLE_CLOUD_REGION \
   --description="Docker repository for jamcaster"

Pull Jamcaster image:

docker pull ghcr.io/dtinth/jamcaster:main

Tag the image:

docker tag ghcr.io/dtinth/jamcaster:main $GOOGLE_CLOUD_REGION-docker.pkg.dev/$GOOGLE_CLOUD_PROJECT/jamcaster/jamcaster:main

Configure Docker to push to the artifact repository:

gcloud auth configure-docker $GOOGLE_CLOUD_REGION-docker.pkg.dev

Push the image to the artifact repository:

docker push $GOOGLE_CLOUD_REGION-docker.pkg.dev/$GOOGLE_CLOUD_PROJECT/jamcaster/jamcaster:main

Create a pod

jamcaster.yml
apiVersion: v1
kind: Pod
metadata:
  name: jamcaster
spec:
  containers:
    - name: jamcaster
      image: $GOOGLE_CLOUD_REGION-docker.pkg.dev/$GOOGLE_CLOUD_PROJECT/jamcaster/jamcaster:main
      env:
        - name: VIDEO_STREAM_TARGET
          value: rtmps://live-api-s.facebook.com:443/rtmp/<stream_key>
        - name: JAMULUS_SERVER
          value: <ip>:<port>
        - name: JAMULUS_CLIENT_NAME
          value: JamRadio
      resources:
        requests:
          cpu: 2000m
          memory: 1Gi
        limits:
          cpu: 2000m
          memory: 1Gi
  restartPolicy: OnFailure
Replace the variables with your own values.

Run it

kubectl apply -f jamcaster.yml

Debugging tips

Running commands inside the container
kubectl exec --stdin --tty jamcaster -- /bin/bash
View logs
kubectl logs jamcaster -f
Port-forward the VNC port
kubectl port-forward jamcaster 5901:5900
Port-forward the JSON-RPC port
kubectl port-forward jamcaster 22100:22100

Clean up

kubectl delete -f jamcaster.yml