Introduction

Minishift allows you to run a OKD cluster locally on your developer workstation or laptop. It automates the deployment and configuration of a virtual machine which then allows you to try out and develop with, OKD.

Deployment

Minishift is relatively simple to deploy and is easiest to deploy using VirtualBox on most distributions of Linux, MacOS and even Windows. In the guide however, I’ll be focusing on using minishift on KVM, using Fedora.

To begin with, we need to ensure we have KVM and libvirt configured correctly

$ sudo dnf -y update
$ sudo dnf -y install bridge-utils libvirt virt-install qemu-kvm
$ sudo dnf -y install virt-top libguestfs-tools
$ sudo systemctl enable --now libvirtd

We’ll add our current logged in user to the libvirt group, which will allow us to interact with qemu:

$ sudo usermod -a -G libvirt $(whoami)
$ newgrp libvirt

We’re almost ready to grab the minishift binary, however we need to ensure the docker machine driver for kvm is installed and located within our system’s path. There isn’t a Fedora specific version, but there is a CentOS version which works just fine:

$ wget https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.10.0/docker-machine-driver-kvm-centos7
$ sudo cp docker-machine-driver-kvm-centos7 /usr/local/bin/docker-machine
$ sudo chmod +x /usr/local/bin/docker-machine-driver-kvm

Next it’s time to grab the minishift binary, extract it, and copy it to /usr/local/bin

$ wget https://github.com/minishift/minishift/releases/download/v1.34.1/minishift-1.34.1-linux-amd64.tgz
$ tar -xvf minishift-1.34.1-linux-amd64.tgz
$ sudo cp minishift-1.34.1-linux-amd64/minishift /usr/local/bin/

Now everything is setup, we can start our minishift cluster:

$ minishift start --vm-driver kvm

Minishift will take a while to download the VM ISO, boot and initialise the cluster. After that is complete it will also copy across the ‘oc’ binary and setup your local profile configuration to interact with minishift as the ‘system:admin’ user. In my case, it didn’t successfully do the last part, So i needed to get the auth token from the gui, which I found the address of doing the following:

$ minishift console --url

Simply browse to that url and log in using the user name “developer” and any password. When logged in, click “Copy Login Command” from the drop down next to the “developer” user displayed in the top right hand side of your window. Past that into the terminal, and you’ll successfully be logged in.

For example:

$ oc login https://192.168.42.109:8443 --token=1Dp__oVDcCmwE18nM1MY5OMuDJ0nAmzQ-VFdt8Ewbcg

You can now check we’re logged in and ready:

$ oc status
he server uses a certificate signed by an unknown authority.
You can bypass the certificate check, but any data you send to the server could be intercepted by others.
Use insecure connections? (y/n): y

Logged into "https://192.168.42.109:8443" as "developer" using the token provided.

You have one project on this server: "myproject"

Using project "myproject".
[matt@matt-fedora-desktop ~]$ oc status
In project My Project (myproject) on server https://192.168.42.109:8443

You have no services, deployment configs, or build configs.
Run 'oc new-app' to create an application.

Creating our first project

We’re now ready to deploy our very first app. We’ll start by creating a new project:

$ oc new-project hello

Now using project "hello" on server "https://192.168.42.109:8443".

You can add applications to this project with the 'new-app' command. For example, try:

    oc new-app centos/ruby-25-centos7~https://github.com/sclorg/ruby-ex.git

to build a new example application in Ruby.

And we’ll now deploy an application for demo purposes, please don’t run this in production:

$ oc new-app mkimberley84/hellogo:latest
--> Found Docker image a4436f1 (2 weeks old) from Docker Hub for "mkimberley84/hellogo:latest"

    * An image stream tag will be created as "hellogo:latest" that will track this image
    * This image will be deployed in deployment config "hellogo"
    * Port 8080/tcp will be load balanced by service "hellogo"
      * Other containers can access this service through the hostname "hellogo"
    * WARNING: Image "mkimberley84/hellogo:latest" runs as the 'root' user which may not be permitted by your cluster administrator

--> Creating resources ...
    imagestream.image.openshift.io "hellogo" created
    deploymentconfig.apps.openshift.io "hellogo" created
    service "hellogo" created
--> Success
    Application is not exposed. You can expose services to the outside world by executing one or more of the commands below:
     'oc expose svc/hellogo' 
    Run 'oc status' to view your app.

We can now get the status of our pods and wait for them to become ready:

$ oc get pods
AME              READY     STATUS    RESTARTS   AGE
hellogo-1-92mhd   1/1       Running   0          15s

Accessing our project externally

After awhile, the container image will be pulled down, and our pod started. The next stage, is to give the service an external IP address. We’ll do this by exposing it.

$ oc expose deploymentconfig/hellogo --type=LoadBalancer --name=hellogo-ingress
$ oc expose service/hellogo-ingress
$ oc get route

If you browse to the url listed by ‘oc get route’ you’ll see our hello application.

Congratulations on successfully configuring minishift on KVM, and deploying your first OKD application