{"id":3087,"date":"2022-09-19T21:38:42","date_gmt":"2022-09-20T01:38:42","guid":{"rendered":"https:\/\/dft.wiki\/?p=3087"},"modified":"2026-04-21T13:37:14","modified_gmt":"2026-04-21T17:37:14","slug":"running-k8s-kubernetes-locally-with-minikube-on-ubuntu-22-04","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=3087","title":{"rendered":"Running K8s (Kubernetes) Locally with Minikube on Ubuntu"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-4093 size-medium\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/09\/MiniKube-300x204.png\" alt=\"\" width=\"300\" height=\"204\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/09\/MiniKube-300x204.png 300w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/09\/MiniKube.png 567w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/p>\n<p>Minikube is a free open-source solution that creates a single node Kubernetes cluster [<a href=\"https:\/\/github.com\/kubernetes\/minikube\">Link<\/a>]. See also the official documentation at [<a href=\"https:\/\/minikube.sigs.k8s.io\/docs\/\">Link<\/a>].<\/p>\n<p>With a single combined Master+Worker node one can develop, test, or simulate a K8s infrastructure.<\/p>\n<pre>sudo apt update &amp;&amp; sudo apt upgrade -y\r\nsudo apt install nano htop wget curl apt-transport-https -y\r\n[ -f \/var\/run\/reboot-required ] &amp;&amp; sudo reboot -f<\/pre>\n<p>No matter if the Minikube is installed in a virtual or in a physical machine, it will need to virtualize the cluster using VirtualBox, KVM, or even Docker:<\/p>\n<p>Installing <strong>VirtualBox<\/strong> (if this is your preference)<\/p>\n<pre>sudo apt install virtualbox virtualbox-ext-pack -y<\/pre>\n<p>Installing <strong>KVM<\/strong> (if this is your preference)<\/p>\n<pre>sudo apt install qemu-kvm libvirt-dev bridge-utils libvirt-daemon-system libvirt-daemon virtinst bridge-utils libosinfo-bin libguestfs-tools virt-top -y\r\nsudo modprobe vhost_net\r\necho \"vhost_net\" | sudo tee -a \/etc\/modules<\/pre>\n<p>Installing <strong>Docker (recommended)<\/strong><\/p>\n<pre>sudo apt install docker.io -y<\/pre>\n<p>Remember to use the Docker driver and set as the default one. The running user must be part of the docker group:<\/p>\n<pre>minikube start --driver=docker\r\nminikube config set driver docker<\/pre>\n<hr \/>\n<p><strong>NESTED VIRTUALIZATION FOR PROXMOX<\/strong><\/p>\n<p>If you are running in <strong>Proxmox<\/strong>, certify your bare-metal hypervisor has enable nested support or the start of the Minikube will fail:<\/p>\n<pre>cat \/sys\/module\/kvm_intel\/parameters\/nested<\/pre>\n<p>If outputs <strong>Y<\/strong>, it is all good. If outputs <strong>N<\/strong> follow the next steps:<\/p>\n<pre>echo \"options kvm-intel nested=Y\" &gt; \/etc\/modprobe.d\/kvm-intel.conf\r\necho \"options kvm-amd nested=1\" &gt; \/etc\/modprobe.d\/kvm-amd.conf\r\nmodprobe -r kvm_intel\r\nmodprobe kvm_intel\r\ncat \/sys\/module\/kvm_intel\/parameters\/nested<\/pre>\n<p><strong>Note:<\/strong> replace <strong>kvm_intel<\/strong> with <strong>kvm_amd<\/strong> for for ADM hardware.<\/p>\n<p>Also configure the guest VM processors type to <strong>host<\/strong>:<\/p>\n<p><a href=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/09\/Screenshot-2022-09-19-194315.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3090 \" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/09\/Screenshot-2022-09-19-194315.jpg\" alt=\"\" width=\"512\" height=\"225\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/09\/Screenshot-2022-09-19-194315.jpg 873w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/09\/Screenshot-2022-09-19-194315-300x132.jpg 300w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2022\/09\/Screenshot-2022-09-19-194315-768x338.jpg 768w\" sizes=\"auto, (max-width: 512px) 100vw, 512px\" \/><\/a><\/p>\n<hr \/>\n<p><strong>INSTALLATION<\/strong><\/p>\n<p>Minikube<\/p>\n<pre>wget https:\/\/storage.googleapis.com\/minikube\/releases\/latest\/minikube-linux-amd64\r\nchmod +x minikube-linux-amd64\r\nsudo mv minikube-linux-amd64 \/usr\/local\/bin\/minikube\r\nminikube version\r\nminikube --help<\/pre>\n<p>Kubectl<\/p>\n<pre>curl -LO https:\/\/storage.googleapis.com\/kubernetes-release\/release\/`curl -s https:\/\/storage.googleapis.com\/kubernetes-release\/release\/stable.txt`\/bin\/linux\/amd64\/kubectl\r\nchmod +x kubectl\r\nsudo mv kubectl \/usr\/local\/bin\/kubectl\r\nkubectl version --short<\/pre>\n<hr \/>\n<p><strong>AUTO-START MINIKUBE ON BOOT<\/strong><\/p>\n<pre>sudo nano \/etc\/systemd\/system\/minikube.service<\/pre>\n<pre>[Unit]\r\nDescription=minikube\r\n\r\n[Service]\r\nType=oneshot\r\nRemainAfterExit=yes\r\nUser=<strong>USERNAME<\/strong>\r\nExecStart=\/usr\/local\/bin\/minikube start --driver=docker\r\nExecStop=\/usr\/local\/bin\/minikube stop\r\n\r\n[Install]\r\nWantedBy=multi-user.target<\/pre>\n<pre>sudo systemctl daemon-reload\r\nsudo systemctl enable minikube<\/pre>\n<hr \/>\n<p><strong>MINIKUBE CHEATSHEET<\/strong><\/p>\n<ul>\n<li>minikube <strong>start<\/strong>\n<ul>\n<li>Start or deploy a new cluster.<\/li>\n<\/ul>\n<\/li>\n<li>minikube <strong>stop<\/strong>\n<ul>\n<li>Stop the existent cluster.<\/li>\n<\/ul>\n<\/li>\n<li>minikube <strong>pause<\/strong>\n<ul>\n<li>Pause the cluster.<\/li>\n<\/ul>\n<\/li>\n<li>minikube <strong>unpause<\/strong>\n<ul>\n<li>Resume the cluster.<\/li>\n<\/ul>\n<\/li>\n<li>minikube <strong>status<\/strong>\n<ul>\n<li>Check the status of Minikube.<\/li>\n<\/ul>\n<\/li>\n<li>minikube <strong>delete<\/strong>\n<ul>\n<li>Destroy the existent cluster.<\/li>\n<\/ul>\n<\/li>\n<li>minikube <strong>ssh<\/strong>\n<ul>\n<li>Attach the current terminal to the cluster.<\/li>\n<\/ul>\n<\/li>\n<li>minikube <strong>logs<\/strong>\n<ul>\n<li>Watch the logs.<\/li>\n<\/ul>\n<\/li>\n<li>minikube <strong>addons<\/strong> <strong>list<\/strong>\n<ul>\n<li>Lists enabled and disabled addons.<\/li>\n<\/ul>\n<\/li>\n<li>minikube <strong>addons enable<\/strong> dashboard\n<ul>\n<li>Enables an addon.<\/li>\n<\/ul>\n<\/li>\n<li>minikube <strong>start &#8211;addons<\/strong> dashboard\n<ul>\n<li>Starts addons on system start up.<\/li>\n<\/ul>\n<\/li>\n<li>minikube <strong>dashboard &#8211;url<\/strong>\n<ul>\n<li>Gets the URL to the dashboard that can be accessed from local host on a random port (http:\/\/127.0.0.1:<strong>34005<\/strong>\/api\/v1\/namespaces\/kubernetes-dashboard\/services\/http:kubernetes-dashboard:\/proxy\/).<\/li>\n<\/ul>\n<\/li>\n<li>minikube addons enable <strong>ingress<\/strong>\n<ul>\n<li>Enables the out-of-the-box NGINX Ingress Crontoller.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p>Create the following resource to make the Dashboard always accessible through the address <strong>kubernetes.local<\/strong> (remember to add it to your hosts file):<\/p>\n<pre>apiVersion: networking.k8s.io\/v1\r\nkind: Ingress\r\nmetadata:\r\n  name: kubernetes-dashboard-ingress\r\n  namespace: kubernetes-dashboard\r\n  annotations:\r\n    nginx.ingress.kubernetes.io\/rewrite-target: \"\/\"\r\nspec:\r\n  ingressClassName: nginx\r\n  rules:\r\n  - host: kubernetes.local\r\n    http:\r\n      paths:\r\n      - path: \/\r\n        pathType: Prefix\r\n        backend:\r\n          service:\r\n            name: kubernetes-dashboard\r\n            port:\r\n              number: 80<\/pre>\n<hr \/>\n<p><strong>KUBECTL CHEATSHEET<\/strong><\/p>\n<p>Create the alias for easier usage:<\/p>\n<pre>alias k=\"minikube kubectl --\"<\/pre>\n<ul>\n<li>k <strong>cluster-info<\/strong><\/li>\n<li>k <strong>config view<\/strong><\/li>\n<li>k <strong>get nodes<\/strong><\/li>\n<li>k <strong>get pods<\/strong><\/li>\n<li>k <strong>get deployments<\/strong><\/li>\n<li>k <strong>get events<\/strong><\/li>\n<li>k <strong>proxy &#8211;address=&#8217;0.0.0.0&#8242;<\/strong> <strong>&#8211;disable-filter=true<\/strong>\n<ul>\n<li>Makes the dashboard accessible from outside the host on port 8001 (http:\/\/10.10.10.10:<strong>8001<\/strong>\/api\/v1\/namespaces\/kubernetes-dashboard\/services\/http:kubernetes-dashboard:\/proxy\/).<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<hr \/>\n<p><strong>OTHER POSTS<\/strong><\/p>\n<p><strong>K3s<\/strong> on Ubuntu [<a href=\"https:\/\/dft.wiki\/?p=3105\">Link<\/a>].<\/p>\n<p><strong>MicroK8s<\/strong> on Ubuntu [<a href=\"https:\/\/dft.wiki\/?p=3151\">Link<\/a>].<\/p>\n<p><strong>K8s<\/strong> Persistent Volumes [<a href=\"https:\/\/dft.wiki\/?p=1435\">Link<\/a>].<\/p>\n<p><strong>K8s<\/strong> Cheat Sheet [<a href=\"https:\/\/dft.wiki\/?p=1372\">Link<\/a>].<\/p>\n<p><strong>K8s<\/strong>\u00a0Dashboard [<a href=\"https:\/\/dft.wiki\/?p=4114\">Link<\/a>].<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Minikube is a free open-source solution that creates a single node Kubernetes cluster [Link]. See [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-3087","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/3087","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=3087"}],"version-history":[{"count":23,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/3087\/revisions"}],"predecessor-version":[{"id":5503,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/3087\/revisions\/5503"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=3087"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=3087"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=3087"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}