FauxpenShift

This cli utility creates a Kubernetes cluster using KIND (KIND runs Kubernetes in a containers) and installs the OpenShift Router on top of it. This is useful for when you want to test your applications using OpenShift routes, but CRC is too heavy.

Prerequisites

At a minimum

  • Docker or Podman (podman is experimental)
  • Access to Nip.io

While you don’t need the kind CLI, you do need to satisfy all the prereqs for KIND. If you’re having trouble see their official docs.

Running it

Download the CLI from and put it in your path.

Linux

sudo wget -O /usr/local/bin/fauxpenshift https://github.com/christianh814/fauxpenshift/releases/download/v0.0.2/fauxpenshift-amd64-linux

Mac OS (Intel)

sudo wget -O /usr/local/bin/fauxpenshift https://github.com/christianh814/fauxpenshift/releases/download/v0.0.2/fauxpenshift-amd64-darwin

Make it executable

sudo chmod +x /usr/local/bin/fauxpenshift

Bash completion if you wish

source <(fauxpenshift completion bash)

Create a Kubernetes cluster with an OpenShift Router:

fauxpenshift create

NOTE To use Podman run: sudo KIND_EXPERIMENTAL_PROVIDER=podman fauxpenshift create

You should have a Kubernetes Cluster with the router running

NOTE If using Podman, you must extract the kubeconfig config by runnning: sudo fauxpenshift kubeconfig

oc get pods -n openshift-ingress 

Testing It

Now let’s create an app and expose a route. First create a namespace

oc create ns welcome-app

Create a deployment in this namespace

oc create deployment welcome-php \
--image=quay.io/redhatworkshops/welcome-php:latest -n welcome-app

Create a service for this deployment

oc expose deployment welcome-php --port=8080 --target-port=8080 -n welcome-app

Now create a route

oc expose svc/welcome-php -n welcome-app

Patch things that the oc expose didn’t 100% get you.

NOTE: You only need to do this if you’re doing this from scratch. If you have a “known good” YAML for your application it should “just work”

kubectl patch route welcome-php -n welcome-app --type=json -p='[{"op": "add", "path": "/spec/to/kind", "value":"Service"}]'
kubectl patch route welcome-php -n welcome-app --type=json -p='[{"op": "add", "path": "/spec/wildcardPolicy", "value":"Subdomain"}]'

Get your route

oc get route -n welcome-app

Curl it (or open it up in a browser)

curl -sI http://$(oc get route welcome-php -n welcome-app -o jsonpath='{.status.ingress[0].host}')

Clean Up

Delete your cluster

fauxpenshift destroy

NOTE If using Podman, run: sudo KIND_EXPERIMENTAL_PROVIDER=podman fauxpenshift destroy

GitHub

View Github