Microsoft Azure

Creation of an Azure Kubernetes Services (AKS) cluster and deployment of an application

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.

Prerequisite:

  • 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

  1. DClick on All Services and digit aks, we will see the Kubernetes services service, click on that resource
  2. Click on Add and a window will appear where we will indicate the following values:
    • 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)
  3. Click on Next: Scale>
  4. In the next window we can activate virtual nodes to scale instantaneously to specific needs. Click on Enabled and click on Next: Authentication>
  5. In the next window leave the value of Service Principal and Enable RBAC by default, click on Next: Networking>
  6. 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 >
  7. In the next window disable monitoring that will not be focus for what we will see. Click on Review + create
  8. 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

  1. Once we have created our AKS, click on the Cloud Shell button that has the symbol of & gt; _ and then select Bash.
  2. We will bring the AKS credentials to be able to use it with the command:
  3. az aks get-credentials –resource-group rg-vvillar –name aks-vvillar
  4. To verify the connection, type the kubectl command that is already integrated with CloudShell, use the command:
  5. kubectl get nodes
  6. Type the command: nano
  7. Add the following script:
  8. 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
    
  9. Press Escape and then Control and X
  10. Type Y; name the file azure-vote.yaml and press enter
  11. Based on the .yaml file created, deploy the application using the following command:
  12. kubectl apply -f azure-vote.yaml
  13. To see the deployment process we can execute the command:
  14. kubectl get service azure-vote-front –watch
  15. 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.

Leave a Reply

avatar
  Subscribe  
Notify of