July 29, 2019

Setup k8s Cluster

k8s

Azure is one option to run a k8s cluster.

install the azure cli on a linux machine

This is the core of the 'official' Microsoft setup script taken from https://docs.microsoft.com/en-us/cli/azure/install-azure-cli-linux?view=azure-cli-latest instead of curling and piping a script to bash, we download and use the internal python script to set up everything, so you should have python installed…​

wget https://azurecliprod.blob.core.windows.net/install.py
chmod 777 install.py
install.py

…​the script will ask you where to put the directory and even add it"s bin folder to your $PATH, pretty impressive, nice job Microsoft!

create a k8s cluster in Azure

# login to azure
az login

# create the resource group 'apolloResourceGroup'
az group create --name apolloResourceGroup --location westeurope

# delete the resource group (this is for cleanup afterwards)
az group delete --name apolloResourceGroup

# create the cluster with 2 nodes (this might take some time)
az aks create \
    --resource-group apolloResourceGroup \
    --name apolloAKSCluster \
    --node-count 2 \
    --generate-ssh-keys
#    --enable-addons http_application_routing \
#    --enable-addons monitoring \

# connect kubectl to the cluster
az aks get-credentials --resource-group apolloResourceGroup --name apolloAKSCluster

the last command should give you a message like

 Merged "apolloAKSCluster" as current context in ~/.kube/config

and you are good to go and use kubectl with the created k8s cluster.

the following resources will be available in the Azure Overview

Availability set

Disk

Network interface

Network security group

Route table

Virtual machine

Virtual Network