Sunday, May 14, 2017

Kubernetes basics : windows cluster in azure

Kubernetes:Container orchestration engine 


1.     Pods: Its a collection of containers or processes. Containers within a pod share an IP address and port space and can talk to each other through localhost. Its the basic unit of deployment in kubernetes as in a container is the basic unit of deployment in Docker. Each Pod as unique IP Address
a.      Ex: Container for sync files and another container for serving the files can be part of single pod
b.     It can contain only container

2.     Replication controller or Replication Sets: This make sure the specified number of pods are running at any one time and also make sure the system is in the desired state.

Ex: if one of the pod is down. controller will create a new pod and the pods are load balanced  

3.     Deployments: It contains the details of the pods and the replication controller It will deploy the replica sets which will deploy pods and in turn deploy container.

4.     Services: Its a group of pods that can be accessed as a single unit. If one of the pod goes down. a new a pod is created and user has to contact only the service and not to the pods directly

5.     Persistent Volumes: for users and administrators that abstracts details of how storage is provided from how it is consumed

6.     Config Maps: Applications require configuration via some combination of config files, command line arguments and environment variables


Creating kubernetes windows cluster in azure 

Install AzureCLI-2.0

Create a resource group
az group create --name=myKubernetesResourceGroup --location=westus

Create the Cluster
az acs create --orchestrator-type=kubernetes --resource-group myKubernetesResourceGroup --name=myKubernetesClusterName --dns-prefix=myPrefix --agent-count=2 --generate-ssh-keys --windows --admin-
username girish --admin-password basava123#

Install kubectl 
az acs kubernetes install-cli

Get the config file
az acs kubernetes get-credentials --resource-group=myKubernetesResourceGroup --name=myKubernetesClusterName



Create a Json file for creating a Pod

{

 "apiVersion": "v1",

 "kind": "Pod",

 "metadata": {

   "name": "iis",

   "labels": {

     "name": "iis"

   }

 },

 "spec": {

   "containers": [

     {

       "name": "iis",

       "image": "microsoft/iis",

       "ports": [

         {

         "containerPort": 80

         }

       ]

     }

   ],

   "nodeSelector": {

     "beta.kubernetes.io/os": "windows"

   }

 }

}


Create a pods

   kubectl apply -f C:\Users\girish\Desktop\iis.json


Get the Pods

kubectl get pods

To expose the container to the world,Run the below command which will create a service and a azure load balancer

kubectl expose pods iis --port=80 --type=LoadBalancer

To see the service

kubectl get svc

No comments:

Post a Comment