Kubernetes using distributed load testing

Foreword

Github address https://github.com/rootsongjc/distributed-load-testing-using-kubernetes

The tutorial describes how Kubernetes distributed load balancing tests, including a web application, and Docker image Kubernetes controllers / services. For more information, please see the Distributed Testing the Using the Load Kubernetes .

Note: The test is set up on my own local cluster of kubernetes test does not require the use of Google Cloud Platform.

ready

GCE and other components do not need, you just need to have a kubernetes cluster can be.

If you have not kubernetes cluster, you can refer kubernetes-handbook deploy a.

Deploying Web Applications

sample-webappDirectory contains a simple web application testing. We will build its image as a docker, run kubernetes in. You can build your own, you can also directly use this I build a good image index.tenxcloud.com/jimmy/k8s-sample-webapp:latest.

Sample-webapp deployed on kubernetes.

$ cd kubernetes-config
$ kubectl create -f sample-webapp-controller.yaml
$ kubectl create -f kubectl create -f sample-webapp-service.yaml

Locust deployment of the Controller and Service

locust-masterAnd locust-workuse the same docker mirror, modify cotnroller in the spec.template.spec.containers.envfield of value for your sample-webappservice name.

- name: TARGET_HOST
  value: http://sample-webapp:8000

Creating Controller Docker mirror (optional)

locust-masterAnd locust-workall controller use locust-tasksdocker mirror. You can download gcr.io/cloud-solutions-http://olz1di9xf.bkt.clouddn.com/locust-tasks, you can compile your own. Probably take a few minutes to compile, image size is 820M.

$ docker build -t index.tenxcloud.com/jimmy/locust-tasks:latest .
$ docker push index.tenxcloud.com/jimmy/locust-tasks:latest

Note : I am using a cloud-speed image repository.

Yaml each controller's spec.template.spec.containers.imagefield specifies that my image:

image: index.tenxcloud.com/jimmy/locust-tasks:latest

Deployment Locust-Master

$ kubectl create -f locust-master-controller.yaml
$ kubectl create -f locust-master-service.yaml

Deployment Locust-Worker

Now deploy locust-worker-controller:

$ kubectl create -f locust-worker-controller.yaml

You can very easily to the work expansion, through the command line:

$ kubectl scale --replicas=20 replicationcontrollers locust-worker

Of course, you can also WebUI: Dashboard - Workloads - Replication the Controllers - ServiceName to expansion Scale -.

20170425173628

Configuration Traefik

Reference kubernetes traefik ingress of installation , the ingress.yamladdition of the following configurations:

  - host: traefik.locust.io
    http:
      paths:
      - path: /
        backend:
          serviceName: locust-master
          servicePort: 8089

And then perform kubectl replace -f ingress.yamlto update traefik.

By Traefik the dashboard you can see the newly added traefik.locust.ionodes.

20170425173638

Test execution

Open the http://traefik.locust.iopage, click on Editthe number of requests and the number of users enter fake user sent per second, click Start Swarmingon it to start the test.

20170425173648

Adjusted during the test sample-webapppod number (the default setting for a pod), to observe changes in the load of pod.

20170425173657

From the period of observation can be seen in the load is evenly distributed to the three pod.

In locust pages can be observed in real time can also download the test results.

20170425173705

reference

Original articles published 0 · won praise 0 · Views 540

Guess you like

Origin blog.csdn.net/qingdao666666/article/details/104625605