Skip to content

Install and setup a local, one-node kubernetes environment for development and test purposes with Microk8s and Ansible on ubuntu.

License

Notifications You must be signed in to change notification settings

OlGe404/microk8s

Repository files navigation

Microk8s

This repo can be used to setup a local kubernetes installation based on microk8s. Checkout https://microk8s.io/ for more.

Prerequisites

For general prerequisites of microk8s, see https://microk8s.io/docs/getting-started.

Run ./prerequisites.sh to install the prerequisites for this repo.

Install

After you've installed the prerequisites, run:

  • ansible-playbook install.yaml
  • Refresh your shell with su - $(whoami)
  • Ensure the client and aliases work with mkctl get pods --all-namespaces

Note: If passwordless sudo is disabled, force ansible to ask for the sudo password by appending -K to the ansible-playbook install.yaml command.

Kubernetes-Dashboard

The kubernetes-dashboard will be installed in microk8s using the official helm chart. We don't use the dashboard add-on to be able to access the dashboard without using a port-forward/proxy command. The dashboard will be available at http://localhost:30001 after installation.

You can retrieve the login token for the dashboard with microk8s kubectl get secret kubernetes-dashboard-admin-token -n kubernetes-dashboard -o jsonpath={'.data.token'} | base64 -d | awk '{print $1}'.

Work with microk8s

Microk8s will be up and running when the installation was done, but it won't be added to your systems autostart. To start microk8s, run microk8s start && microk8s status --wait-ready. It can take some time for all services to be up and running, even after the command returns.

To stop microk8s, run microk8s stop. See microk8s help for a list of all available subcommands.

The kubeconfig file to interact with microk8s will be created at /.kube/microk8s and an alias will be created automatically to set export KUBECONFIG=/.kube/microk8s on shell login. If you don't want that, append -e microk8s_manage_kubeconfig=false to the ansible-playbook install.yaml command.

Microk8s is bundled with the kubectl cli. If you don't have kubectl installed, or you only want to use it in the microk8s context, append -e microk8s_manage_kubectl=true to create the kubectl='microk8s kubectl' alias.

Aliases

The playbook creates aliases to ease the usage of microk8s and microk8s kubectl commands. It also exports the KUBECONFIG ENV so you can work with other clients like oc/kubectl/helm as usual in the microk8s context.

The following aliases are created:

Alias Command Notes
mk8s microk8s For commands controlling microk8s itself, e.g. mk8s start or mk8s stop
mkctl microk8s kubectl To run kubectl commands with the included binary, e.g. mkctl get services
mkns microk8s kubectl config set-context microk8s --namespace <ns> To set a namespace for subsequent microk8s kubectl commands, e.g. mkns kube-system
mktoken microk8s kubectl get secret kubernetes-dashboard-admin-token -n kubernetes-dashboard -o jsonpath={'.data.token'} | base64 -d | awk '{print $1}' Get the login token for the kubernetes-dashboard

Deinstall

To deinstall microk8s, run ansible-playbook deinstall.yaml. If passwordless sudo is disabled, run ansible-playbook deinstall.yaml -K instead.

About

Install and setup a local, one-node kubernetes environment for development and test purposes with Microk8s and Ansible on ubuntu.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages