Installing a BlazeMeter Agent for Kubernetes

You want to install a BlazeMeter on-premise agent for Kubernetes on a server/instance behind your firewall. BlazeMeter supports the two Ingress controllers for Kubernetes, Contour and Istio.

If you want to install a BlazeMeter on-premise agent for Kubernetes specifically to run virtual services, consider setting up Istio. For more information, see Installing a BlazeMeter Agent for Kubernetes - Service Virtualization.

When adding an on-premise agent for a Private Location, you will come across commands for Docker and Kubernetes installations, which you copy and run on your machine to install the agent. Ensure that you update all environment variables according to your Kubernetes instance.

Contour Configuration

BlazeMeter provides two methods for installing a Kubernetes agent with Contour:

  • Automatic: Involves copying a BlazeMeter auto-generated command, then replacing environment variables with your own, and possibly adding new ones. This is a straightforward method recommended for most use cases.
  • Manual: Involves creating separate YAML files, filling them with your environment variables, and executing them individually. This method is recommended for special use cases, for example, if you need to use CA certificates with your agent.

This article covers these two alternative procedures:

Install Kubernetes Agent (Automatic)

The following steps walk you through the automatic method. For the manual method, see Optional Installation Step: Manual Kubernetes Agent Installation.

If you are installing an agent that uses a CA certificate, we recommend using the manual install method instead.

Follow these steps:

  1. Verify that your server/instance meets the minimum requirements.
  2. Log into your BlazeMeter account and click Settings in the top right corner.
    settings
  3. To choose to the Private Location where you want to create the Agent, go to Workspaces, Private Locations.
    private location
  4. For our Kubernetes implementation, ensure that your Private Location support a Shared Run Type instead of Dedicated. See Creating a Private Location for details.
  5. Click Add agent.

    add agent

  6. Enter the agent name.
  7. (Optional) Enter the IP address of the machine.
  8. Click Create Agent.
    new agent

    A Kubernetes installation command and configuration is generated on the Kubernetes Configuration tab.
    k8s config

  9. Copy the command, then update and/or add to the environment variables as per details of your Kubernetes instance. For details, see the following section Using the Kubernetes Auto-Generated Command, and also the article BlazeMeter Agent Environment Variables.
  10. Run the updated command on your private engine.
  11. Use the following command to check on the status of the pod launch for the crane deployment:
    kubectl get pods
  12. After the Kubernetes pod shows as 'Running', the agent indicates to be in an 'Idle' status and is available for use. For more information what you can do with your new private location, see Using Private Locations.

    agent actions

Using the Kubernetes Auto-Generated Command (Manual)

When adding an on-premise agent for a Private Location, you will come across commands for Docker and Kubernetes installations, which you copy and run on your machine to install the agent.

The Kubernetes auto-generated command allows you to consolidate all configuration and deployment variables for a simpler execution.

Prerequisites for using the auto-generated command

  • Verify that you have a cluster admin access to execute the command.
  • Replace all instances of namespace with your assigned namespace. For best practices for a namespace, see the Kubernetes documentation.
    • Use the following yaml to create a namespace if required:
      apiVersion: v1
      kind: Namespace
      metadata:
      name: BLAZEMETER
  • You can also add and replace other environment variables as required by your instance. See the complete list of BlazeMeter Agent Environment Variables for details.
If using Contour as Ingress controller, for example, for Service Virtualization, do not forget to enable the Contour stanza (the last part of the auto-generated command) by removing the comment prefixes.

Example Auto-Generated Command

Copy
cat <<'_FILE_1234567890_END_' | kubectl apply -f -  
---
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata: { namespace: BLAZEMETER, name: role-crane }
rules: [{ apiGroups: [''], resources: [pods/exec], verbs: [create] }, 
{ apiGroups: [''], resources: [pods, pods/log], verbs: [get, list] }, 
{ apiGroups: [extensions, apps, ''], resources: [pods, services, endpoints, 
daemonsets, 'pods/*', pods/exec, deployments, replicasets, ingresses, deployments/scale], 
verbs: [get, list, watch, create, update, patch, delete, deletecollection, createcollection] }]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata: { name: role-binding-crane }
subjects: [{ kind: ServiceAccount, name: default, namespace: BLAZEMETER }]
roleRef: { kind: Role, name: role-crane, apiGroup: rbac.authorization.k8s.io }
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata: { name: cluster-role-crane }
rules: [{ apiGroups: [''], resources: [nodes], verbs: [get, list, watch, create, update, patch] }]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata: { name: cluster-role-binding-crane }
roleRef: { apiGroup: rbac.authorization.k8s.io, kind: ClusterRole, name: cluster-role-crane }
subjects: [{ kind: ServiceAccount, name: default, namespace: BLAZEMETER }]
---
apiVersion: apps/v1
kind: Deployment
metadata: { name: crane, labels: { role: role-crane, harbor_id: 5fab0840a7cf6b5c2a3aa414, 
ship_id: 5fb2f5a65c99071c0f79bfd6 } }
spec: { selector: { matchLabels: { role: role-crane, harbor_id: 5fab0840a7cf6b5c2a3aa414, 
ship_id: 5fb2f5a65c99071c0f79bfd6 } }, replicas: 1, strategy: { type: Recreate }, 
template: { metadata: { labels: { role: role-crane, harbor_id: 5fab0840a7cf6b5c2a3aa414, ship_id: 5fb2f5a65c99071c0f79bfd6 } }, spec: { restartPolicy: Always, terminationGracePeriodSeconds: 30, containers: [{ name: bzm-crane-5fb2f5a65c99071c0f79bfd6, image: 'blazemeter/crane:latest', imagePullPolicy: Always, env: [{ name: HARBOR_ID, value: 5fab0840a7cf6b5c2a3aa414 }, { name: SHIP_ID, value: 5fb2f5a65c99071c0f79bfd6 }, { name: AUTH_TOKEN, value: c2d9fccc40a1391c4a3ff1000039feba6ed4908d73f2abce4ca6a67434a211ee }, { name: CONTAINER_MANAGER_TYPE, value: KUBERNETES }, { name: IMAGE_OVERRIDES, value: '{}' }, { name: DOCKER_REGISTRY, value: gcr.io/verdant-bulwark-278 }, { name: AUTO_KUBERNETES_UPDATE, value: 'true' }] }] } } }

## Uncomment following YAML to grant read/write access to HttpProxy in Contour
# ---
# apiVersion: rbac.authorization.k8s.io/v1
# kind: ClusterRole
# metadata: { name: contour-access-cluster-role }
# rules: [{ apiGroups: [''], resources: [nodes], verbs: [get, list, watch, create, update, patch] }]
# ---
# apiVersion: rbac.authorization.k8s.io/v1
# kind: ClusterRoleBinding
# metadata: { name: contour-access-for-default-sa }
# roleRef: { apiGroup: rbac.authorization.k8s.io, kind: ClusterRole, name: contour-access-cluster-role }
# subjects: [{ kind: ServiceAccount, name: default, namespace: BLAZEMETER }]

_FILE_1234567890_END_