Link Search Menu Expand Document
Star

Getting started with Gefyra and Colima Kubernetes

This guide will show you how to use Gefyra for the local development of a Kubernetes application running in Colima Kubernetes.

Prerequisites

  1. Follow the installation for your preferred platform.

  2. Create a local Kubernetes cluster with colima:

colima start --kubernetes --network-address

Find out the network address of your VM:

colima list
PROFILE    STATUS     ARCH      CPUS    MEMORY    DISK     RUNTIME       ADDRESS
default    Running    x86_64    2       2GiB      60GiB    docker+k3s    192.168.106.2

Install Gefyra components in the cluster:

gefyra up --host=192.168.106.2
  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.yaml
    

Check out this workload running under: http://hello.127.0.0.1.nip.io:8080/

Running Gefyra

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

  2. 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 under: http://hello.127.0.0.1.nip.io:8080/

  3. List all running bridges:
    gefyra list --bridges
    
  4. Unbridge the local container and reset the cluster to its original state:
    gefyra unbridge -N mypybridge
    

    Check out the initial response from: http://hello.127.0.0.1.nip.io:8080/

Cleaning up

  1. Remove Gefyra’s components from the cluster with
    gefyra down
    
  2. Remove the locally running Kubernetes cluster with
    colima delete