Remote Clouds

Gefyra on Google Kubernetes Engine (GKE)

Bridge local containers into a remote GKE cluster with Gefyra — WireGuard over UDP 31820, firewall rules, and live staging development.

Prerequisites

  1. You have the gcloud command installed
  2. Follow the installation of Gefyra for your preferred platform

Additionally you need an account for the Google Cloud Platform including the permission to create a new cluster. Make sure your gcloud is using the right project configuration. Googles documentation is available here.

Setup a cluster

  1. The easiest way to create a new cluster is using gcloud:
gcloud container clusters create spacecraft

This may take a few minutes, there will be 3 VM instances running a kubernetes cluster ready to serve your applications. gcloud will set your kubectl context to the created cluster, nothing to worry about!

  1. The last thing we need to do is open a port in the firewall. This allows gefyra to connect to the cluster using wireguard:
gcloud compute firewall-rules create gefyra --allow udp:31820
  1. Apply some workload, for example from the testing directory of this repo:
kubectl apply -f https://raw.githubusercontent.com/gefyrahq/gefyra/main/testing/workloads/hello_dd.yaml

Running Gefyra

  1. At first, we need a host IP of one of our compute instances. You can get them with running gcloud compute instances list. Pick one of them.
  2. Now you can run gefyra up --host <IP>
  3. Run a local container with Gefyra (Zero Image Build):
# 1. Create a local response file
mkdir -p /tmp/local-server
echo "<h1>Hello from Gefyra. Live local code served directly into GKE!</h1>" > /tmp/local-server/index.html

# 2. Run the local container in Gefyra
gefyra run \
  -i python:3.12-alpine \
  -N mypyserver \
  -v /tmp/local-server:/app \
  -c "python3 -m http.server 8000 -d /app" \
  -d
  1. Exec into the running container and verify cluster access:
docker exec -it mypyserver sh
wget -O- hello-nginx
exit
  1. Mount the workload and create a bridge to intercept traffic with your local container:
# 1. Mount the deployment with Carrier2
gefyra mount create --target deployment/hello-nginxdemo/hello-nginx --name mymount

# 2. Bridge traffic to your local container
gefyra bridge create --mount mymount -p 80:8000 -t mypyserver --match-path-prefix /
  1. List active mounts and bridges:
gefyra bridge list
gefyra mount list
  1. Remove the bridge and unmount the workload to reset the cluster:
# Delete the bridge
gefyra bridge delete <bridge-id>

# Unmount the workload and restore original container image
gefyra mount delete mymount

Cleaning up

Remove Gefyra's components from the cluster with gefyra down