OpenShift Support for BlazeMeter Agent for Kubernetes

Service Virtualization now supports the OpenShift Container Platform web console. You can create a new project, create a role for an agent and deploy the agent using OpenShift. You can then deploy Mock Services to your Private location as usual.

The BlazeMeter Agent and containers officially support OpenShift when using HAProxy. Support for Contour or Istio on OpenShift is experimental at this time.

Set up Service Virtualization on the OpenShift platform

The setup consists of two sections:

Create a New Project and a Role for the Agent

OpenShift admin needs to perform these steps as a prerequisite before a developer can set up Service Virtualization.

Follow these steps:

  1. Create a new project with name blazemeter.
    oc new-project blazemeter
  2. Create Role for the agent.
    • Apply the YAML file:
      apiVersion: rbac.authorization.k8s.io/v1
      kind: Role
      metadata:
      name: role-crane
      namespace: blazemeter
      rules:
      - apiGroups:
      - ""
      resources:
      - pods
      - pods/log
      verbs:
      - get
      - list
      - apiGroups:
      - ""
      - extensions
      - apps
      resources:
      - pods
      - services
      - endpoints
      - daemonsets
      - pods/*
      - pods/exec
      - deployments
      - replicasets
      - deployments/scale
      verbs:
      - get
      - list
      - watch
      - create
      - update
      - patch
      - delete
      - deletecollection
      - createcollection
      - apiGroups:
      - route.openshift.io
      resources:
      - routes
      - routes/custom-host
      verbs:
      - get
      - list
      - create
      - update
      - patch
      - delete
    • Run the following command:
      oc apply -f ./role-crane.yaml
  3. Create Role binding for the agent to default service account in the blazemeter project.
    • Apply the YAML file:
      apiVersion: rbac.authorization.k8s.io/v1
      kind: RoleBinding
      metadata:
      name: role-binding-crane
      namespace: blazemeter
      roleRef:
      apiGroup: rbac.authorization.k8s.io
      kind: Role
      name: role-crane
      subjects:
      - kind: ServiceAccount
      name: default
      namespace: blazemeter
    • Run the following command:
      oc apply -f ./rolebinding-crane.yaml
  4. Provide editing permissions to a developer (or any non-admin user) who will be deploying the agent.
    edit role
    oc adm policy add-role-to-user edit developer

Deploy the Agent

Prerequisite: OpenShift admin needs to create a new project and a role for the agent.

Follow these steps:

  1. Log in as a developer.
    oc login -u developer -p developer https://api.crc.testing:6443
  2. Create a configmap required for the agent app.
    • Edit the agent config map template with the name ‘crane-cm-template.yaml’ to update the AUTH_TOKEN, HARBOR_ID, SHIP_ID. You can get these values by creating a new private location in BlazeMeter.
    • Update the KUBERNETES_WEB_EXPOSE_SUB_DOMAIN with the sub domain of the route host name.
    • (Optional) Update the DOCKER_REGISTRY if you are using the images from your own Docker registry instead of gcr.io.
    • Use the following YAML file for reference:
      apiVersion: v1
      kind: ConfigMap
      metadata:
      name: crane-cm
      namespace: blazemeter
      data:
      AUTH_TOKEN: <AUTH_TOKEN>
      CONTAINER_MANAGER_TYPE: KUBERNETES
      DOCKER_REGISTRY: gcr.io/verdant-bulwark-278
      HARBOR_ID: <HARBOR_ID>
      INHERIT_RUNNING_USER_AND_GROUP: "true"
      KUBERNETES_SERVICE_USE_TYPE: CLUSTERIP
      KUBERNETES_SERVICES_BLOCKING_GET: "true"
      KUBERNETES_WEB_EXPOSE_SUB_DOMAIN: apps-crc.testing
      KUBERNETES_WEB_EXPOSE_TYPE: OPENSHIFT
      SHIP_ID: <SHIP_ID>
    • Run the following command:
      oc apply -f ./crane-cm.yaml
  3. Deploy the agent.
    • Use the following YAML file for reference:
      apiVersion: apps/v1
      kind: Deployment
      metadata:
      name: crane
      labels:
      role: role-crane
      spec:
      selector:
      matchLabels:
      role: role-crane
      replicas: 1
      strategy:
      type: Recreate
      template:
      metadata:
      labels:
      role: role-crane
      spec:
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      containers:
      - envFrom:
      - configMapRef:
      name: crane-cm
      name: bzm-crane
      image: gcr.io/verdant-bulwark-278/blazemeter/crane:3.5.159
      imagePullPolicy: Always
    • Run the following command:
      oc apply -f ./deployment-crane.yaml
  4. Verify the agent status in BlazeMeter. Go to Settings, Workspace, Private Locations.

    openshift private location.png

Once the agent is deployed, you can deploy the Mock Services to your Private location as usual.

To check the deployments, log in to the OpenShift console:

crc console