Disclaimer: the views, thoughts, and opinions expressed in the text belong solely to the author, and not necessarily to the author’s employer, organization, committee or other group or individual.

Today I would like to write about how to run swagger-editor in minikube but before I go on to the details of the story let me give a brief introduction on why I want to do this. I have had the lingering idea for the past few weeks to build a few web based applications to get my feet wet in application developer for web and learn more about Kubernetes in the process. Well if you didn’t know swagger is an open source relatively easy to use suite of api development tools. I’m specifically interested in swagger-editor and the ability to write swagger api specifications.

Now on to the details, swagger-editor can be run via docker itself pretty easily and is documented in there GitHub repository however we will be using minikube. I will not be covering how to setup minikube or docker as that is well documented already. Now a few things to note on software versions we are using, we have:

minikube version: v0.28.0 Docker version 18.03.1-ce, build 9ee9f40 swaggerapi/swagger-editor:latest macOS High Sierra 10.13.5

At this point we will make the assumption that docker and minikube is setup and running. After we have our prerequisites satisfied we will create a namespace inside of minikube.

command: kubectl create namespace swagger

The namespace will be used to separate its resources from the general kubernetes resources. After we have created our namespace swagger we will create the deployment.

command: kubectl -n swagger run swagger-editor --image=swaggerapi/swagger-editor --port=8080

The prior command will do a few things

Create a deployment with the name set to swagger-editor, Use the docker image provider by swaggerapi. And set the swagger-editor to use the 8080 port.

Next we will expose the swagger-editor to be a NodePort service.

command: kubectl -n swagger expose deployment swagger-editor --type=NodePort

Once we have run the prior command all we have to do is get the url to visit the swagger-editor deployment in our browser.

command: minikube service -n swagger --url swagger-editor

This will give us the service url for us to see the swagger-editor application service that we deployed and we can not visit the link in our web browser.

To conclude, we were able to easily deploy our swagger-editor application to minikube and enable us to leverage this tool for swagger api specification editing.