Skip to main content
Version: 1.x

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

  1. Minikube is installed (at least in version v1.26.1)
  2. Gefyra is available (at least in version 0.9.0)

Creating a local Kubernetes cluster

  1. 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
  1. 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
  1. Check the output of the deployed app with:
kubectl expose deployment hello-nginxdemo --type=NodePort --port=80
minikube service hello-nginxdemo

Running Gefyra

  1. 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.

  1. Build your Docker image with a local tag, for example from the testing directory: cd testing/images/ && docker build -f Dockerfile.local . -t pyserver
  2. Execute Gefyra's run command:
gefyra run -i pyserver -N mypyserver -n default
  1. 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
  1. List all running bridges:
gefyra list --bridges
  1. 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.