Hello, in this article we will see how to create an AKS cluster, an instance completely managed by Azure, that allows us to have orchestration and instances for microservices.
- A Microsoft Azure subscription.
Disclaimer: Given the constant updating of Cloud Computing technologies some steps may be different at the time of reading the article, I will make the effort to keep it updated, but there could be some differences between what is shown below and the Azure console at the moment of the implementation.
Creating the AKS resource
- DClick on All Services and digit aks, we will see the Kubernetes services service, click on that resource
- Click on Add and a window will appear where we will indicate the following values:
Click on Next: Scale>
- Subscription: <Your Azure Subscription>
- Resource group: Create New > rg-vvillar
- Kubernetes cluster name: aks-vvillar
- Region: (US) East US
- Kubernetes version: 1.12.7 (default)
- DNS name prefix: aks-vvillar-dns
- Node size: Standard DS2 v2 (the size remains the same and can not be changed after)
- Node count: 1 (the number of nodes if it can be modified after creation)
- In the next window we can activate virtual nodes to scale instantaneously to specific needs. Click on Enabled and click on Next: Authentication>
- In the next window leave the value of Service Principal and Enable RBAC by default, click on Next: Networking>
- In the part of networking leave the default values, these values will allow us to host the virtual machines that are the hosting instances of the containers and access them. Click on Next: Monitoring >
- In the next window disable monitoring that will not be focus for what we will see. Click on Review + create
- Check that Validation Passed is displayed on the top part of the windows and click on Create
Connecting to the cluster and deploying the application using Cloud Shell
- Once we have created our AKS, click on the Cloud Shell button that has the symbol of & gt; _ and then select Bash.
- We will bring the AKS credentials to be able to use it with the command: az aks get-credentials –resource-group rg-vvillar –name aks-vvillar
- To verify the connection, type the kubectl command that is already integrated with CloudShell, use the command: kubectl get nodes
- Type the command: nano
- Add the following script:
- Press Escape and then Control and X
- Type Y; name the file azure-vote.yaml and press enter
- Based on the .yaml file created, deploy the application using the following command: kubectl apply -f azure-vote.yaml
- To see the deployment process we can execute the command: kubectl get service azure-vote-front –watch
- If it is already possible to see the Public IP as in the image above we can enter the application. Go to a browser and access the website using the public IP.
apiVersion: apps/v1 kind: Deployment metadata: name: azure-vote-back spec: replicas: 1 selector: matchLabels: app: azure-vote-back template: metadata: labels: app: azure-vote-back spec: nodeSelector: "beta.kubernetes.io/os": linux containers: - name: azure-vote-back image: redis resources: requests: cpu: 100m memory: 128Mi limits: cpu: 250m memory: 256Mi ports: - containerPort: 6379 name: redis --- apiVersion: v1 kind: Service metadata: name: azure-vote-back spec: ports: - port: 6379 selector: app: azure-vote-back --- apiVersion: apps/v1 kind: Deployment metadata: name: azure-vote-front spec: replicas: 1 selector: matchLabels: app: azure-vote-front template: metadata: labels: app: azure-vote-front spec: nodeSelector: "beta.kubernetes.io/os": linux containers: - name: azure-vote-front image: microsoft/azure-vote-front:v1 resources: requests: cpu: 100m memory: 128Mi limits: cpu: 250m memory: 256Mi ports: - containerPort: 80 env: - name: REDIS value: "azure-vote-back" --- apiVersion: v1 kind: Service metadata: name: azure-vote-front spec: type: LoadBalancer ports: - port: 80 selector: app: azure-vote-front