Differences

This shows you the differences between two versions of the page.

Link to this comparison view

installing_microk8s_on_ubuntu_18_bionic [2020/06/20 15:01] (current)
Douglas Quintiliano dos Santos created
Line 1: Line 1:
 +====== Installing Microk8s on Ubuntu 18.04 (Bionic) ======
  
 +As we are working with Ubuntu, let's install the snap to handle the microk8s installation
 +<sxh bash>
 +sudo apt-get update && apt-get install snap -y
 +</sxh>
 +
 +Now we need to install the microk8s
 +<sxh bash>
 +sudo snap install microk8s --classic
 +</sxh>
 +
 +After the installation we need to enable the non-root user be able to handle the microk8s
 +<sxh bash>
 +sudo usermod -a -G microk8s <username>
 +</sxh>
 +
 +Now let's create an alias to make it more easy to type
 +<sxh bash>
 +echo "alias kubectl='microk8s.kubectl'" >> ~/.bashrc
 +</sxh>
 +
 +**Now we need to log out and back in.**
 +
 +
 +Now after log in again let's check the status of the microk8s
 +<sxh bash>
 +microk8s.status --wait-ready
 +microk8s is running
 +addons:
 +dns: disabled
 +cilium: disabled
 +dashboard: disabled
 +fluentd: disabled
 +gpu: disabled
 +helm: disabled
 +helm3: disabled
 +ingress: disabled
 +istio: disabled
 +jaeger: disabled
 +knative: disabled
 +kubeflow: disabled
 +linkerd: disabled
 +metallb: disabled
 +metrics-server: disabled
 +prometheus: disabled
 +rbac: disabled
 +registry: disabled
 +storage: disabled
 +</sxh>
 +
 +Now let's enable the CoreDNS
 +<sxh bash>
 +microk8s.enable dns
 +</sxh>
 +
 +Now we need to store the microk8s configuration as follows
 +<sxh bash>
 +microk8s.kubectl config view --raw > $HOME/.kube/config
 +</sxh>
 +
 +Now we need to adjust the iptables configuration, let's enable the FORWARD as ACCEPT
 +<sxh bash>
 +sudo iptables -P FORWARD ACCEPT
 +</sxh>
 +
 +Now we need to install the iptables-persistent package that is need as dependency
 +<sxh bash>
 +sudo apt-get install iptables-persistent
 +</sxh>
 +
 +I will be using the Docker as Container Runtime, we need to configure it
 +<sxh bash>
 +vim /etc/docker/daemon.json
 +{
 +    "insecure-registries" : ["localhost:32000"]
 +}
 +</sxh>
 +
 +Now we need to restart the Docker Service
 +<sxh bash>
 +systemctl restart docker
 +</sxh>
 +
 +Now we are ok to get start :D
 +
 +===== Dashboard addon =====
 +
 +**Note**: By Default the Google Chrome will not enable your access to the interface, you can use the FireFox Browser though.
 +
 +The standard Kubernetes Dashboard is a convenient way to keep track of the activity and resource use of MicroK8s
 +<sxh bash>
 +microk8s enable dashboard
 +Applying manifest
 +serviceaccount/kubernetes-dashboard created
 +service/kubernetes-dashboard created
 +secret/kubernetes-dashboard-certs created
 +secret/kubernetes-dashboard-csrf created
 +secret/kubernetes-dashboard-key-holder created
 +configmap/kubernetes-dashboard-settings created
 +role.rbac.authorization.k8s.io/kubernetes-dashboard created
 +clusterrole.rbac.authorization.k8s.io/kubernetes-dashboard created
 +rolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
 +clusterrolebinding.rbac.authorization.k8s.io/kubernetes-dashboard created
 +deployment.apps/kubernetes-dashboard created
 +service/dashboard-metrics-scraper created
 +deployment.apps/dashboard-metrics-scraper created
 +service/monitoring-grafana created
 +service/monitoring-influxdb created
 +service/heapster created
 +deployment.apps/monitoring-influxdb-grafana-v4 created
 +serviceaccount/heapster created
 +clusterrolebinding.rbac.authorization.k8s.io/heapster created
 +configmap/heapster-config created
 +configmap/eventer-config created
 +deployment.apps/heapster-v1.5.2 created
 +
 +If RBAC is not enabled access the dashboard using the default token retrieved with:
 +
 +token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
 +microk8s kubectl -n kube-system describe secret $token
 +
 +In an RBAC enabled setup (microk8s enable RBAC) you need to create a user with restricted
 +permissions as shown in:
 +https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md
 +</sxh>
 +
 +Now we need to create the Token
 +<sxh bash>
 +token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1)
 +</sxh>
 +
 +Now we neeed to get the output to log in
 +<sxh bash>
 +microk8s kubectl -n kube-system describe secret $token
 +Name:         default-token-wczsp
 +Namespace:    kube-system
 +Labels:       <none>
 +Annotations:  kubernetes.io/service-account.name: default
 +              kubernetes.io/service-account.uid: 24ff2f4e-e0c1-4391-9974-2d48cea20106
 +
 +Type:  kubernetes.io/service-account-token
 +
 +Data
 +====
 +namespace:  11 bytes
 +token:      eyJhbGciOiJSUzI1NiIsImtpZCI6ImVmRUFTallpSFJpUlAtVWFKSGZsWjB1ODgwYlpyVkE1U0lHbVVQYnd4NTgifQ.eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJrdWJlLXN5c3RlbSIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZWZhdWx0LXRva2VuLXdjenNwIiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9zZXJ2aWNlLWFjY291bnQubmFtZSI6ImRlZmF1bHQiLCJrdWJlcm5ldGVzLmlvL3NlcnZpY2VhY2NvdW50L3NlcnZpY2UtYWNjb3VudC51aWQiOiIyNGZmMmY0ZS1lMGMxLTQzOTEtOTk3NC0yZDQ4Y2VhMjAxMDYiLCJzdWIiOiJzeXN0ZW06c2VydmljZWFjY291bnQ6a3ViZS1zeXN0ZW06ZGVmYXVsdCJ9.Nuk-nue84uxd16d7vms5DYMxjKtex31EfQ8UgV6mTIhWsxX_dUCFOS0TlrZXoT4aQQIy5GNt7uYQV6t_MKFLxlSw1961N0NP0yNLzbnL_QH2LoBWEEd9orrYOrlD5XBJMyICUkXKq_ISCNbd51sQjPrErY3KxD6ncATQxD1R9T1vH46VZrKcSjBgOGjD-Xnb9kG_0KBwxbuPCKayAsN8m8hr3K6uZNzKb1V89F2Dn1pw5AL8kRPuSG90esdSrnoQTWoCwicZ9PsoQhUVyxAW6PM3NJmW9AWQyo4fbsc7ksLG7x7QFeWjfyyp6jRo0KtD6gvQPe0PRrEcy2l61OmFHQ
 +ca.crt:     1103 bytes
 +</sxh>
 +
 +Next, you need to connect to the dashboard service. While the MicroK8s snap will have an IP address on your local network (the Cluster IP of the kubernetes-dashboard service), you can also reach the dashboard by forwarding its port to a free one on your host with:
 +
 +<sxh bash>
 +microk8s kubectl port-forward -n kube-system service/kubernetes-dashboard 10443:443
 +</sxh>
 +
 +You can then access the Dashboard at https://127.0.0.1:10443
 +
 + you are running MicroK8s in a VM and you need to expose the Dashboard to other hosts, you should also use the **--address [IP_address_that_your_browser's_host_has]** option. Set this option to **--address 0.0.0.0** to make the Dashboard public. For example:
 +
 +<sxh bash>
 +microk8s kubectl port-forward -n kube-system service/kubernetes-dashboard 10443:443 --address 0.0.0.0
 +Forwarding from 0.0.0.0:10443 -> 8443
 +</sxh>
 +
 +Now we can access https://hostip:10443 we will get the dashboard authentication and we need to put the token and click sign in
 +
 +{{::k8s-dashboard-token.png?600|}}
 +
 +After that we'll get the main dashboard page.
 +
 +{{::k8s-dashboard.png?600|}}
 +
 +Visit the [[https://github.com/kubernetes/dashboard/blob/master/docs/user/accessing-dashboard/1.7.x-and-above.md|upstream dashboard documentation]] to find out other ways to reach the
 +
 +====== References ======
 +  - https://microk8s.io/
 +  - https://snapcraft.io/docs/installing-snapd
 +  - https://microk8s.io/docs/troubleshooting
 +  - https://www.digitalocean.com/?refcode=ee97875d52fa&utm_campaign=Referral_Invite&utm_medium=Referral_Program&utm_source=CopyPaste
 +  - https://microk8s.io/docs/
 +  - https://microk8s.io/docs/addon-dashboard
 +  - https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/
Print/export
QR Code
QR Code installing_microk8s_on_ubuntu_18_bionic (generated for current page)