Azure
Setup kubeadm K8s cluster on Azure provider.
Requirements
You should have defined (or created) the following resources:
Azure subscription;
Resource Group (for all resources like VMs, disks, etc);
VNET and a VNET Resource Group (if different from the VMs RG);
Network Security Group.
All steps bellow describe the process to create a single-master and single-node cluster.
Keep in mind you must replace all resources' names with your own definitions.
Select your Azure subscription
We will need to run some AZ CLI command, to do so, make sure you are using your correct subscription during the entire process.
You will see your subscription as "Default: true".
Create an Availability Set
It will be used to configure the Load Balancer later.
You can also create a Scalability Set if you are going to use auto scaling or Application Gateway endpoints.
Create a Public IP
This IP will be used in the Load Balancer to connect to the master node.
Using Azure Portal, create a Public IP with the following options.
Create Virtual Machines
First of all, you have to get the ID of the subnet where the VMs will be created.
Identify and get subnet ID. It will be something like:
Then, create your VMs.
Create one "master" and one "worker".
Install Docker
SSH to both your servers, master and worker.
Install docker dependencies.
Setup the repository.
Install Docker.
Check with docker version you should install to support you K8s version: https://kubernetes.io/docs/setup/production-environment/container-runtimes/#docker
Edit Docker service file.
Edit Docker service file.
Add the --exec-opt native.cgroupdriver=systemd
config at the end of the line "ExecStart":
Restart services:
Install kubeadm, kubectl and kubelet
SSH to your master node.
Follow the instructions here: https://app.gitbook.com/@devops-buzz/s/public/kubeadm/cheat-sheet#install-kubeadm-kubectl-and-kubelet
Then get the packages versions and copy them. They will be used to install the worker node with exactly the same versions: https://app.gitbook.com/@devops-buzz/s/public/kubeadm/cheat-sheet#get-kubeadm-dependencies-versions
SSH to your worker node, and install the same version: https://app.gitbook.com/@devops-buzz/s/public/~/drafts/-LhMcXSw47Ajn24zlx5O/primary/kubeadm/cheat-sheet#specific-version
Create an AD App registrations
Register an application
On Azure Portal, go to "Azure Active Directory", "App registrations".
Select "New registration". Fill up the form.
Add role assignment
Go to "All services", "Subscriptions" and select your subscription.
Go to "Access control (IAM), "Add", "Add role assignment".
Go to "Role" and "Assign access to". "Select" the application you created.
Go to "Azure Active Directory", "App registrations" and find your application.
Get the "Application (client) ID".
New client secret
Go to "Certificates & secrets", "New client secret".
Fill up the form.
Copy and save the secret value.
The secret value will be displayed just once. Copy and save it now!
Setup cluster
SSH to your master server.
Create config files
Create kubeadm config file.
With the following content.
Create cloud config file.
With the following content.
To get the "tenantId", run
az account show
and get "tenantId" field.To get the "subscriptionId", run
az account show
and get "id" field."aadClientId" is the "Application (client) ID" from Azure AD Application created above.
"aadClientSecret" is the Application secret created above.
Init cluster
The command above will return the "join" command, like:
Save this command in safe place. It will be used to add nodes to your cluster.
Get kubeconfig
SSH to your master node and run as root.
Deploy Weave CNI
SSH to your master node and run as root.
Azure does not support Calico.
Wait until the master node is "READY".
Add nodes
SSH to your node and run the "join" command you got above.
Label nodes (optional)
Setup Load Balancer
Create any service type "LoadBalancer". This will create create a Load Balancer on Azure called "kubernetes".
Create the manifest file.
With the following content.
Deploy the service.
Go to Azure portal, find the Load Balancer "kuberntes" in your Resource Group.
Wait a few minutes. You should have a "Backend pool" called "kubernets" with your node in it.
Add a "Frontend IP Configuration" and select the public IP you created above.
Create a "Backend pool" add your master server.
Create a "health probe" for you master server on port 6443.
Create a "Load Balancing Rule" using your Public IP on port 6443 to your master pool.
At this point you should be able to use your kubeconfig your public DNS.
Setup static IPs
Go to Azure portal, find your VMs, go to "Networking", lick on the NIC, go to "IP configurations", click on the IP, on "Assignment", set it to "Static".
Find the VMs Public IPs and double check if they are "Static".
Last updated