Getting started with Gefyra and Minikube
This guide describes the usage of Gefyra for the local development of a Kubernetes application running in Minikube.
Important: This getting started guide for Minikube requires Gefyra in version 0.9.0+.
Prerequisites
Creating a local Kubernetes cluster
- Create a local Kubernetes cluster with Minikube by running:
minikube start
Important: the following example does not fully work with --driver=qemu
since minikube service
is not currently
implemented with the qemu2 driver. See https://github.com/kubernetes/minikube/issues/14146 for details.
Tested drivers are: docker, kvm2, kvm, virtualbox. Others are potentially working, but are not tested.
After some time of downloading the required resources, the cluster will be running. You may enable the required
addons based on your requirements. The kubectl
context is immediately set to this cluster. You can check if
kubectl config current-context
is set to minikube
.
kubectl config current-context
- Apply some workload, for example from the testing directory of this repository:
kubectl apply -f https://raw.githubusercontent.com/gefyrahq/gefyra/main/testing/workloads/hello.yaml
- Check the output of the deployed app with:
kubectl expose deployment hello-nginxdemo --type=NodePort --port=80
minikube service hello-nginxdemo
Running Gefyra
- Set up Gefyra with your Minikube cluster:
gefyra up --minikube
The --minikube
switch detects all required connection parameters from your local cluster.
2. 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. 3. 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 8000:80 --target deploy/hello-nginxdemo/hello-nginx
Check out the locally running server comes up by refreshing the address from:
minikube service hello-nginxdemo
- List all running bridges:
gefyra list --bridges
- Unbridge the local container and reset the cluster to its original state:
gefyra unbridge -N mypybridge
Check out the initial response from:
minikube service hello-nginxdemo
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.