Azure Container Service for Kubernetes is used to create, configure, and manage a cluster of virtual machines that are preconfigured to run containerized applications.
Before starting creating Azure Container Cluster (ACS) we need first to create Service Principal Client ID and password
We can either using Azure CLI for Windows or using Azure CLI from Azure portal
az account set --subscription "subscription-id" az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/mySubscriptionID"
Now create ssh-keys, (i used PuTTY)
Start PuTTY generator and save private Key (will be used for connecting to Kubernetes),leave PuTTY generator opened
From Azure portal click New-Containers-Azure Container Service
Specify name and resource group
Specify Kubernetes as Orchestrator
Set username, copy SSH public key from PuTTY Key Generator and ID and password from Azure CLI (generated in first step)
Connecting to Cluster
Again, i used PuTTY
Connection-SSH-Auth-browse for saved private keys
Specify DNS cluster name
Test connectivity to the ACS Kubernetes cluster,
kubectl get nodes
Deploy container to Azure Cluster
kubectl run nginx-test --image=nginx --replicas=1 --port=80
Check container is deployed:
kubectl get deployment
Make the container available from Internet
kubectl expose deployment nginx-test –port=80 –type=LoadBalancer
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes 10.0.0.1 443/TCP 25m nginx-test 10.0.30.9 80:30495/TCP 12s
Check the public IP address has been provisioned:
kubectl get services NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes 10.0.0.1 443/TCP 25m nginx-test 10.0.30.9 80:30495/TCP 12s
It takes some time to get Public IP, run get services until “pending” disappear
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes 10.0.0.1 443/TCP 21m nginx-test 10.0.30.9 13.81.216.198 80:30495/TCP 2m
Test connectivity
Scale out container
kubectl scale --replicas=2 deployment/nginx-test 2017-11-04 15:14:37.535906 I | proto: duplicate proto type registered: google.protobuf.Any 2017-11-04 15:14:37.535967 I | proto: duplicate proto type registered: google.protobuf.Duration 2017-11-04 15:14:37.535984 I | proto: duplicate proto type registered: google.protobuf.Timestamp deployment "nginx-test" scaled
Check another container instance is created:
kubectl get pods NAME READY STATUS RESTARTS AGE nginx-test-861205578-ghpd9 1/1 Running 0 49s nginx-test-861205578-lh32t 1/1 Running 0 4m
To remove deployments type
kubectl delete deployment nginx-test</pre>