<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Alex Dudko</title>
    <description>The latest articles on DEV Community by Alex Dudko (@adudko).</description>
    <link>https://dev.to/adudko</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F303022%2Fdbd99721-0f57-40af-8407-b188c29f4b28.png</url>
      <title>DEV Community: Alex Dudko</title>
      <link>https://dev.to/adudko</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/adudko"/>
    <language>en</language>
    <item>
      <title>Setting up a single master Kubernetes cluster on Azure using kubeadm</title>
      <dc:creator>Alex Dudko</dc:creator>
      <pubDate>Thu, 02 Jan 2020 01:12:48 +0000</pubDate>
      <link>https://dev.to/adudko/setting-up-a-single-master-kubernetes-cluster-on-azure-using-kubeadm-1cjn</link>
      <guid>https://dev.to/adudko/setting-up-a-single-master-kubernetes-cluster-on-azure-using-kubeadm-1cjn</guid>
      <description>&lt;h2&gt;
  
  
  Overview
&lt;/h2&gt;

&lt;p&gt;By the end of this guide, you will have a Kubernetes cluster on Azure with one master and one worker node. You will know how to add more worker nodes to the cluster.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prerequisites
&lt;/h2&gt;

&lt;p&gt;Before you begin, you'll need to have the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;an active &lt;a href="https://azure.microsoft.com/en-us/free/"&gt;Azure account&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;a MacOS or Linux computer.&lt;/li&gt;
&lt;li&gt;the &lt;a href="https://docs.microsoft.com/en-us/cli/azure/install-azure-cli?view=azure-cli-latest"&gt;Azure CLI&lt;/a&gt; installed on your machine.&lt;/li&gt;
&lt;li&gt;an &lt;a href="https://docs.microsoft.com/en-us/azure/virtual-machines/linux/mac-create-ssh-keys"&gt;SSH key pair&lt;/a&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Procedure
&lt;/h2&gt;

&lt;p&gt;You will start from creating a base &lt;a href="https://docs.microsoft.com/en-us/azure/virtual-machines/linux/capture-image"&gt;image of a virtual machine&lt;/a&gt; that will contain &lt;a href="https://kubernetes.io/docs/reference/setup-tools/kubeadm/kubeadm/"&gt;kubeadm&lt;/a&gt;, &lt;a href="https://github.com/containerd/containerd"&gt;containerd&lt;/a&gt;, kubelet and kubectl.&lt;/p&gt;

&lt;p&gt;The image will be used to create 2 virtual machines (one for Kubernetes master node and one for Kubernetes worker node).&lt;/p&gt;

&lt;p&gt;After that, you will use kubeadm to &lt;a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/"&gt;create a single control-plane Kubernetes cluster&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a virtual machine
&lt;/h3&gt;

&lt;p&gt;You need to log in to Azure and create a new resource group that will be used through the rest of this guide.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;az login
az group create &lt;span class="nt"&gt;--name&lt;/span&gt; KubernetesTestCluster &lt;span class="nt"&gt;--location&lt;/span&gt; eastus
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The next command creates a &lt;a href="https://docs.microsoft.com/en-us/azure/virtual-machines/windows/sizes-general"&gt;Standard_B2s&lt;/a&gt; virtual machine using the default UbuntuLTS image. You make check current pricing for this and other types of virtual machines at &lt;a href="https://azureprice.net/"&gt;https://azureprice.net/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Make sure you have created your SSH key pair (see Prerequisites) otherwise this command will fail to find &lt;code&gt;~/.ssh/id_rsa.pub&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;az vm create &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--resource-group&lt;/span&gt; KubernetesTestCluster &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--name&lt;/span&gt; base-vm &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--image&lt;/span&gt; UbuntuLTS &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--size&lt;/span&gt; Standard_B2s &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--admin-username&lt;/span&gt; azuser &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--tags&lt;/span&gt; &lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;base-vm &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--ssh-key-value&lt;/span&gt; ~/.ssh/id_rsa.pub
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The output of &lt;code&gt;az vm create&lt;/code&gt; contains &lt;code&gt;publicIpAddress&lt;/code&gt;.&lt;br&gt;
Use it to ssh to your new virtual machine and run &lt;code&gt;sudo&lt;/code&gt; to become &lt;code&gt;root&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh azuser@&amp;lt;publicIpAddress&amp;gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;su -
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Installing containerd to base-vm
&lt;/h3&gt;

&lt;p&gt;These instructions are based on Kubernetes documentation. If you have any questions, please read &lt;a href="https://kubernetes.io/docs/setup/production-environment/container-runtimes/"&gt;Container runtimes&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;In this guide, you will use &lt;code&gt;containerd&lt;/code&gt; as a Kubernetes container runtime.&lt;br&gt;
However there are several container runtimes listed in &lt;a href="https://kubernetes.io/docs/setup/production-environment/container-runtimes/"&gt;Container runtimes&lt;/a&gt;, and you can use any of them if you want.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /etc/modules-load.d/containerd.conf &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
overlay
br_netfilter
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;modprobe overlay br_netfilter

&lt;span class="c"&gt;# Setup required sysctl params, these persist across reboots.&lt;/span&gt;
&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /etc/sysctl.d/99-kubernetes-cri.conf &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
net.bridge.bridge-nf-call-iptables  = 1
net.ipv4.ip_forward                 = 1
net.bridge.bridge-nf-call-ip6tables = 1
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;sysctl &lt;span class="nt"&gt;--system&lt;/span&gt;

apt-get update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; apt-transport-https ca-certificates curl software-properties-common

curl &lt;span class="nt"&gt;-fsSL&lt;/span&gt; https://download.docker.com/linux/ubuntu/gpg | apt-key add -

add-apt-repository &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="s2"&gt;"deb [arch=amd64] https://download.docker.com/linux/ubuntu &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="s2"&gt;
    &lt;/span&gt;&lt;span class="si"&gt;$(&lt;/span&gt;lsb_release &lt;span class="nt"&gt;-cs&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;&lt;span class="s2"&gt; &lt;/span&gt;&lt;span class="se"&gt;\&lt;/span&gt;&lt;span class="s2"&gt;
    stable"&lt;/span&gt;

apt-get update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; containerd.io

&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; /etc/containerd &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; containerd config default &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /etc/containerd/config.toml

&lt;span class="c"&gt;# since UbuntuLTS uses systemd as the init system&lt;/span&gt;
&lt;span class="nb"&gt;sed&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; &lt;span class="s1"&gt;'s/systemd_cgroup = false/systemd_cgroup = true/'&lt;/span&gt; /etc/containerd/config.toml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Installing kubeadm to base-vm
&lt;/h3&gt;

&lt;p&gt;These instructions are based on Kubernetes documentation. If you have any questions, please read &lt;a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/install-kubeadm/"&gt;Installing kubeadm&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-s&lt;/span&gt; https://packages.cloud.google.com/apt/doc/apt-key.gpg | &lt;span class="nb"&gt;sudo &lt;/span&gt;apt-key add -

&lt;span class="nb"&gt;cat&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /etc/apt/sources.list.d/kubernetes.list &lt;span class="o"&gt;&amp;lt;&amp;lt;&lt;/span&gt;&lt;span class="no"&gt;EOF&lt;/span&gt;&lt;span class="sh"&gt;
deb https://apt.kubernetes.io/ kubernetes-xenial main
&lt;/span&gt;&lt;span class="no"&gt;EOF

&lt;/span&gt;apt-get update &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-get &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-y&lt;/span&gt; kubelet kubeadm kubectl &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; apt-mark hold kubelet kubeadm kubectl

&lt;span class="c"&gt;# since containerd is configured to use the systemd cgroup driver&lt;/span&gt;
&lt;span class="nb"&gt;echo&lt;/span&gt; &lt;span class="s1"&gt;'KUBELET_EXTRA_ARGS=--cgroup-driver=systemd'&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; /etc/default/kubelet
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Make sure that swap is disabled in &lt;code&gt;/etc/fstab&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Creating a base VM image from base-vm
&lt;/h3&gt;

&lt;p&gt;The following set of commands creates a custom image of the virtual machine you have just configured. Please read &lt;a href="https://docs.microsoft.com/en-us/azure/virtual-machines/linux/tutorial-custom-images"&gt;Tutorial: Create a custom image of an Azure VM with the Azure CLI&lt;/a&gt; if you want to know what each of the commands does.&lt;/p&gt;

&lt;p&gt;Deprovision the virtual machine, exit from the &lt;code&gt;root&lt;/code&gt; environment and close the SSH session.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;waagent &lt;span class="nt"&gt;-deprovision&lt;/span&gt;+user
&lt;span class="nb"&gt;exit
exit&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Execute the following commands in your local environment to create &lt;code&gt;base-vm-image&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;az vm deallocate &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--resource-group&lt;/span&gt; KubernetesTestCluster &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--name&lt;/span&gt; base-vm

az vm generalize &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--resource-group&lt;/span&gt; KubernetesTestCluster &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--name&lt;/span&gt; base-vm

az image create &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--resource-group&lt;/span&gt; KubernetesTestCluster &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--name&lt;/span&gt; base-vm-image &lt;span class="nt"&gt;--source&lt;/span&gt; base-vm
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Deleting unused resources
&lt;/h3&gt;

&lt;p&gt;Now when you have the image, you no longer need the virtual machine you used to create it. You should delete the virtual machine to avoid being charged for resources you don't need.&lt;/p&gt;

&lt;p&gt;Unfortunately at the moment of writing, deleting a virtual machine using CLI in Azure does not delete all dependent resources that were automatically created for the machine (for instance, disks and network interfaces).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/Azure/azure-cli/issues/4897"&gt;https://github.com/Azure/azure-cli/issues/4897&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/Azure/azure-cli/issues/8532"&gt;https://github.com/Azure/azure-cli/issues/8532&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Lucky for you, when you ran &lt;code&gt;az vm create&lt;/code&gt; to create this virtual machine you applied a tag to every resource it created via &lt;code&gt;--tags name=base-vm&lt;/code&gt;. Now you can use &lt;code&gt;az resource list --tag&lt;/code&gt; to find all dependent resources that need to be deleted.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;az vm delete &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--resource-group&lt;/span&gt; KubernetesTestCluster &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--name&lt;/span&gt; base-vm

az resource delete &lt;span class="nt"&gt;--ids&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;az resource list &lt;span class="nt"&gt;--tag&lt;/span&gt; &lt;span class="nv"&gt;name&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;base-vm &lt;span class="nt"&gt;--query&lt;/span&gt; &lt;span class="s2"&gt;"[].id"&lt;/span&gt; &lt;span class="nt"&gt;-otsv&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Initializing your control-plane node
&lt;/h3&gt;

&lt;p&gt;You need to create a new virtual machine for your control-plane node using the prepared &lt;code&gt;base-vm-image&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;az vm create &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--resource-group&lt;/span&gt; KubernetesTestCluster &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--name&lt;/span&gt; master1 &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--image&lt;/span&gt; base-vm-image &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--size&lt;/span&gt; Standard_B2s &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--admin-username&lt;/span&gt; azuser &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--ssh-key-value&lt;/span&gt; ~/.ssh/id_rsa.pub
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;publicIpAddress&lt;/code&gt; from the output of the command above to ssh to your new virtual machine and run &lt;code&gt;sudo&lt;/code&gt; to become &lt;code&gt;root&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh azuser@&amp;lt;publicIpAddress&amp;gt;
&lt;span class="nb"&gt;sudo &lt;/span&gt;su -
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Configure bash completion to make your life easier:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.kube
kubectl completion bash &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; ~/.kube/completion.bash.inc

&lt;span class="nb"&gt;printf&lt;/span&gt; &lt;span class="s2"&gt;"
# Kubectl shell completion
source '&lt;/span&gt;&lt;span class="nv"&gt;$HOME&lt;/span&gt;&lt;span class="s2"&gt;/.kube/completion.bash.inc'
"&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.bash_profile

&lt;span class="nb"&gt;source&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.bash_profile
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To initialize the control-plane node run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;kubeadm init &lt;span class="nt"&gt;--pod-network-cidr&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;10.244.0.0/16

&lt;span class="o"&gt;[&lt;/span&gt;init] Using Kubernetes version: v1.17.0
&lt;span class="o"&gt;[&lt;/span&gt;preflight] Running pre-flight checks
&lt;span class="o"&gt;[&lt;/span&gt;preflight] Pulling images required &lt;span class="k"&gt;for &lt;/span&gt;setting up a Kubernetes cluster
&lt;span class="o"&gt;[&lt;/span&gt;preflight] This might take a minute or two, depending on the speed of your internet connection
&lt;span class="o"&gt;[&lt;/span&gt;preflight] You can also perform this action &lt;span class="k"&gt;in &lt;/span&gt;beforehand using &lt;span class="s1"&gt;'kubeadm config images pull'&lt;/span&gt;
...

Your Kubernetes control-plane has initialized successfully!

To start using your cluster, you need to run the following as a regular user:

  &lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.kube
  &lt;span class="nb"&gt;sudo cp&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; /etc/kubernetes/admin.conf &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.kube/config
  &lt;span class="nb"&gt;sudo chown&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="nt"&gt;-u&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;:&lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;id&lt;/span&gt; &lt;span class="nt"&gt;-g&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.kube/config

You should now deploy a pod network to the cluster.
Run &lt;span class="s2"&gt;"kubectl apply -f [podnetwork].yaml"&lt;/span&gt; with one of the options listed at:
  https://kubernetes.io/docs/concepts/cluster-administration/addons/

Then you can &lt;span class="nb"&gt;join &lt;/span&gt;any number of worker nodes by running the following on each as root:

kubeadm &lt;span class="nb"&gt;join&lt;/span&gt; &amp;lt;control-plane-host&amp;gt;:&amp;lt;control-plane-port&amp;gt; &lt;span class="nt"&gt;--token&lt;/span&gt; &amp;lt;token&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
    &lt;span class="nt"&gt;--discovery-token-ca-cert-hash&lt;/span&gt; sha256:&amp;lt;&lt;span class="nb"&gt;hash&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;If you have any questions about &lt;code&gt;kubeadm init&lt;/code&gt;, please read &lt;a href="https://kubernetes.io/docs/setup/production-environment/tools/kubeadm/create-cluster-kubeadm/"&gt;Creating a single control-plane cluster with kubeadm&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Configure &lt;code&gt;kubectl&lt;/code&gt; and run &lt;code&gt;kubectl cluster-info&lt;/code&gt; to verify that Kubernetes master is running.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;mkdir&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.kube
&lt;span class="nb"&gt;cp&lt;/span&gt; &lt;span class="nt"&gt;-i&lt;/span&gt; /etc/kubernetes/admin.conf &lt;span class="nv"&gt;$HOME&lt;/span&gt;/.kube/config
kubectl cluster-info
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You should see:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Kubernetes master is running at https://10.0.0.4:6443
KubeDNS is running at https://10.0.0.4:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Install pod network addon:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl apply &lt;span class="nt"&gt;-f&lt;/span&gt; https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h3&gt;
  
  
  Adding a worker node to the cluster
&lt;/h3&gt;

&lt;p&gt;You need to create a new virtual machine for a worker node using the prepared &lt;code&gt;base-vm-image&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Open a new terminal windows and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;az vm create &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--resource-group&lt;/span&gt; KubernetesTestCluster &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--name&lt;/span&gt; worker1 &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--image&lt;/span&gt; base-vm-image &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--size&lt;/span&gt; Standard_B2s &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--admin-username&lt;/span&gt; azuser &lt;span class="se"&gt;\&lt;/span&gt;
   &lt;span class="nt"&gt;--ssh-key-value&lt;/span&gt; ~/.ssh/id_rsa.pub
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;publicIpAddress&lt;/code&gt; from the output of the command above to ssh to your new virtual machine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;ssh azuser@&amp;lt;publicIpAddress&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Run the &lt;code&gt;kubeadm join&lt;/code&gt; command that you saw in the output of &lt;code&gt;kubeadm init&lt;/code&gt; above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;sudo &lt;/span&gt;kubeadm &lt;span class="nb"&gt;join&lt;/span&gt; &amp;lt;control-plane-host&amp;gt;:&amp;lt;control-plane-port&amp;gt; &lt;span class="nt"&gt;--token&lt;/span&gt; &amp;lt;token&amp;gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;--discovery-token-ca-cert-hash&lt;/span&gt; sha256:&amp;lt;&lt;span class="nb"&gt;hash&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;By default, tokens expire after 24 hours. If you are joining a node to the cluster after the current token has expired, you can create a new token by running &lt;code&gt;kubeadm token create&lt;/code&gt; on the master node.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Smoke testing
&lt;/h3&gt;

&lt;p&gt;To verify that all nodes are &lt;code&gt;Ready&lt;/code&gt; and all pods are &lt;code&gt;Running&lt;/code&gt;, return to the terminal windows with the SSH session to the control-plane node (master1) and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;kubectl get nodes &lt;span class="nt"&gt;-o&lt;/span&gt; wide
kubectl get pods &lt;span class="nt"&gt;--all-namespaces&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; wide
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The output should be similar to this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get nodes &lt;span class="nt"&gt;-o&lt;/span&gt; wide
NAME      STATUS   ROLES    AGE     VERSION   INTERNAL-IP   EXTERNAL-IP   OS-IMAGE             KERNEL-VERSION     CONTAINER-RUNTIME
master1   Ready    master   23m     v1.17.0   10.0.0.4      &amp;lt;none&amp;gt;        Ubuntu 18.04.3 LTS   5.0.0-1027-azure   containerd://1.2.10
worker1   Ready    &amp;lt;none&amp;gt;   2m20s   v1.17.0   10.0.0.5      &amp;lt;none&amp;gt;        Ubuntu 18.04.3 LTS   5.0.0-1027-azure   containerd://1.2.10

&lt;span class="nv"&gt;$ &lt;/span&gt;kubectl get pods &lt;span class="nt"&gt;--all-namespaces&lt;/span&gt; &lt;span class="nt"&gt;-o&lt;/span&gt; wide
NAMESPACE     NAME                              READY   STATUS    RESTARTS   AGE    IP           NODE      NOMINATED NODE   READINESS GATES
kube-system   coredns-6955765f44-dj8kk          1/1     Running   0          23m    10.244.0.4   master1   &amp;lt;none&amp;gt;           &amp;lt;none&amp;gt;
kube-system   coredns-6955765f44-px77m          1/1     Running   0          23m    10.244.0.3   master1   &amp;lt;none&amp;gt;           &amp;lt;none&amp;gt;
kube-system   etcd-master1                      1/1     Running   0          23m    10.0.0.4     master1   &amp;lt;none&amp;gt;           &amp;lt;none&amp;gt;
kube-system   kube-apiserver-master1            1/1     Running   0          23m    10.0.0.4     master1   &amp;lt;none&amp;gt;           &amp;lt;none&amp;gt;
kube-system   kube-controller-manager-master1   1/1     Running   0          23m    10.0.0.4     master1   &amp;lt;none&amp;gt;           &amp;lt;none&amp;gt;
kube-system   kube-flannel-ds-amd64-mw84v       1/1     Running   0          14m    10.0.0.4     master1   &amp;lt;none&amp;gt;           &amp;lt;none&amp;gt;
kube-system   kube-flannel-ds-amd64-qrfn6       1/1     Running   0          3m3s   10.0.0.5     worker1   &amp;lt;none&amp;gt;           &amp;lt;none&amp;gt;
kube-system   kube-proxy-j7qns                  1/1     Running   0          3m3s   10.0.0.5     worker1   &amp;lt;none&amp;gt;           &amp;lt;none&amp;gt;
kube-system   kube-proxy-kdlgt                  1/1     Running   0          23m    10.0.0.4     master1   &amp;lt;none&amp;gt;           &amp;lt;none&amp;gt;
kube-system   kube-scheduler-master1            1/1     Running   0          23m    10.0.0.4     master1   &amp;lt;none&amp;gt;           &amp;lt;none&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Cleaning up
&lt;/h2&gt;

&lt;p&gt;When you no longer need your Kubernetes cluster, you should delete it to avoid being charged for the resource you don't use.&lt;/p&gt;

&lt;p&gt;The fastest way to delete all created resources is to delete the resource group you created at the very beginning of this guide.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;az group delete &lt;span class="nt"&gt;--name&lt;/span&gt; KubernetesTestCluster
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That's it. Happy hacking!&lt;/p&gt;

</description>
      <category>kubernetes</category>
      <category>azure</category>
      <category>kubeadm</category>
    </item>
  </channel>
</rss>
