Search Sreeni's Insights

Filter by content type
cloud December 21, 2017 5 min read

How to Scale Sentry with Azure Container Instances?

This guide scales Sentry with Azure Container Instances through an ACI Connector for Kubernetes or AKS, comparing resource limits, cost, provisioning and operational control.

Share:

How to Scale Sentry with Azure Container Instances?

We can scale Sentry ACI containers in two ways:

Virtual Kubelet with AKS ClusterAKS Cluster instead of ACI
ApproachUse best both ACI and AKS world by using Virtual kubelet or ACI connectorUse AKS instead of ACI
Pros+ Fast provisioning and pay per second
+ Don’t need VM to run additional pods
+ Cost effective since we required pay only what we have used
+ Hypervisor isolation provides better security
+ No limitation of the CPU and memory resources
+ Provides better scalability and control.
Cons− Has resource limitations
• Supported only 4 CPU cores max per container
• Supported only 16 GB max per container
− We need to pay for underlying VM clusters regardless of what we using
− Add little management complexity.

Option1: Using Virtual Kubelet/ACI Connector to Kubernetes

The Azure Container Instances Connector for Kubernetes allows Kubernetes clusters to deploy Azure Container Instances and with help of Kubernetes services we can scale.

This enables on-demand and nearly instantaneous container compute, orchestrated by Kubernetes, without having VM infrastructure to manage and while still leveraging the portable Kubernetes API. This will allow us to use both VMs and container instances simultaneously in the same Kubernetes cluster, giving you the best of both worlds.

Kubernetes Control Panel with ACI Connector to Azure Container Instances (ACI)
Kubernetes Control Panel with ACI Connector to Azure Container Instances (ACI)

Steps to Implement:

Follow the following instructions to set up the ACI connector with Kubernetes and run the Sentry containers.

  • Install the Azure CLI when it not installed already. Refer to this link for more information.

  • Install the kubectl when it not installed already. Use the following command to install,

    az aks install-cli
  • Install the Helm CLI. Refer to this link for more information.

  • Create the Kubernetes yaml file for existing containers

  • Navigate to the yaml file folder.

  • Login to your Azure Account.

    az login
  • List out your existing subscriptions and set the current subscription, where you want to create Kubernetes services.

    az account list -o table
  • Take the desired subscription id from above command output and use it in the following command to set the current subscription.

    az account set --subscription <azure subscription id>
  • Create a new AKS cluster with the following command: Replace the input place holders with actual values

    az aks create --resource-group <Resource Group> --name <name of kubernetes cluster> --node-count 1 --generate-ssh-keys
  • Use the following command to connect to the newly created AKS instance from your local machine.

    az aks get-credentials --resource-group <Resource Group> --name <name of kubernetes cluster>
  • Create a service principal with RBAC enabled.

    az ad sp create-for-rbac --name <name of service principal> -o table
  • Save the values from the command output in environment variables:

    export AZURE_TENANT_ID=<Tenant>
    export AZURE_CLIENT_ID=<AppId>
    export AZURE_CLIENT_SECRET=<Password>
  • Grab the public master URI for your Kubernetes cluster and save the value.

    kubectl cluster-info
    export MASTER_URI=<Kubernetes Master>
  • Deploy the Virtual Kubelet to the newly created AKS cluster with the following command:

    export RELEASE_NAME=virtual-kubelet
    export VK_RELEASE=virtual-kubelet-latest
    export NODE_NAME=virtual-kubelet
    export CHART_URL=https://github.com/virtual-kubelet/azure-aci/raw/master/charts/$VK_RELEASE.tgz
    
    helm install --name "$RELEASE_NAME" "$CHART_URL" \
      --set provider=azure \
      --set providers.azure.targetAKS=true \
      --set providers.azure.masterUri=$MASTER_URI \
      --set nodeName=$NODE_NAME
  • Alternatively, you can use the following command to deploy the Virtual Kubelet.

    az aks install-connector --name <AKS instance name> --resource-group <Resource Group> --connector-name virtual-kubelet
  • Just to pulse check, type the following command and it will list out all nodes that currently active in the AKS instance. Here you can find a node starts with “virtual-kubelet”.

    kubectl get nodes
  • Open your Kubernetes yaml files and append the following configs snippets into all files.

    nodeSelector:
        kubernetes.io/role: agent
        beta.kubernetes.io/os: linux
        type: virtual-kubelet
      tolerations:
      - key: virtual-kubelet.io/provider
        operator: Exists
      - key: azure.com/aci
        effect: NoSchedule

    Note: By default, ACI protects virtual kubelet nodes to avoid unexpected pods running on them i.e kube-proxy and other Kubernetes management pods. When we want to run our pods into virtual kubelet, then we need to add the above snippets into our Kubernetes deployment yaml file.

  • Run the following command to deploy your container into virtual kubelet

    kubectl create -f <your kubernetes deployment>.yaml
  • Use the following command to output a list of pods with the scheduled node.

    kubectl get pods -o wide
  • Here, you can notice your pod is running on the virtual-kubelet node.

  • To validate that the container is running in an Azure Container Instance, use the az container list Azure CLI command.

    az container list -o table

Option2: Using AKS instead of ACI

We can use Azure Kubernetes Service(AKS) instead of ACI for better horizontal and vertical scalability.

Steps to Implement:

Follow the following instructions to set up the Azure Kubernetes Service(AKS) and run the Sentry containers.

  • Install the Azure CLI when it not installed already. Refer to this link for more information.

  • Install the kubectl when it not installed already. Use the following command to install,

    az aks install-cli
  • Install the Helm CLI. Refer to this link for more information.

  • Create the Kubernetes yaml file for existing containers

  • Navigate to the yaml file folder.

  • Login to your Azure Account.

    az login
  • List out your existing subscriptions and set the current subscription, where you want to create Kubernetes services.

    az account list -o table
  • Take the desired subscription id from above command output and use it in the following command to set the current subscription.

    az account set --subscription <azure subscription id>
  • Create a new AKS cluster with the following command: Replace the input place holders with actual values

    az aks create --resource-group <Resource Group> --name <name of kubernetes cluster> --node-count 1 --generate-ssh-keys
  • Use the following command to connect to the newly created AKS instance from your local machine.

    az aks get-credentials --resource-group <Resource Group> --name <name of kubernetes cluster>
  • Just to pulse check, type the following command and it will list out all nodes that currently active in the AKS instance.

    kubectl get nodes
  • Run the following command to deploy your container into virtual kubelet

    kubectl create -f <your kubernetes deployment>.yaml
  • Use the following command to output a list of pods with the scheduled node.

    kubectl get pods -o wide

Info: For a quick start, Kubernetes yaml files are fine, but for production, it is highly recommend using the helm chart for better management.

Related Posts