Installation of Kubernetes on Azure

Kubernetes Introduction

Kubernetes (K8S) is an open-source system for automating deployment, scaling, and management of containerized applications.

It groups containers that make up an application into logical units for easy management and discovery.
Running Kubernetes Cluster on Public Cloud:
While trying to deploy Kubernetes cluster on Public Cloud like azure, there are two options:

  1. Deploy K8S from scratch using ACS engine on azure.
  2. Use one of the turnkey methods like Flannel based or Weave based.

There are many resources describing the Flannel based and the Weave based turnkey solutions for deployment of K8S on Azure, however very few available on deployment of K8S from scratch using ACS engine on azure.
We present a technique of end-to-end deployment of K8S from scratch using ACS engine on azure.

Fig: Installation of K8S on Azure over the network using ACS Engine.

Steps of Kubernetes deployment on Azure

Pre-Requisite:
Installation of git, Python 2.7.9 or greater, docker (latest version).

  1. Installation of Azure CLI on linux host VMAs they say “A great cloud needs a great tools” and hence we need to install azure cli on the linux host VM using,
    $ curl -L https://aka.ms/InstallAzureCli | bash
  2. Installation of Azure CLI on linux host VM
    Pre-Requisite:
    It needs golang being installed on the linux VM host.

    $ apt-get install golang

    Steps for installation of ACS engine on linux host VM.

    1. Setup go path using,
      $ mkdir $HOME/go
    2. Edit
      $HOME/.bash_profile

      and add the following lines to setup your go path

      $ export PATH=$PATH:/usr/local/go/bin
      $ export GOPATH=$HOME/go
      note: if ~/.bash_profile is missing than add the above lines to the ~/.bashrc file.
      $ source $HOME/.bash_profile
    3. Perform some preliminary steps in order to achieve the binary of the acs-engine.
      • Get the local copy of the acs-engine git hub project.
        $ go get github.com/Azure/acs-engine
      • Change the path to,
        $ cd $GOPATH/src/github.com/Azure/acs-engine
      • Install glide using;
        $ sudo add-apt-repository ppa:masterminds/glide
        $ sudo apt-get install glide
        $ sudo apt-get update
        $ glide create
        $ glide install
        $ sudo make
        $ sudo apt-get update
      • Get the binary of the go-bindata;
        $ go get -u github.com/jteeuwen/go-bindata/…
        $ cd ~/GOPATH/bin
        Verify that go-bindata is available in this location.
        $ sudo make (To build the binary of the acs-engine)
        Verify that binary of the acs-engine is created at the location;
        $ ls GOPATH/src/github.com/Azure/acs-engine/bin
  3. Run the acs-engine binary to get the azure command-line parameters.
    $ cd GOPATH/src/github.com/Azure/acs-engine/bin
     $ ./acs-engine
  4. Generating the service PrincipalKubernetes uses a Service Principal to talk to Azure APIs to dynamically manage resources such as User Defined Routes and L4 Load Balancers.

    Using Azure CLI:

    $ az login
    $ az account set –subscription=“${SUBSCRIPTION_ID}”
    $ az ad sp create-for-rbac –role=“Contributor” --scopes=/subscriptions/${SUBSCRIPTION_ID}

    This will output your appId, password, name, and tenant. The name or appId may be used for the servicePrincipalProfile.servicePrincipalClientId and the password is used for servicePrincipalProfile.servicePrincipalClientSecret

    Confirm your service principal by opening a new shell and run the following commands substituting in name, password, and tenant:

    $ az login --service-principal -u NAME -p PASSWORD –tenant TENANT
    $ az vm list-sizes --location westus
    (Note: replace westus by <resource group location name>
  5. Create a new kubernetes.json file under the example directory in the following path
    $GOPATH/src/github.com/Azure/acs-engine/examples

    Add the following parameters:

    1. SSH Public keys under the values for the “keyData”.This can be obtained from the
      $ cat ~/.ssh/id_rsa.pub
    2. Add values for the keys “servicePrincipalClientID” and for “servicePrincipalClientSecret”.
    3. Add values for “dns-prefix” key under master profile.
    4. Add private ip’s for the master nodes and for the slave nodes under the master profile and in the agent profile.
  6. Generate the new Template deployment
    Run

    $./bin/acs-engine generate examples/kubernetes.json

    to generate the templates in the _output/Kubernetes-UNIQUEID directory. The UNIQUEID is a hash of your master’s FQDN prefix.

  7. Deploying with Azure CLI 2.0
    The generated templates from the step 5 i.e. azuredeploy.json and azuredeployparameters.json in the _output/Kubernetes-UNIQUEID directory can now be used using azure cli to deploy the cluster.
  8. Verification
    To Verify your deployment using below command:
    SSH to k8s-master (use Public IP address or DNS name)

    ssh azureuser@

    Execute below commands and see the output:

    kubectl get nodes # list all nodes in k8s cluster
    kubectl get services --all-namespaces

Ajeet Vijayvargiya

Ajeet Vijayvargiya

Senior Technical Lead at Calsoft inc.
Ajeet has 11 years of experience in development/design/testing of enterprise LAN security products and cloud computing. He has in-depth knowledge of TCP/IP Protocol development, DPDK development, virtualization and cloud computing. Ajeet is a RedHat Certified Engineer and also a Certified Cloud Developer (MS Azure).
Ajeet Vijayvargiya

Latest posts by Ajeet Vijayvargiya (see all)


    Farhan Patel

    Farhan Patel

    Automation QA-Verification & Validation Engineer at Calsoft inc.
    Farhan has has experience in the Networking domain that includes Routing and Switching in LAN networks, SDN, Data-Center Networking (Leaf-Spine Architecture) and Network Security as it's major focus. He has worked and executed QA activities in cloud technologies like Azure, AWS, Docker container, Kubernetes, Mesos, Marathon,etc
    Farhan Patel

    Latest posts by Farhan Patel (see all)

    Leave a Reply

    Your email address will not be published. Required fields are marked *