{"id":1526,"date":"2019-03-29T02:43:17","date_gmt":"2019-03-29T02:43:17","guid":{"rendered":"https:\/\/www.appservgrid.com\/paw93\/?p=1526"},"modified":"2019-04-06T01:35:19","modified_gmt":"2019-04-06T01:35:19","slug":"running-kubernetes-locally-on-linux-with-minikube-now-with-kubernetes-1-14-support","status":"publish","type":"post","link":"https:\/\/www.appservgrid.com\/paw93\/index.php\/2019\/03\/29\/running-kubernetes-locally-on-linux-with-minikube-now-with-kubernetes-1-14-support\/","title":{"rendered":"Running Kubernetes locally on Linux with Minikube &#8211; now with Kubernetes 1.14 support"},"content":{"rendered":"<ul>\n<li><center><br \/>\n<figure><img decoding=\"async\" src=\"https:\/\/d33wubrfki0l68.cloudfront.net\/4d279b610d2c8a3ca30eaf4a45964d6b455735cd\/dbb9d\/images\/blog\/2019-03-28-running-kubernetes-locally-on-linux-with-minikube\/ihor-dvoretskyi-1470985-unsplash.jpg\" width=\"600\" \/><\/figure>\n<p><\/center><em>A few days ago, the Kubernetes community announced\u00a0<a href=\"https:\/\/kubernetes.io\/blog\/2019\/03\/25\/kubernetes-1-14-release-announcement\/\" target=\"_blank\" rel=\"noopener\">Kubernetes 1.14<\/a>, the most recent version of Kubernetes. Alongside it, Minikube, a part of the Kubernetes project, recently hit the\u00a0<a href=\"https:\/\/github.com\/kubernetes\/minikube\/releases\/tag\/v1.0.0\" target=\"_blank\" rel=\"noopener\">1.0 milestone<\/a>, which supports\u00a0<a href=\"https:\/\/kubernetes.io\/blog\/2019\/03\/25\/kubernetes-1-14-release-announcement\/\" target=\"_blank\" rel=\"noopener\">Kubernetes 1.14<\/a>\u00a0by default.<\/em><\/p>\n<p>Kubernetes is a real winner (and a de facto standard) in the world of distributed Cloud Native computing. While it can handle up to\u00a0<a href=\"https:\/\/kubernetes.io\/blog\/2017\/03\/scalability-updates-in-kubernetes-1.6\" target=\"_blank\" rel=\"noopener\">5000 nodes<\/a>\u00a0in a single cluster, local deployment on a single machine (e.g. a laptop, a developer workstation, etc.) is an increasingly common scenario for using Kubernetes.<\/p>\n<p><center><\/p>\n<div class=\"SandboxRoot env-bp-350\" data-twitter-event-id=\"0\">\n<div id=\"twitter-widget-0\" class=\"EmbeddedTweet EmbeddedTweet--cta js-clickToOpenTarget tweet-InformationCircle-widgetParent\" lang=\"en\" data-click-to-open-target=\"https:\/\/twitter.com\/idvoretskyi\/status\/1093154369040773120\" data-iframe-title=\"Twitter Tweet\" data-scribe=\"page:tweet\" data-twitter-event-id=\"1\"><\/div>\n<div class=\"resize-sensor\">\n<div class=\"resize-sensor-shrink\">\n<div><\/div>\n<\/div>\n<\/div>\n<\/div>\n<p><\/center>This is post #1 in a series about the local deployment options on Linux, and it will cover Minikube, the most popular community-built solution for running Kubernetes on a local machine.<\/p>\n<p><a href=\"https:\/\/github.com\/kubernetes\/minikube\" target=\"_blank\" rel=\"noopener\">Minikube<\/a>\u00a0is a cross-platform, community-driven\u00a0<a href=\"https:\/\/kubernetes.io\/\" target=\"_blank\" rel=\"noopener\">Kubernetes<\/a>\u00a0distribution, which is targeted to be used primarily in local environments. It deploys a single-node cluster, which is an excellent option for having a simple Kubernetes cluster up and running on localhost.<\/p>\n<p>Minikube is designed to be used as a virtual machine (VM), and the default VM runtime is\u00a0<a href=\"https:\/\/www.virtualbox.org\/\" target=\"_blank\" rel=\"noopener\">VirtualBox<\/a>. At the same time, extensibility is one of the critical benefits of Minikube, so it\u2019s possible to use it with\u00a0<a href=\"https:\/\/github.com\/kubernetes\/minikube\/blob\/master\/docs\/drivers.md\" target=\"_blank\" rel=\"noopener\">drivers<\/a>\u00a0outside of VirtualBox.<\/p>\n<p>By default, Minikube uses Virtualbox as a runtime for running the virtual machine. Virtualbox is a cross-platform solution, which can be used on a variety of operating systems, including GNU\/Linux, Windows, and macOS.<\/p>\n<p>At the same time, QEMU\/KVM is a Linux-native virtualization solution, which may offer benefits compared to Virtualbox. For example, it\u2019s much easier to use KVM on a GNU\/Linux server, so you can run a single-node Minikube cluster not only on a Linux workstation or laptop with GUI, but also on a remote headless server.<\/p>\n<p>Unfortunately, Virtualbox and KVM can\u2019t be used simultaneously, so if you are already running KVM workloads on a machine and want to run Minikube there as well, using the KVM minikube driver is the preferred way to go.<\/p>\n<p>In this guide, we\u2019ll focus on running Minikube with the KVM driver on Ubuntu 18.04 (I am using a bare metal machine running on\u00a0<a href=\"https:\/\/www.packet.com\/\" target=\"_blank\" rel=\"noopener\">packet.com<\/a>.)<\/p>\n<p><center><\/p>\n<figure><img decoding=\"async\" src=\"https:\/\/d33wubrfki0l68.cloudfront.net\/dd7b0abd857c585b87fdd51b1a50103464c9e059\/ad9dc\/images\/blog\/2019-03-28-running-kubernetes-locally-on-linux-with-minikube\/module_01_cluster.png\" alt=\"Minikube architecture (source: kubernetes.io)\" width=\"600\" \/><figcaption>Minikube architecture (source: kubernetes.io)<\/p>\n<\/figcaption><\/figure>\n<p><\/center><\/p>\n<h2 id=\"disclaimer\"><strong>Disclaimer<\/strong><\/h2>\n<p>This is not an official guide to Minikube. You may find detailed information on running and using Minikube on it\u2019s official\u00a0<a href=\"https:\/\/github.com\/kubernetes\/minikube\" target=\"_blank\" rel=\"noopener\">webpage<\/a>, where different use cases, operating systems, environments, etc. are covered. Instead, the purpose of this guide is to provide clear and easy guidelines for running Minikube with KVM on Linux.<\/p>\n<h2 id=\"prerequisites\"><strong>Prerequisites<\/strong><\/h2>\n<ul>\n<li>Any Linux you like (in this tutorial we\u2019ll use Ubuntu 18.04 LTS, and all the instructions below are applicable to it. If you prefer using a different Linux distribution, please check out the relevant documentation)<\/li>\n<li><code>libvirt<\/code>\u00a0and QEMU-KVM installed and properly configured<\/li>\n<li>The Kubernetes CLI (<code>kubectl<\/code>) for operating the Kubernetes cluster<\/li>\n<\/ul>\n<h3 id=\"qemu-kvm-and-libvirt-installation\">QEMU\/KVM and libvirt installation<\/h3>\n<p><em>NOTE: skip if already installed<\/em><\/p>\n<p>Before we proceed, we have to verify if our host can run KVM-based virtual machines. This can be easily checked using the\u00a0<a href=\"https:\/\/manpages.ubuntu.com\/manpages\/bionic\/man1\/kvm-ok.1.html\" target=\"_blank\" rel=\"noopener\">kvm-ok<\/a>\u00a0tool, available on Ubuntu.<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-shell\" data-lang=\"shell\">sudo apt install cpu-checker &amp;&amp; sudo kvm-ok<\/code><\/pre>\n<\/div>\n<p>If you receive the following output after running\u00a0<code>kvm-ok<\/code>, you can use KVM on your machine (otherwise, please check out your configuration):<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-shell\" data-lang=\"shell\">$ sudo kvm-ok\r\nINFO: \/dev\/kvm exists\r\nKVM acceleration can be used<\/code><\/pre>\n<\/div>\n<p>Now let\u2019s install KVM and libvirt and add our current user to the\u00a0<code>libvirt<\/code>\u00a0group to grant sufficient permissions:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-shell\" data-lang=\"shell\">sudo apt install libvirt-clients libvirt-daemon-system qemu-kvm \\\r\n    &amp;&amp; sudo usermod -a -G libvirt $(whoami) \\\r\n    &amp;&amp; newgrp libvirt<\/code><\/pre>\n<\/div>\n<p>After installing libvirt, you may verify the host validity to run the virtual machines with\u00a0<code>virt-host-validate<\/code>\u00a0tool, which is a part of libvirt.<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-shell\" data-lang=\"shell\">sudo virt-host-validate<\/code><\/pre>\n<\/div>\n<h3 id=\"kubectl-kubernetes-cli-installation\"><strong>kubectl (Kubernetes CLI) installation<\/strong><\/h3>\n<p><em>NOTE: skip if already installed<\/em><\/p>\n<p>In order to manage the Kubernetes cluster, we need to install\u00a0<a href=\"https:\/\/kubernetes.io\/docs\/reference\/kubectl\/overview\/\" target=\"_blank\" rel=\"noopener\">kubectl<\/a>, the Kubernetes CLI tool.<\/p>\n<p>The recommended way to install it on Linux is to download the pre-built binary and move it to a directory under the\u00a0<code>$PATH<\/code>.<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-shell\" data-lang=\"shell\">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\n    &amp;&amp; sudo install kubectl \/usr\/local\/bin &amp;&amp; rm kubectl<\/code><\/pre>\n<\/div>\n<p>Alternatively, kubectl can be installed with a big variety of different methods (eg. as a .deb or snap package &#8211; check out the\u00a0<a href=\"https:\/\/kubernetes.io\/docs\/tasks\/tools\/install-kubectl\/\" target=\"_blank\" rel=\"noopener\">kubectl documentation<\/a>\u00a0to find the best one for you).<\/p>\n<h2 id=\"minikube-installation\"><strong>Minikube installation<\/strong><\/h2>\n<h3 id=\"minikube-kvm-driver-installation\">Minikube KVM driver installation<\/h3>\n<p>A VM driver is an essential requirement for local deployment of Minikube. As we\u2019ve chosen to use KVM as the Minikube driver in this tutorial, let\u2019s install the KVM driver with the following command:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-shell\" data-lang=\"shell\">curl -LO https:\/\/storage.googleapis.com\/minikube\/releases\/latest\/docker-machine-driver-kvm2 \\\r\n    &amp;&amp; sudo install docker-machine-driver-kvm2 \/usr\/local\/bin\/ &amp;&amp; rm docker-machine-driver-kvm2<\/code><\/pre>\n<\/div>\n<h3 id=\"minikube-installation-1\">Minikube installation<\/h3>\n<p>Now let\u2019s install Minikube itself:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-shell\" data-lang=\"shell\">curl -LO https:\/\/storage.googleapis.com\/minikube\/releases\/latest\/minikube-linux-amd64 \\\r\n    &amp;&amp; sudo install minikube-linux-amd64 \/usr\/local\/bin\/minikube &amp;&amp; rm minikube-linux-amd64<\/code><\/pre>\n<\/div>\n<h3 id=\"verify-the-minikube-installation\">Verify the Minikube installation<\/h3>\n<p>Before we proceed, we need to verify that Minikube is correctly installed. The simplest way to do this is to check Minikube\u2019s status.<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-shell\" data-lang=\"shell\">minikube version<\/code><\/pre>\n<\/div>\n<h3 id=\"to-use-the-kvm2-driver\">To use the KVM2 driver:<\/h3>\n<p>Now let\u2019s run the local Kubernetes cluster with Minikube and KVM:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-shell\" data-lang=\"shell\">minikube start --vm-driver kvm2<\/code><\/pre>\n<\/div>\n<h3 id=\"set-kvm2-as-a-default-vm-driver-for-minikube\">Set KVM2 as a default VM driver for Minikube<\/h3>\n<p>If KVM is used as the single driver for Minikube on our machine, it\u2019s more convenient to set it as a default driver and run Minikube with fewer command-line arguments. The following command sets the KVM driver as the default:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-shell\" data-lang=\"shell\">minikube config set vm-driver kvm2<\/code><\/pre>\n<\/div>\n<p>So now let\u2019s run Minikube as usual:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-shell\" data-lang=\"shell\">minikube start<\/code><\/pre>\n<\/div>\n<h2 id=\"verify-the-kubernetes-installation\"><strong>Verify the Kubernetes installation<\/strong><\/h2>\n<p>Let\u2019s check if the Kubernetes cluster is up and running:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-shell\" data-lang=\"shell\">kubectl get nodes<\/code><\/pre>\n<\/div>\n<p>Now let\u2019s run a simple sample app (nginx in our case):<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-shell\" data-lang=\"shell\">kubectl create deployment nginx --image=nginx<\/code><\/pre>\n<\/div>\n<p>Let\u2019s also check that the Kubernetes pods are correctly provisioned:<\/p>\n<div class=\"highlight\">\n<pre><code class=\"language-shell\" data-lang=\"shell\">kubectl get pods<\/code><\/pre>\n<\/div>\n<h2 id=\"screencast\"><strong>Screencast<\/strong><\/h2>\n<p><center><a href=\"https:\/\/asciinema.org\/a\/237106\" target=\"_blank\" rel=\"noopener\"><img decoding=\"async\" src=\"https:\/\/asciinema.org\/a\/237106.svg\" alt=\"asciicast\" \/><\/a><\/center><\/p>\n<h2 id=\"next-steps\"><strong>Next steps<\/strong><\/h2>\n<p>At this point, a Kubernetes cluster with Minikube and KVM is adequately set up and configured on your local machine.<\/p>\n<p>To proceed, you may check out the Kubernetes tutorials on the project website:<\/p>\n<ul>\n<li><a href=\"https:\/\/kubernetes.io\/docs\/tutorials\/hello-minikube\/\" target=\"_blank\" rel=\"noopener\">Hello Minikube<\/a><\/li>\n<\/ul>\n<p>It\u2019s also worth checking out the \u201cIntroduction to Kubernetes\u201d course by The Linux Foundation\/Cloud Native Computing Foundation, available for free on EDX:<\/p>\n<ul>\n<li><a href=\"https:\/\/www.edx.org\/course\/introduction-to-kubernetes#\" target=\"_blank\" rel=\"noopener\">Introduction to Kubernetes<\/a><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><a href=\"https:\/\/kubernetes.io\/blog\/2019\/03\/28\/running-kubernetes-locally-on-linux-with-minikube-now-with-kubernetes-1.14-support\/\" target=\"_blank\" rel=\"noopener\">Source<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A few days ago, the Kubernetes community announced\u00a0Kubernetes 1.14, the most recent version of Kubernetes. Alongside it, Minikube, a part of the Kubernetes project, recently hit the\u00a01.0 milestone, which supports\u00a0Kubernetes 1.14\u00a0by default. Kubernetes is a real winner (and a de facto standard) in the world of distributed Cloud Native computing. While it can handle up &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.appservgrid.com\/paw93\/index.php\/2019\/03\/29\/running-kubernetes-locally-on-linux-with-minikube-now-with-kubernetes-1-14-support\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Running Kubernetes locally on Linux with Minikube &#8211; now with Kubernetes 1.14 support&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-1526","post","type-post","status-publish","format-standard","hentry","category-kubernetes"],"_links":{"self":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/1526","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/comments?post=1526"}],"version-history":[{"count":2,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/1526\/revisions"}],"predecessor-version":[{"id":1594,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/posts\/1526\/revisions\/1594"}],"wp:attachment":[{"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/media?parent=1526"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/categories?post=1526"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.appservgrid.com\/paw93\/index.php\/wp-json\/wp\/v2\/tags?post=1526"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}