Azure Kubernetes Service - jasper-zanjani/azure GitHub Wiki

Notes

Kubernetes (Greek for "helmsman", "pilot", or "captain" and "k8s" for short) has emerged as the leading container orchestrator in the industry since 2018. It is a container management or orchestration system developed by Google after deciding to release an internal container management system named "Borg" to the public and donating it to the Cloud Native Computing Foundation.

History

Kubernetes was first announced by Google in mid-2014. It coalesced from a fusion between developers working on Google's Compute Engine and Google's Borg, a cluster manager that runs hundreds of thousands of jobs at Google, representing the infrastructure powering the entire Google enterprise.

By that time, Amazon had established a market advantage and the developers decided to change their approach by introducing a disruptive technology to drive the relevance of the Compute platform they had built. They created a ubiquitous abstraction that could run better than anyone else.

At the time, Google had been trying to engage the Linux kernel team and trying to overcome their skepticism. Internally, the project was framed as offering "Borg as a Service", although there were concerns that Google was in danger of revealing too much of its secret sauce.

Terminology

  • Pod: the most basic unit that K8s deals with, representing one or more tightly-coupled containers that should be controlled as a single application (typically one main container with subsidiary helper containers). Within a pod you can specify more than one container image. A pod's containers should:
    • operate closely together
    • share a lifecycle
    • always be scheduled on the same node
  • Worker: a container host, with a Kubelet process that communicates with K8s cluster services.
  • Desired State Management system, used by Kubernetes to describe a cluster's desired state declaratively.

Architecture

Kubernetes can be visualized as a system built from layers, with each higher layer abstracting the complexity of the lower levels.

One server serves as the master, exposing an API for users and clients, assigning or scheduling work, and orchestrating communication between other components.

  • A master node runs 3 processes: kube-apiserver, kube-controller-manager, and kube-scheduler
  • Master (control plane) components also run on the master node: kube-apiserver, kube-controller-manager, kube-scheduler, and Cluster Store

Other machines in the cluster are called nodes or workers and accept and run workloads using available resources.

  • Each node is equipped with a container runtime like Docker, which it uses to create and destroy containers according to instructions from the master server.
  • Each node runs 2 processes: kubelet and kube-proxy.

Storage

A volume represents a way to store, retrieve, and persist data across pods and through the application lifecycle. In the context of Azure, Kubernetes can use two types of data volume:

  • Azure Disks using Azure Premium (SSDs) or Azure Standard (HDDs).
  • Azure Files using a SMB 3.0 share backed by an Azure Storage account.

A PersistentVolumeClaim requests either Disk or File storage of a particular StorageClass, access mode, and size. It is bound to a PersistentVolume once an available storage resource has been assigned to the pod requesting it.

Tasks

Persistent volume claim

Sources:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: azure-managed-disk
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: managed-premium
  resources:
    requests:
      storage: 5Gi

Provision Azure Disk

Specifying Azure Standard, while retaining underlying Azure Disk.

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: managed-disk-forapp
provisioner: kubernetes.io/azure-disk
reclaimPolicy: Retain
parameters:
  storageaccounttype: default
  kind: Managed

Specifying Azure Premium, while retaining underlying Azure Disk.

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: managed-disk-forapp
provisioner: kubernetes.io/azure-disk
reclaimPolicy: Retain
parameters:
  storageaccounttype: Premium_LRS
  kind: Managed

Create cluster

PowerShell does not offer an option to generate SSH keys for access to the cluster; ssh-keygen must be used.

$Password = Read-Host -Prompt 'Please enter your password' -AsSecureString

New-AzAKS -ResourceGroupName $g -Name $n `
-KubernetesVersion 1.16.7 `
-NodeCount 2 `
-NetworkPlugin azure `
-NodeVmSetType VirtualMachineScaleSets `
-WindowsProfileAdminUserName azureuser `
-WindowsProfileAdminUserPassword $Password
PASSWORD="P@ssw0rd1234"

az aks create -g $g -n $n
--generate-ssh-keys \
--enable-addons monitoring \
--node-count 2 \
--network-plugin azure \
--vm-set-type VirtualMachineScaleSets \
--windows-admin-username azureuser \
--windows-admin-password $PASSWORD

Add node pool

New-AzAksNodePool -ResourceGroupName $g -Name npwin -ClusterName $c -OsType Windows -KubernetesVersion 1.16.7
az aks nodepool add -g $g -n $n --cluster-name $c \
  --os-type Windows \
  --node-count 1

Sources