Deploy New Relic Infrastructure inside a Azure Kubernetes Cluster

In this post, we will create a Kubernetes Azure Container Service. Later, we will create Dockerfile to push an image into to the Azure Container Registry. After that, we will create a helm charts to wrap our environment and finally, we will deploy it in our cluster.


Set up

Deploying Kubernetes on ACS

First of all, we need to set some environment variables to make this process a little bit easier. Feel free to edit them and paste them into your terminal.


Now, login to Azure in your CLI:

az login

After that, deploy a new resource group (it might take a couple of minutes):

az group create -n $RESOURCE_GROUP -l $LOCATION

It should return "provisioningState": "Succeeded".

Then, deploy the Azure Container Service (full documentation). This next command asumes you dont have ssh keys in your terminal, but you can remove the --generate-ssh-keys if you would like az to use your usual pair of ssh keys (uploads ~/.ssh/ to the VMs):

az acs create --orchestrator-type=kubernetes -n $CLUSTER_NAME -g $RESOURCE_GROUP -d $CLUSTER_DNS --generate-ssh-keys

It should take about 10 minutes to finish and it will return a "provisioningState": "Succeeded".

The next step is to install kubectl by running:

az acs kubernetes install-cli

Obtain the .kube/config:

az acs kubernetes get-credentials -g=$RESOURCE_GROUP -n=$CLUSTER_NAME

And finally, verify you can connect to your cluster by getting your pods:

kubect get pods

Deploying ACR

In addition to the Azure Cli 2.0 and depending on your version you might have to install the acr component in your Az CLI.

az component update --add  acr

This component allow us to manage the Azure Container Registry through our CLI. We will use a ACR to host our Docker images that will be deployed later in our cluster. Deploy one on your subscription with the following command (full documentation):

az acr create -n $ACR_NAME -g $RESOURCE_GROUP -l $LOCATION

Allow admin access to your ACR to retrieve the username and password:

az acr update -n $ACR_NAME --admin-enabled true

And get the credentials:

ACR_CREDS=`az acr credential show -n $ACR_NAME` | echo $ACR_CREDS

If you have jq installed you can do the following:

ACR_USER=`echo $ACR_CREDS | jq -r '.username'`
ACR_PASS=`echo $ACR_CREDS | jq -r '.password'`

With these credentials we will be able to push the images to the registry.

Steps to deploy New Relic

Basically, we will create a Dockerfile with the New Relic infrastructure. After that, we will upload that image to the ACR where it will be pulled by a helm chart to deploy it into our kubernetes cluster.

Create dockerfile

Let’s start by creating a working directory, lets call it azure-nri:

mkdir azure-nri
cd azure-nri

Push it to the ACR

Create helm chart

Deploy New Relic into the cluste