Kubernetes

This guide walks you through installing the Middleware Agent (mw-agent) in a Kubernetes environment. These instructions can also be found on the Installation page in the Middleware application.

The installation will set up Middleware Agent as a DaemonSet and Deployment inside your Kubernetes cluster and add necessary components to appropriately permission the DaemonSet and Deployment pods. A Kubernetes service is also created to allow components to connect to the Middleware Agent via Cluster IP address and ports which can then be used by langague specific APM SDKs.

Prerequisites

1 Kubernetes Version

Kubernetes version 1.21 or above. Check with the following command:

2 Kubernetes Access

Access to Kubernetes cluster and client (i.e. kubectl)

kubectl version should be >= v1.17.0, You can verify the current version via this command

3 CLI Tools

Install bash, curl and wget

Install

Step 1: Access Kubernetes Installation

Log in to your Middleware account, navigate to the Installation Page in the bottom left corner and select Kubernetes from the Infrastructure section

Step 2: Identify Kubernetes Context

Get the current Kubernetes Context and ensure the cluster belonging to this Context is where you want to install the Middleware Agent.

Use the following command to find out your current Kubernetes context:

Note the CLUSTER name from the output of the command above. This name will be used as an input for clusterMetadata.name if you wish to use Helm option to install the Middleware Agent in the next step.

Step 3: Run Kubernetes Install Command

Install the Middleware Agent for Kubernetes with Helm, Bash or .bat. Copying the command directly from the Installation page ensures your API key and Target is inserted correctly.

If you are installing the Middleware Agent with Microsoft PowerShell, proceed to the Kubernetes with MS PowerShell document.

Helm
Bash
.bat

To get started you'll want to add our helm repo and then run the helm install below.

In the helm install command, replace <your-cluster-name> with the name of your cluster. This name can be found using kubectl config current-context command.

Using an existing secret w/ Helm to manage API Keys

You can use an existing secret from your secret manager with the below snippet, assuming that secret has the Middleware API Key:

Download the Middleware Agent batch file here. Open PowerShell, change the directory to the location of the download, and execute the following commands:

Step 4: Add Host Tags [Optional]

Create filterable custom tags by adding the MW_HOST_TAGS environment variable to the installation command as comma-separated key-value pairs. Use the tag name to create an alias for the host (e.g. production).

Check your host tags have been embedded by navigating to Infrastructure -> Your Desired Host -> System Information

Step 5: Verify Installation

Verify the status of the Middleware Agent with the following command:

Step 6: Check Your Dashboard

Navigate to Middleware and ensure metrics are appearing in the Kubernetes section on the Infrastructure tab. Depending on the size of your cluster, it can take up to a few minutes for metrics to appear. If metrics do not appear after this time head to our troubleshooting page for some common issues.

Upgrade

The Middleware Agent is frequently updated to add new features and improve performance. More information on new features can be found in our Newsletter.

Select one of the options below depending on your Middleware Agent installation method.

Helm
Bash

Troubleshooting

Run only one Middleware Agent DaemonSet per cluster per host. Multiple agents will cause unexpected behavior.

Once the Middleware Agent is installed on your cluster metrics should begin appearing in the Middleware application within a few minutes. If metrics do not appear, confirm that Kubernetes has access to the internet, either directly or through a proxy, and that only one MW Agent is running per cluster.

Switching Between Contexts

If you are using another thirdy-party resource for managing your Kubernetes Infrastructure (e.g. Lens) it's possible your cluster names are similar across clusters. This will make it hard to delineate between the clusters inside of Middleware.

To fix this, you can force a speicific cluster.name by setting the MW_KUBE_CLUSTER_NAME environment variable to the name(s) you are using in your thrid party resource. Once the cluster is renamed, it will automatically reset and start to catch the appropriately labeled environment variables.

Uninstall

Helm
Bash

If you installed the agent via Helm chart, you can uninstall via the following commands:

To uninstall the Middleware Agent use the following command:

Need assistance or want to learn more about Middleware? Contact our support team at [email protected].