Posted on Leave a comment

Deploying kubernetes applications with 2-clicks | Azure DevOps & Terraform

When you read the title you may think that this article can be a clickbait. That’s the reason you should continue reading until this end to figure out that deploying k8s application with Azure DevOps and terraform can be very easy when you create everything through infrastructure as code.

In this example we will utilize Azure DevOps pipelines and terraform to deploy a yaml definition on an AKS cluster that runs on Azure. For this output we will need three steps.

The first step is to create an AKS cluster on Azure. When we have the infrastructure ready we can then continue and bind Azure DevOps pipelines with the AKS resource so that we can deploy on the cluster. The last step is to have the yaml definition of the application that we need to deploy and run the application deployment process inside azure devops.

The project is structure as shown in the below picture.

  • The code folder contains the yaml k8s definition file.
  • The iac_aks creates the AKS cluster inside Azure
  • The iac_devops creates the Azure Devops resources needed (Service connection with AKS)
  • And finally the azure-pipeline and application-pipeline are the pipelines that will run the automation and do the job.

In order to try out the example the first think that you need to do is to create a variable group inside azure devops and store two values. The first value will be the secret Personal access token that will be used to create the Azure DevOps resources. The second one is the URL of your Azure DevOps organization.

When those are set you will need to change the tfvars files and add the names that you prefer for the resources creation. Finally you can have your deployment ready with just two clicks. One for the infra pipelines and one for the application pipeline.

Code is hosted on Github

Posted on Leave a comment

Install kubernetes plugins with krew

There are a lot of tools built around Kubernetes the industry standard orchestration tool that enterprises use in order to host micro-services. One open source project which allow you to install helpful plugins for k8s is krew and you can find it on GitHub.

By installing krew, you will get access to many helpful plugins that have been created for developers and uploaded to krew marketplace. One example of these plugins is the resource-capacity plugin which gives you at a glance limit, resources usage for your k8s pods.

First you will need to install krew for your operating system. The installation instructions can be found in the link below, and you should follow the steps provided.

If you use windows, you will need to add krew on your path in order to have the tool available on your command line. First navigate in your system advanced settings and press environmental variables.

Then you will need to add in your path variable, the installation path of krew which should be %USERPROFILE%\.krew\bin

After installing krew, you can run a command to verify if PATH variables work. You will need first to restart your cmd

As a last step you can install plugins using krew with

kubectl krew install plugin-name

In my case I installed the resource capacity plugin which give CPU, Memory Requests and Limits for your k8s cluster.

FInally you can find your installed plugins inside .krew/store folder.

Posted on Leave a comment

Error while proxying request: getting credentials: exec: executable kubelogin not found

For those who do not know Lens, it is a powerful IDE tool for managing Kubernetes. When it comes to k8s administration, sometimes command line would be a pain for engineers so various companies create tools that can provide the same functionality with a modern GUI. Such tool is Lens and you can find it using the link below.

After you setup Lens you may encounter an error when you try to connect to your k8s cluster.

The error indicates that you are missing kubelogin tool. You can verify that by typing kubelogin –version in the command line. If you get an error you should go and install the tool.

Following the instructions provided by the documentation you will be able to install kubelogin.

I personally used the setup for windows through powershell.

After you install kubelogin, close and open the application again so that the PATH settings get updated. Finally you will be able to browse your cluster with Lens.

Posted on Leave a comment

Deploy kubernetes cluster with kubectl and azure devops

In this guide we will examine how you can deploy pods on your Azure Kubernetes Cluster with Azure devops. In order to getting started you will need to create an AKS cluster under a resource group and connect this cluster with azure devops. After the creation you will need to connect with the cluster and export the kubeconfig file for the ado service connection.

You can do that by pressing connect

You can read the rest of the article on Medium using the link below:

A detailed deployment video can be found on my Udemy course: