Azure Container Service for Kubernetes

Posted: November 4, 2017 in Azure

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

0.png

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

4.PNG

From Azure portal click New-Containers-Azure Container Service

1.png

Specify name and resource group

2.PNG

Specify Kubernetes as Orchestrator

3.png

Set username, copy SSH public key from PuTTY Key Generator and ID and password from Azure CLI (generated in first step)

6.PNG

5

Connecting to Cluster

Again, i used PuTTY

Connection-SSH-Auth-browse for saved private keys

9

Specify DNS cluster name

7.PNG

Test connectivity to the ACS Kubernetes cluster,

kubectl get nodes

10.PNG

Deploy container to Azure Cluster

kubectl run nginx-test --image=nginx --replicas=1 --port=80

Check container is deployed:

kubectl get deployment

11.PNG

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

12.PNG

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>
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s