Coder Social home page Coder Social logo

kubctl-node-micro-service's Introduction

Azure Kubernetes Micro Service

This repository will walk you through on how to setup your AKS cluster, create your own Azure Registry, create a service principal so that AKS cluster can access the Azure Registry. Once the RBAC is created, you can upload your local Docker Image to the Registry. And then instruct AKS to deploy image. Before you start venturing into AKS, please ensure to have

  • kubectl (brew install kubernetes-cli)
  • azure-cli ()
  • node (brew install node)
  • gulp (npm install gulp -g)

installed

Step-1

Once you have created your "Free Trial" account through https://portal.azure.com switch to azure-cli

az account show

If you have more than one subscription in your account (like I have) use to following to swtich to reight subscription:

az account set -s "Free Trial"

Step-2

Before creating AKS cluster, you need to create resource group. An Azure resource group is a logical container into which Azure resources are deployed and managed.

az group create --name myResourceGroup --location eastus myResourceGroup is the name of my group

Once the resource group is created, create Azure Container registry with the az acr create command. The registry name must be unique within Azure.

az acr create --resource-group myResourceGroup --name myResourceG --sku Basic myResourceG is the name of my Registry

Step-3

Login to the newly created container

az acr login --name myResourceG

Create a service principal with az ad sp create-for-rbac.

az ad sp create-for-rbac --skip-assignment

The output of the above command produces the following output.

  {
   "appId": "XXXXXXXXXXXXXXXXXX",
   "displayName": "azure-cli-2018-07-24-17-15-19",
   "name": "http://azure-cli-2018-07-24-17-15-19",
   "password": "XXXXXXXXXXXXX",
   "tenant": "15ccb6d1-d335-4996-b6f9-7b6925f08121"
  }

Now to access images that will be pushed in the ACR from the AKS, use the above appId and password to create a role assignment. Using the following command:

`az acr show --name myResourceG --resource-group myResourceGroup` 

gather the acrId. It should be something like: "/subscriptions/2b4a6dde-bc39-4d82-a08d-651133df1609/resourceGroups/myResourceGroup/providers/Microsoft.ContainerRegistry/registries/myResourceG"

az role assignment create --assignee <appId> --role Reader --scope <acrId>

Step-4

Now create an AKS cluster with clustername cluster-1

az aks create --name cluster-1 --resource-group myResourceGroup --node-count 1 --generate-ssh-keys --service-principal "c41d4e40-9800-4128-addc-36d877e9ab58" --client-secret "7f8f10b1-74f9-4469-8eb8-ece3f79380c1"

This will probably take around 5-6 minutes to setup the cluster.*

Once the cluster is created, to connect with kubectl gets credentials for the AKS cluster name cluster-1 in the myResourceGroup.*

az aks get-credentials --name cluster-1 --resource-group myResourceGroup

To verify the connection to your cluster, run

kubectl get nodes

Step-5

Download the code from https://github.com/AnirbanKundu/aks-micro-service.git. To build the application run:

  npm install
  gulp dist  

Now create the docker file, using the following command:

docker build -t node-web-svc .

To know the ACR login server URL run the following command :

az acr show --name myResourceG --resource-group myResourceGroup

The output of the command shows the ACR uri - in this case, the URI is "loginServer": "myresourceg.azurecr.io" Now tag your local image as :

docker tag node-web-svc:1.0 myresourceg.azurecr.io/node-web-svc:v1

Push the image to the ACR server

docker push myresourceg.azurecr.io/node-web-svc:v1

Using the Deployment.yaml file create the deployment and service Using the following command it is done

kubectl apply -f Deployment.yaml 

Step-6

To test the application, check if the Kubernetes service is created which exposes the application to the internet. This process can take a few minutes. To monitor progress, use

kubectl get service node-web-svc --watch

Once the EXTERNAL-IP address has changed from pending to an IP address, use CTRL-C to stop the kubectl watch process. The current service is available http://23.96.27.6:9002/get

OSBA

az aks get-credentials --resource-group myResourceGroup --name osba-quickstart-cluster --admin

kubctl-node-micro-service's People

Contributors

anirbankundu avatar anirbankunduge avatar

Watchers

James Cloos avatar  avatar

Forkers

vdonthireddy

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.