Skip to content
This repository has been archived by the owner on Oct 14, 2021. It is now read-only.

Latest commit

 

History

History
104 lines (76 loc) · 2.54 KB

ContainerSolutions.md

File metadata and controls

104 lines (76 loc) · 2.54 KB

Containerised Solutions

Azure Container Registry

Create:

az acr create --name $ACR_NAME \
              --resource-group $RESOURCE_GROUP \
              --location $RESOURCE_GROUP_LOCATION \
              --sku Standard

Build an image using ACR:

az acr build --registry $ACR_NAME -t $IMAGE_NAME .

Access locally:

az acr login --name $ACR_NAME
docker pull $ACR_NAME.azurecr.io/$IMAGE_NAME:cj2

Azure Container Instance

Start:

ACR_LOGIN_SERVER=$(az acr show --name $ACR_NAME \
                               --resource-group $RESOURCE_GROUP \
                               --query "loginServer" \
                               --output tsv)

az container create --resource-group $RESOURCE_GROUP \
                    --name $IMAGE_NAME \
                    --image $ACR_LOGIN_SERVER/$IMAGE_NAME:$IMAGE_VERSION \
                    --cpu 1 --memory 1 \
                    --registry-login-server $ACR_LOGIN_SERVER \
                    --registry-username $(az keyvault secret show --vault-name $AKV_NAME -n $ACR_NAME-pull-usr --query value -o tsv) \
                    --registry-password $(az keyvault secret show --vault-name $AKV_NAME -n $ACR_NAME-pull-pwd --query value -o tsv) \
                    --dns-name-label $IMAGE_NAME-$RANDOM \
                    --query ipAddress.fqdn \
                    --ports 3000

Stop:

az container stop --name $IMAGE_NAME --resource-group $RESOURCE_GROUP

Azure Kubernetes Services (AKS)

Create:

az aks create --resource-group $RESOURCE_GROUP \
            --location $RESOURCE_GROUP_LOCATION \
            --name $AKS_NAME \
            --kubernetes-version 1.12.6 \
            --node-vm-size Standard_B2s \
            --node-count 2 \
            --generate-ssh-keys

Connect:

sudo az aks install-cli
az aks get-credentials --resource-group $RESOURCE_GROUP --name $AKS_NAME

Now use kubectl

Scaling

Docs: https://docs.microsoft.com/en-us/azure/aks/concepts-scale

Manually scale nodes:

az aks scale --resource-group myResourceGroup --name myAKSCluster --node-count 2

Enable the cluster auto-scaler:

az aks update \
    --resource-group myResourceGroup \
    --name myAKSCluster \
    --enable-cluster-autoscaler \
    --min-count 1 \
    --max-count 3

Update:

az aks update \
    --resource-group myResourceGroup \
    --name myAKSCluster \
    --update-cluster-autoscaler \
    --min-count 1 \
    --max-count 2