Skip to content

Instantly share code, notes, and snippets.

@felipecruz91
Last active January 25, 2020 09:10
Show Gist options
  • Save felipecruz91/f5784b681f3a53f94beac2353a76dc92 to your computer and use it in GitHub Desktop.
Save felipecruz91/f5784b681f3a53f94beac2353a76dc92 to your computer and use it in GitHub Desktop.
kubernetes-installation

kubernetes installation using Microk8s

Install

$ sudo snap install microk8s --classic --channel=1.14/stable

Add your user to the 'microk8s' group:

$ sudo usermod -a -G microk8s your-user

Note: The new group will be available on the user's next login.

Accessing Kubernetes: MicroK8s embeds a kubectl and a .kubeconfig file required for accessing the installed MicroK8s. This avoids colliding with any local versions that might be already installed. Check the version installed:

$ microk8s.kubectl version --short

Client Version: v1.14.10
Server Version: v1.14.10

If you would like to use the MicroK8s kubectl and .kubeconfig file locally, you can do the following:

$ sudo snap alias microk8s.kubectl kubectl
$ sudo kubectl config view --raw > $HOME/.kube/config
$ sudo iptables -P FORWARD ACCEPT
$ sudo apt-get install iptables-persistent

Enable the following addons:

$ sudo microk8s.enable dns storage registry 

Reboot your machine:

$ sudo reboot

Verify installation

Build your image locally and push it to your local registry

$ docker build . -t localhost:32000/webapp:0.1
$ docker push localhost:32000/webapp:0.1
$ kubectl run webapp --image=localhost:32000/webapp:0.1 --port=8080 --restart=Never

or let's deploy a pod that prints out the "hi there" message by using an image from a public registry:

$ kubectl run busybox --image=busybox --restart=Never /bin/echo "hi there"

$ kubectl logs busybox
hi there

$ kubectl delete pod busybox

References

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment