Implement Azure Kubernetes Service

Implement Azure Kubernetes Service

Register the Microsoft.Kubernetes and Microsoft.KubernetesConfiguration resource providers.

Today we will register resource providers necessary to deploy an Azure Kubernetes Services cluster.

1. Sign in to the Azure portal.

2. In the Azure portal, open the Azure Cloud Shell by clicking on the icon in the top right of the Azure Portal.

3. If prompted to select either Bash or PowerShell, select PowerShell.

4. From the Cloud Shell pane, run the following to register the Microsoft.Kubernetes and Microsoft.KubernetesConfiguration resource providers.

Register-AzResourceProvider -ProviderNamespace Microsoft.Kubernetes
Register-AzResourceProvider -ProviderNamespace Microsoft.KubernetesConfiguration        
Article content

5. Close the Cloud Shell pane.

Deploy an Azure Kubernetes Service cluster

Now we will deploy an Azure Kubernetes Services cluster by using the Azure portal.

1. In the Azure portal, search for locate Kubernetes services and then, on the Kubernetes services blade, click + Create, and then click + Create a Kubernetes cluster.

Article content

2. On the Basics tab of the Create Kubernetes cluster blade, specify the following settings below. Leave others with their default values.

Article content
Article content

3. Click Next: Node Pools > and, on the Node Pools tab of the Create Kubernetes cluster blade, specify the following settings. Leave others with their default values.

Article content

4. Click Next: Access > and, on the Access tab of the Create Kubernetes cluster blade. Leave settings with their default values.

Article content

5. Click Next: Networking > and, on the Networking tab of the Create Kubernetes cluster blade, specify the following settings. Leave others with their default values.

Article content
Article content

6. Click Next: Integrations >, on the Integrations tab of the Create Kubernetes cluster blade, specify the following settings. Leave others with their default values.

Article content

7. Click Review + create, ensure that the validation passed and click Create.

Note: In production scenarios, you would want to enable monitoring. Monitoring is disabled in this case since it is not covered in the lab.
Note: Wait for the deployment to complete. This should take about 10 minutes.

Deploy pods into the Azure Kubernetes Service cluster

In this next step, we will deploy a pod into the Azure Kubernetes Service cluster.

1. On the deployment blade, click the Go to resource link.

2. On the az104-9c-aks1 Kubernetes service blade, in the Settings section, click Node pools.

Article content

3. On the az104-9c-aks1 - Node pools blade, verify that the cluster consists of a single pool with one node.

Article content

4. In the Azure portal, open the Azure Cloud Shell by clicking on the icon in the top right of the Azure Portal.

5. Switch the Azure Cloud Shell to Bash (black background).

6. From the Cloud Shell pane, run the following to retrieve the credentials to access the AKS cluster:

RESOURCE_GROUP='az104-09c-rg1'
AKS_CLUSTER='az104-9c-aks1'
az aks get-credentials --resource-group $RESOURCE_GROUP --name $AKS_CLUSTER        
Article content

7. From the Cloud Shell pane, run the following to verify connectivity to the AKS cluster:

kubectl get nodes        
Article content

8. In the Cloud Shell pane, review the output and verify that the one node which the cluster consists of at this point is reporting the Ready status.

9. From the Cloud Shell pane, run the following to deploy the nginx image from the Docker Hub:

kubectl create deployment nginx-deployment --image=nginx        
Article content
 Note: Make sure to use lower case letters when typing the name of the deployment (nginx-deployment)

10. From the Cloud Shell pane, run the following to verify that a Kubernetes pod has been created:

kubectl get pods        
Article content

11. From the Cloud Shell pane, run the following to identify the state of the deployment:

kubectl get deployment        
Article content

12. From the Cloud Shell pane, run the following to make the pod available from Internet:

kubectl expose deployment nginx-deployment --port=80 --type=LoadBalancer        
Article content

13. From the Cloud Shell pane, run the following to identify whether a public IP address has been provisioned:

kubectl get service        
Article content

14. Re-run the command until the value in the EXTERNAL-IP column for the nginx-deployment entry changes from <pending> to a public IP address. Note the public IP address in the EXTERNAL-IP column for nginx-deployment.

15. Open a browser window and navigate to the IP address you obtained in the previous step. Verify that the browser page displays the Welcome to nginx! message.

Scale containerized workloads in the Azure Kubernetes service cluster

The last step is to scale horizontally the number of pods, and then number of cluster nodes.

1. From the Cloud Shell pane, and run the following to scale the deployment by increasing of the number of pods to 2:

kubectl scale --replicas=2 deployment/nginx-deployment        
Article content

2. From the Cloud Shell pane, run the following to verify the outcome of scaling the deployment:

kubectl get pods        
Article content
Note: Review the output of the command and verify that the number of pods increased to 2.
Article content
Article content

3. From the Cloud Shell pane, run the following to scale out the cluster by increasing the number of nodes to 2:

RESOURCE_GROUP='az104-09c-rg1'
AKS_CLUSTER='az104-9c-aks1'
az aks scale --resource-group $RESOURCE_GROUP --name $AKS_CLUSTER --node-count 2        
Article content
Note: Wait for the provisioning of the additional node to complete. This might take about 3 minutes. If it fails, rerun the az aks scale command.

4. From the Cloud Shell pane, run the following to verify the outcome of scaling the cluster:

kubectl get nodes        


Article content
Note: Review the output of the command and verify that the number of nodes increased to 2.

5. From the Cloud Shell pane, run the following to scale the deployment:

kubectl scale --replicas=10 deployment/nginx-deployment        
Article content

6. From the Cloud Shell pane, run the following to verify the outcome of scaling the deployment:

kubectl get pods        
Article content
Note: Review the output of the command and verify that the number of pods increased to 10.

7. From the Cloud Shell pane, run the following to review the pods distribution across cluster nodes:

kubectl get pod -o=custom-columns=NODE:.spec.nodeName,POD:.metadata.name        
Article content
Note: Review the output of the command and verify that the pods are distributed across both nodes.

8. From the Cloud Shell pane, run the following to delete the deployment:

kubectl delete deployment nginx-deployment        
Article content

9. Close the Cloud Shell pane.

Everton Carvalho dos Santos

IT Consultant / Sr. Infrastructure Analyst / 12x Microsoft Certified / ITIL Foundation / Lean Navigator/ GSuite Certification

10mo

Thanks for sharing

Like
Reply

To view or add a comment, sign in

More articles by Marcelo Leite Gomes

  • Implement Data Protection

    Provision the lab environment For the last chapter, we will deploy two virtual machines that will be used to test…

    1 Comment
  • Implement Azure Container Instances

    Deploy a Docker image by using the Azure Container Instance In this task, you will create a new container instance for…

    1 Comment
  • Implement Web Apps

    Create an Azure web app In this task, we will create an Azure web app. 1.

    1 Comment
  • Manage Virtual Machines

    Deploy zone-resilient Azure virtual machines by using the Azure portal and an Azure Resource Manager template In this…

  • Manage Azure Storage

    Let’s manage some files? The idea is the following, you need to evaluate the use of Azure storage for storing files…

    1 Comment
  • Implement Traffic Management

    Azure Traffic Manager operates at the DNS layer to quickly and efficiently direct incoming DNS requests based on the…

  • Implement Intersite Connectivity

    Your company has offices in three different locations, and the data center of these offices are connected via mesh wide…

  • Implement Virtual Networking

    Create and configure a virtual network To create a virtual network with multiple subnets, follow the steps below. 1.

  • Manage Azure resources by Using Azure CLI

    Start a Bash session in Azure Cloud Shell 1. From the portal, open the Azure Cloud Shell by clicking on the icon in the…

  • Manage Azure resources by Using Azure PowerShell

    Create a Resource Group and an Azure managed disk by using Azure PowerShell To create a resource group in the same…

Insights from the community

Others also viewed

Explore topics