st-tech / gatling-operator

Automating distributed Gatling load testing using Kubernetes operator
MIT License
68 stars 21 forks source link

Initial version ( copy from PoC repository ) #1

Closed yokawasa closed 2 years ago

yokawasa commented 2 years ago

Descriptions

Initial version of gatling operator which is copied from PoC repository

Huge apologies for being a huge PR πŸ™ πŸ™

:memo: Please be noted that all comments are expected to be made in English

Tests

Local k8s/kind cluster

Preparations for the tests

Before testing

  • make sure to make your remote k8s cluster up and running
  • Also make gatling-operator up and running with make deploy-kind
  • Please see README.md for the detail

First, create local Kind cluster

make kind-create

Check if the kind cluster named gatling-cluster is created

kind get clusters

Then, deploy controller to the kind cluster

make kind-deploy

Check the CRD for gatling-operator is deployed

kubectl get crds

NAME                                      CREATED AT
gatlings.gatling-operator.tech.zozo.com   2021-10-10T05:59:54Z

Check if gatling-operator is running

kubectl get pod,deploy -n gatling-system

NAME                                                       READY   STATUS    RESTARTS   AGE
pod/gatling-operator-controller-manager-7c6c879475-lhx2f   2/2     Running   0          26s

NAME                                                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/gatling-operator-controller-manager   1/1     1            1           26s

Deploy sample gatling CR to the local cluster

For testing01, deploy sample gatling CR named gatling-sample01 to the cluster with make kind-sample-deploy

:memo: testing01 check if gatling test can be done while testing scenarios are packaged in a single container

make kind-sample-deploy

NAME                                                      AGE
gatling.gatling-operator.tech.zozo.com/gatling-sample01   26s

Check if gatling CR is deployed and then if relevant job and pods are created

kubectl get gatling,job,pod                                                                                                                                                                   

NAME                                                      AGE
gatling.gatling-operator.tech.zozo.com/gatling-sample01   26s

NAME                                COMPLETIONS   DURATION   AGE
job.batch/gatling-sample01-runner   0/3           26s        26s

NAME                                READY   STATUS    RESTARTS   AGE
pod/gatling-sample01-runner-s2vkq   1/1     Running   0          26s
pod/gatling-sample01-runner-tv6t4   1/1     Running   0          26s
pod/gatling-sample01-runner-xgwsc   1/1     Running   0          26s

For testing02, deploy sample gatling CR named gatling-sample02 to the cluster with kubectl apply

:memo: testing02 check if gatling test can be done while testing scenarios are given via ConfigMap

kubeclt apply -f config/samples/gatling-operator_v1alpha1_gatling02.yaml

Check if gatling CR is deployed and then if relevant job and pods are created

kubectl get gatling,job,pod                                                                                                                                                                   

NAME                                                      AGE
gatling.gatling-operator.tech.zozo.com/gatling-sample02   32s

NAME                                COMPLETIONS   DURATION   AGE
job.batch/gatling-sample02-runner   0/3           31s        31s

NAME                                READY   STATUS    RESTARTS   AGE
pod/gatling-sample02-runner-chsbq   1/1     Running   0          31s
pod/gatling-sample02-runner-gtlbj   1/1     Running   0          31s
pod/gatling-sample02-runner-jvvt7   1/1     Running   0          31s

Checklist

Remote k8s cluster

Preparations for the tests

Before testing

  • make sure your remote k8s cluster up and running and can connect to its api server via kubectl
  • Also make gatling-operator up and running with make deploy
  • Also make sure your cluster has permissions to pull containers from your container registry
  • Please see README.md for the detail

:memo: in the following description, we use AWS ECR for the private container registry

First, deploy controller to the k8s cluster

# login to the container regsitry (AWS ECR in this case)
aws ecr get-login-password --region ap-northeast-1 | docker login --username AWS --password-stdin 717397055837.dkr.ecr.ap-northeast-1.amazonaws.com/gatling-operator

# make deploy IMG=<your-registry>/gatling-operator:<tag>
make deploy IMG=717397055837.dkr.ecr.ap-northeast-1.amazonaws.com/gatling-operator:v0.0.1

Check the CRD for gatling-operator is deployed

kubectl get crds

NAME                                      CREATED AT
gatlings.gatling-operator.tech.zozo.com   2021-10-10T05:59:54Z

Check if gatling-operator is running

kubectl get pod,deploy -n gatling-system

NAME                                                       READY   STATUS    RESTARTS   AGE
pod/gatling-operator-controller-manager-579bd7bc49-5tvsz   2/2     Running   0          26s

NAME                                                  READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/gatling-operator-controller-manager   1/1     1            1           27s

Deploy sample gatling CR to the remote k8s cluster

For testing01, deploy sample gatling CR named gatling-sample01 to the cluster with make sample-docker-push and make sample-deploy

:memo: testing01 check if gatling test can be done while testing scenarios are packaged in a single container

First, Push a sample gatling image to container registry

# login to the container registry (AWS ECR in this case)
aws ecr get-login-password --region ap-northeast-1 | docker login --username AWS --password-stdin 717397055837.dkr.ecr.ap-northeast-1.amazonaws.com/gatling

# make sample-docker-push SAMPLE_IMG=<your-registry>/gatling:<tag>
make sample-docker-push SAMPLE_IMG=717397055837.dkr.ecr.ap-northeast-1.amazonaws.com/gatling:v0.0.1

πŸ“ Ensure that you're logged into your docker container registry that you will be using as the image store for your K8s cluster if not yet done!

After you push the sample gatling container, deploy the Gatling CR to your cluster:

# make sample-deploy SAMPLE_IMG=<your-registry>/gatling:<tag>
make sample-deploy SAMPLE_IMG=717397055837.dkr.ecr.ap-northeast-1.amazonaws.com/gatling:v0.0.1

Check if gatling CR is deployed and then if relevant job and pods are created

kubectl get gatling,job,pod                                                                                                                                                                   

NAME                                                      AGE
gatling.gatling-operator.tech.zozo.com/gatling-sample01   25s

NAME                                COMPLETIONS   DURATION   AGE
job.batch/gatling-sample01-runner   0/3           25s        25s

NAME                                READY   STATUS    RESTARTS   AGE
pod/gatling-sample01-runner-7b8sm   1/1     Running   0          25s
pod/gatling-sample01-runner-95t2j   1/1     Running   0          25s
pod/gatling-sample01-runner-kwgjw   1/1     Running   0          25s

For testing02, deploy sample gatling CR named gatling-sample02 to the cluster with kubectl apply

:memo: testing02 check if gatling test can be done while testing scenarios are given via ConfigMap

kubectl apply -f config/samples/gatling-operator_v1alpha1_gatling02.yaml

Check if gatling CR is deployed and then if relevant job and pods are created

kubectl get gatling,job,pod                                                                                                                                                                   

NAME                                                      AGE
gatling.gatling-operator.tech.zozo.com/gatling-sample02   29s

NAME                                COMPLETIONS   DURATION   AGE
job.batch/gatling-sample02-runner   0/3           30s        30s

NAME                                READY   STATUS    RESTARTS   AGE
pod/gatling-sample02-runner-4g7vn   1/1     Running   0          30s
pod/gatling-sample02-runner-cskh5   1/1     Running   0          30s
pod/gatling-sample02-runner-xnvhz   1/1     Running   0          30s

Checklist

yokawasa commented 2 years ago

Given the suggestion like https://github.com/st-tech/gatling-operator/pull/1#discussion_r733460033, I added check if cloud storage info is given, and skip the reporter job in the case that prerequistes are not met https://github.com/st-tech/gatling-operator/pull/1/commits/437ea7b03d7ac264eab3e53886b2040842f5653e

yokawasa commented 2 years ago

I was wondering about the behavior on rerun. It's not necessary to fix the minor points.

Please see the comment I made in the thread https://github.com/st-tech/gatling-operator/pull/1#discussion_r740047892, Also please check the following updates I made based upon your comments:

yokawasa commented 2 years ago

@akitok @niqniqniqq @tmrekk121 thanks a lot for the review! I go ahead to merge the PR