Up and running with Kubernetes and Microk8s

Canonical have been doing some awesome work with Microk8s. This program makes it super simple to get up and running fast with Kubernetes.
Apr 14, 2020

Installing the Microk8s snap couldn’t be much easier. However there are a couple of extra steps and gotchas if you want to install this in a VM on the DigitalOcean.

snap install microk8s --classic

You can alias the kubectl and helm commands if you don’t want to keep running microk8s.kubectl.

snap alias microk8s.kubectl kubectl
snap alias microk8s.helm helm

Microk8s makes it simple to enable common add-ons the ones we are enabling

# Dashboard for a bit of a nice interface to see what's happening
microk8s.enable dashboard

# Ingress for managing domain names
microk8s.enable ingress

# Helm so we can install services from templates
microk8s.enable helm

When we want to get to our dashboard we can’t login over http, so we need proxy connections to our local workstation. For this we will need to install kubectl locally, luckily this is also available as a snap, so we can install that with a snap install kubectl.

To get the config for your local kubectl you can run another handy command microk8s.config this will print a config file to the terminal that you can copy the into ~/.kube/config then you can run kubectl locally.

Before you run the proxy command you can get your access token by running.

kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)

Now we have setup kubectl locally you can run kubectl proxy to access your cluster from localhost. The URL to your dashboard will be

More reads

Yii2 stream responses

Yii2 stream responses

In your Yii2 controller, it is quite common practice to return the stream of a file to the browser for your user to download. However, it’s not so well documented you can set any stream reference as the content of your response.