Skip to main content

Install local OpenShift

OpenShift and Kubernetes can be installed locally on a single machine for test purpose. The installation requires knowledge of your OS administration, and can be quite complex. We recommend to install it locally only if really required. Otherwise we recommend you to simply use Docker to test images, then deploy them on the DSRI.

Install MiniShift

You will need to set up the virtualization environment before installing MiniShift.

Download MiniShift and unzip it.

# For Ubuntu 18.04 and older
sudo apt install -y libvirt-bin qemu-kvm
# For Ubuntu 18.10 and newer (replace libvirtd by libvirt in next commands)
sudo apt install -y qemu-kvm libvirt-daemon libvirt-daemon-system

# Create group if does not exist
sudo addgroup libvirtd
sudo adduser $(whoami) libvirtd

sudo usermod -a -G libvirtd $(whoami)
newgrp libvirtd
curl -L https://github.com/dhiltgen/docker-machine-kvm/releases/download/v0.10.0/docker-machine-driver-kvm-ubuntu16.04 -o /usr/local/bin/docker-machine-driver-kvm
sudo chmod +x /usr/local/bin/docker-machine-driver-kvm

# Check if libvirtd running
systemctl is-active libvirtd
# Start if inactive
sudo systemctl start libvirtd

# Copy MiniShift in your path
cp minishift-1.34.1-linux-amd64/minishift /usr/local/bin

Start MiniShift

minishift start

Get your local OpenShift cluster URL after the command complete.

Login

Go to your local cluster URL.

E.g. https://192.168.42.58:8443/console/catalog.

Username: admin or developer

Password: anything will work

# As admin
oc login -u system:admin

Stop

minishift stop

Reset

minishift delete -f

Install kubectl

Kubernetes

kubectl on Ubuntu

For more details: read the official install Kubernetes on Ubuntu tutorial or see the official Ubuntu Kubernetes install documentation.

sudo snap install microk8s --classic
sudo usermod -a -G microk8s $USER
# Restart your machine
mkdir -p ~/.kube
microk8s.kubectl config view --raw > $HOME/.kube/config

# Make sure this works for dashboard on Ubuntu
microk8s.enable dashboard dns

To do only if kubectl is not already installed on your machine:

sudo snap alias microk8s.kubectl kubectl

kubectl on MacOS & Windows

Included in Docker installation. Use the installer provided by DockerHub.

Activate it in Docker Preferences > Kubernetes.

For Windows you will need to download the kubectl.exe and place it in your PATH.

We recommend to create a kubectl directory in C:/ and add this C:/kubectl to the Path environment variable in System properties > Advanced > Environment Variables > Path

Install the Dashboard UI

# Install Kubernetes UI
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0-beta4/aio/deploy/recommended.yaml
kubectl apply -f https://raw.githubusercontent.com/MaastrichtU-IDS/d2s-core/master/argo/roles/kube-dashboard-adminuser-sa.yml
kubectl apply -f https://raw.githubusercontent.com/MaastrichtU-IDS/d2s-core/master/argo/roles/kube-adminuser-rolebinding.yml

# Get the Token to access the dashboard
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep admin-user | awk '{print $1}')


# Windows user will need to execute the 2 commands manually:
kubectl -n kube-system get secret
# And get the token containing 'admin-user'
kubectl -n kube-system describe secret
# For Windows: give the anonymous user global access
kubectl create clusterrolebinding cluster-system-anonymous --clusterrole=admin --user=system:anonymous
# Note: this could be improved. I think only the Dashboard UI didn't have the required permissions.

# Finally, start the web UI, and chose the Token connection
kubectl proxy

Then visit: http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

And provide the previously obtained token.

Warning: you will need to save the token to login again next time (use the password save from your browser if possible).

Run kubectl

kubectl should be running at start.

Just restart the web UI

kubectl proxy

Then visit: http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/

Enable internet

Debug DNS on Ubuntu

microk8s.enable dns

Restart your machine.

You might need to change your firewall configuration

  • On Ubuntu
sudo ufw allow in on cni0
sudo ufw allow out on cni0
sudo ufw default allow routed
kubectl exec -ti busybox -- /bin/sh
ping google.com

Create persistent volume

# Create volume
kubectl apply -n argo -f d2s-core/argo/storage/storage-mac.yaml

Not working at the moment.

Uninstall

Clean uninstall before 2.2.

kubectl get cm workflow-controller-configmap -o yaml -n kube-system --export | kubectl apply -n argo -f -
kubectl delete -n kube-system cm workflow-controller-configmap
kubectl delete -n kube-system deploy workflow-controller argo-ui
kubectl delete -n kube-system sa argo argo-ui
kubectl delete -n kube-system svc argo-ui

Install Argo workflows

Argo project

Install on your local Kubernetes

Argo workflows will be installed on the argo namespace. See the official Argo documentation for more details.

kubectl create ns argo
kubectl apply -n argo -f https://raw.githubusercontent.com/argoproj/argo/v2.4.2/manifests/install.yaml

# Configure service account to run workflow
kubectl create rolebinding default-admin --clusterrole=admin --serviceaccount=default:default

# Test run
argo submit --watch https://raw.githubusercontent.com/argoproj/argo/master/examples/hello-world.yaml

See custom configuration for namespace install.

kubectl apply -n argo -f https://raw.githubusercontent.com/vemonet/argo/master/manifests/namespace-install.yaml

Install the client

See the Argo workflows documentation.

Expose the UI

kubectl -n argo port-forward deployment/argo-ui 8002:8001

Access on http://localhost:8002.