Skip to main content Link Search Menu Expand Document (external link)
Star

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.

  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
  2. Check the output of the deployed app with:
    1. kubectl expose deployment hello-nginxdemo --type=NodePort --port=80
    2. 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
    3. 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 --deployment hello-nginxdemo --port 8000:80 --container-name hello-nginx -I mypybridge
    Check out the locally running server comes up by refreshing the address from: minikube service hello-nginxdemo
  4. List all running bridges:
    gefyra list --bridges
  5. 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