Deploy a webserver using Azure Kubernetes Service
We will be looking at setting up an Azure Kubernetes Cluster and then deploying an nginx web server on it.
To deploy an Azure Kubernetes Cluster, login to portal.azure.com with your credentials and search for kubernetes service.
Fill in the details as seen below:
You can leave the node pools section with the default parameters as seen below:
The Authentication section can also take the default parameters as seen below:
The dns name is automatically created for you as seen below:
The Log analytics workspace is also created by default:
You can decide to add tags if it helps to identify your resources then proceed to review all changes and ensuring the validation is passed as below and then proceed to click on the create button to create the kubernetes cluster:
Once the deployment is done, you will see a screen as below. Click on Connect to cluster to be able to connect to the cluster.
A cloud shell environment is provided by clicking on portal.azure.com/#cloudshell/. We will be connecting to the cluster using commands we run from the cloudshell.
Some of the sample commands are as seen below:
Run the following commands to connect to your cluster:
az account set -subscription xxxx-xxxx–xxxx-xxxx–xxxx
az aks get-credentials -resource-group azurekubernetes -name azurekubernetes
Next we deploy the webserver in the cluster by running the command below:
kubectl run webserver -generator=run-pod/v1 -image=nginx
Once you have deployed the pod, next you create a service to expose the pod so it can be accessible over the internet by running the command below:
kubectl expose pod webserver -type=LoadBalancer -name=podwebserver-service -port=80
To get the public IP of the pod, run the command:
kubectl get service
To confirm that you can access the pod from the internet, put in the public Ip on your local browser and you should be able to access the webserver as seen below:
You can also get the full view of the pod by describing it as below:
In summary, you can see how easy it is to deploy a webserver using Azure kubernetes service. So go on and try your hands on making use of the AKS environment and send me your feedback on “promiseuchenwachukwu@gmail.com” as I would love to hear from you.
https://kubernetes.io/docs/tutorials/stateless-application/expose-external-ip-address/