How to create a k8s cluster with kubeadm on Azure

Shawn.L
2 min readJan 6, 2019

--

  1. Build a resource group named ‘testk8s’ and create below resources under the resource group

a. Networking

Virtual Network: testk8s-vnet

Address space: 192.169.0.0/16

Subnet: ‘default’ 192.169.0.0/16

Network Security Group: testk8s-nsg

Routetable: testk8s-routetable

b. VM

Master: testk8s-m1

Availabilty Set: testk8s-m

Vnet: testk8s-vnet

subnet: default

Agent: testk8s-a1

Availability Set: testk8s-a

Vnet: testk8s-vnet

subnet: default

2. Login into the VM ‘testk8s-m1’ and follow below to install the kubeadm/kubectl/kubelet/docker

3. Modify below configuration file per requirement. Below is an example which has Pod CIDR as ‘10.244.0.0/16’

apiVersion: kubeadm.k8s.io/v1beta1
kind: InitConfiguration
nodeRegistration:
kubeletExtraArgs:
cloud-provider: "azure"
cloud-config: "/etc/kubernetes/cloud.conf"
---
apiVersion: kubeadm.k8s.io/v1beta1
kind: ClusterConfiguration
kubernetesVersion: v1.13.0
apiServer:
extraArgs:
cloud-provider: "azure"
cloud-config: "/etc/kubernetes/cloud.conf"
extraVolumes:
- name: cloud
hostPath: "/etc/kubernetes/cloud.conf"
mountPath: "/etc/kubernetes/cloud.conf"
controllerManager:
extraArgs:
cloud-provider: "azure"
cloud-config: "/etc/kubernetes/cloud.conf"
extraVolumes:
- name: cloud
hostPath: "/etc/kubernetes/cloud.conf"
mountPath: "/etc/kubernetes/cloud.conf"
networking:
serviceSubnet: "10.240.0.0/16"
podSubnet: "10.244.0.0/16"

4. Create an AD application

5. Modify the configuration file ‘/etc/kubernetes/cloud.conf’

{
"cloud":"AzurePublicCloud",
"tenantId": "xxx",
"subscriptionId": "xxx",
"aadClientId": "xxx",
"aadClientSecret": "xxx",
"resourceGroup": "k8s",
"location": "eastus",
"vmType": "standard",
"subnetName": "master",
"securityGroupName": "testslk8s",
"vnetName": "k8s-vnet",
"vnetResourceGroup": "",
"routeTableName": "testk8s-routetable",
"primaryAvailabilitySetName": "testk8s",
"primaryScaleSetName": "",
"cloudProviderBackoff": true,
"cloudProviderBackoffRetries": 6,
"cloudProviderBackoffExponent": 1.5,
"cloudProviderBackoffDuration": 5,
"cloudProviderBackoffJitter": 1,
"cloudProviderRatelimit": true,
"cloudProviderRateLimitQPS": 3,
"cloudProviderRateLimitBucket": 10,
"useManagedIdentityExtension": false,
"userAssignedIdentityID": "",
"useInstanceMetadata": true,
"loadBalancerSku": "Basic",
"excludeMasterFromStandardLB": false,
"providerVaultName": "",
"maximumLoadBalancerRuleCount": 250,
"providerKeyName": "k8s",
"providerKeyVersion": ""
}

6. Initialize the cluster

sudo kubeadm init -config kubeadm.conf

7. Install the network addon

8. Make sure the master node is ‘ready’ and all kube-system pods are running

kubectl get node,pod -n kube-system

9. login to the VM ‘testk8s-a1’

10. Follow the step2 to install docker/kubeadm/kubelet/kubectl

11. Use the command in the output of step6 to join the cluster or follow below

12. Execute below to verify. It’s expected to create two pods in the cluster and a loadbalancer and a public IP in Azure platform.

kubectl apply -f https://raw.githubusercontent.com/Azure-Samples/azure-voting-app-redis/master/azure-vote-all-in-one-redis.yaml

Sign up to discover human stories that deepen your understanding of the world.

--

--

Responses (6)

Write a response