Getting started with Gefyra and the Google Cloud Platform
This guide will show you how to use Gefyra for the remote development of a Kubernetes Application running in the Google Kubernetes Engine (GKE).
Prerequisites
- You have the gcloud command installed
- 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
- 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!
- 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
- 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
- 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. - Now you can run
gefyra up --host <IP>
- Run a local Docker image with Gefyra in order to make it part of the cluster.
- Build your Docker image with a local tag, for example from the testing directory:
cd testing/images/ && docker build -f Dockerfile.local . -t pyserver
- Execute Gefyra's run command:
gefyra run -i pyserver -N mypyserver -n default
- Exec into the running container and look around. You will find the container to run within your Kubernetes cluster.
docker exec -it mypyserver bash
wget -O- hello-nginx
will print out the website of the cluster service hello-nginx from within the cluster.
- Build your Docker image with a local tag, for example from the testing directory:
- Create a bridge in order to intercept the traffic to the cluster application with the one running locally:
gefyra bridge -N mypyserver -n default --port 80:8000 --target deploy/hello-nginxdemo/hello-nginx
- List all running bridges:
gefyra list --bridges
- Unbridge the local container and reset the cluster to its original state:
gefyra unbridge -N mypybridge
Cleaning up
Remove Gefyra's components from the cluster with gefyra down
Provide us with your feedback
Did everything work as expected? How was the experience of using Gefyra? We'd appreciate if you could take 2 minutes of your time to fill out our feedback form.