{"id":8691,"date":"2021-01-30T21:07:10","date_gmt":"2021-01-30T21:07:10","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=8691"},"modified":"2023-05-25T10:02:36","modified_gmt":"2023-05-25T10:02:36","slug":"installing-kubernetes-on-ubuntu","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/installing-kubernetes-on-ubuntu\/","title":{"rendered":"Installing Kubernetes on Ubuntu"},"content":{"rendered":"<p>In this post I&#8217;m just going to list the steps for installing Kubernetes (k8s) on Ubuntu server using the single node, lightweight MicroK8s.<\/p>\n<ul>\n<li>\nIf you don&#8217;t have it installed, install snap<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nsudo apt install snapd\r\n<\/pre>\n<\/li>\n<\/ul>\n<p>Now let&#8217;s go through the steps to get microk8s installed<\/p>\n<ul>\n<li>\nInstall microk8s<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nsudo snap install microk8s --classic\r\n<\/pre>\n<li>\nYou may wish to change permissions to save using sudo everytime, if so run the following and change {username} to your user name.<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nsudo usermod -a -G microk8s {username}\r\nsudo chown -f -R {username} ~\/.kube\r\n<\/pre>\n<\/li>\n<li>Verify the installation\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nsudo microk8s.status\r\n<\/pre>\n<\/li>\n<li>To save us typing microk8s to run k8s command let&#8217;s alias it\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nsudo snap alias microk8s.kubectl kubectl\r\n<\/pre>\n<\/li>\n<\/ul>\n<p><strong>Accessing the Dashboard<\/strong><\/p>\n<p>Whilst you can now run kubectl command, the Web based <a href=\"https:\/\/github.com\/kubernetes\/dashboard\" rel=\"noopener\" target=\"_blank\">dashboard<\/a> is really useful &#8211; so lets deploy it using<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nkubectl apply -f https:\/\/raw.githubusercontent.com\/kubernetes\/dashboard\/v2.1.0\/aio\/deploy\/recommended.yaml\r\n<\/pre>\n<p>By default the Dashboard can only be accessed from the local machine and from a security standpoint you may even prefer not to be running a dashboard, but if you decide you want it (for example for dev work) then&#8230;<\/p>\n<p><em>As per <a href=\"https:\/\/github.com\/kubernetes\/dashboard\/blob\/master\/docs\/user\/accessing-dashboard\/README.md\" rel=\"noopener\" target=\"_blank\">Accessing Dashboard<\/a><\/em><\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nkubectl -n kubernetes-dashboard edit service kubernetes-dashboard\r\n<\/pre>\n<p>Change type: ClusterIP to type: NodePort and save this file.<\/p>\n<p>You&#8217;ll need to run the proxy<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nkubectl proxy&amp;\r\n<\/pre>\n<p>Now to get the port for the dashboard, run the following<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nkubectl -n kubernetes-dashboard get service kubernetes-dashboard\r\n<\/pre>\n<p>Example output (take from <a href=\"https:\/\/github.com\/kubernetes\/dashboard\/blob\/master\/docs\/user\/accessing-dashboard\/README.md\" rel=\"noopener\" target=\"_blank\">Accessing Dashboard<\/a>)<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nNAME                   TYPE       CLUSTER-IP       EXTERNAL-IP   PORT(S)        AGE\r\nkubernetes-dashboard   NodePort   10.100.124.90   &lt;nodes&gt;       443:31707\/TCP   21h\r\n<\/pre>\n<p>You can now access the dashboard remotely now on the port 31707 (see the PORT(S) listed above), for example https:\/\/{master-ip}:31707 where {master-ip} is the server&#8217;s ip address.<\/p>\n<p>To get the token for the dashboard we need to set up and few things<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nkubectl describe secret -n kube-system | grep deployment -A 12\r\n<\/pre>\n<p>Then copy the whole token to the Dashboard Token edit box and login.<\/p>\n<p>To enable skipping of the requirement for a token etc. on the dashboard (should only be used on a development installation) run<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\nkubectl edit deployment kubernetes-dashboard -n kubernetes-dashboard\r\n<\/pre>\n<p>then add the following line<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\n- args:\r\n   - --auto-generate-certificates\r\n   - --namespace=kubernetes-dashboard\r\n   - --enable-skip-login  # this argument allows us to skip login\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In this post I&#8217;m just going to list the steps for installing Kubernetes (k8s) on Ubuntu server using the single node, lightweight MicroK8s. If you don&#8217;t have it installed, install snap sudo apt install snapd Now let&#8217;s go through the steps to get microk8s installed Install microk8s sudo snap install microk8s &#8211;classic You may wish [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[314,312],"tags":[],"class_list":["post-8691","post","type-post","status-publish","format-standard","hentry","category-kubernetes","category-ubuntu-2"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=8691"}],"version-history":[{"count":5,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8691\/revisions"}],"predecessor-version":[{"id":9984,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/8691\/revisions\/9984"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=8691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=8691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=8691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}