ajeetraina / jmeter-docker

Setting up JMeter Distributed Load Testing Environment under Docker 17.03 Swarm Mode Cluster
36 stars 42 forks source link

Swarm mode service #1

Open guillemsola opened 7 years ago

guillemsola commented 7 years ago

Awesome template!

Is it possible to make this running as a docker Swarm service? If I launch the compose as service I cannot do the docker exec as services seems to run in a different way.

It would be awesome to have this covered in the repo

ajeetraina commented 7 years ago

Good catch. The exact command is :

$sudo docker stack deploy -c docker-compose.yml myjmeter

This is for Swarm Mode cluster.

Refer to my blog which clearly explains that :

http://collabnix.com/archives/2708

I will go ahead and update the Readme.

ajeetraina commented 7 years ago

I have updated the README.md.

guillemsola commented 7 years ago

Nice,

Then what I miss is, how do you get with docker ps the container id? I though it was not possible to do a docker exec in Swarm mode

I understand this is the feature that we will need https://github.com/moby/moby/issues/27552

ajeetraina commented 7 years ago

The command 'docker ps' shows only the containers running on the local machine. You need to run 'docker service ps' to get the containers for specific service and to know the node it is running on.

On 06-May-2017 12:16 PM, "guillemsola" notifications@github.com wrote:

Nice,

Then what I miss is, how do you get with docker ps the container id? I though it was not possible to do a docker exec in Swarm mode

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ajeetraina/jmeter-docker/issues/1#issuecomment-299620122, or mute the thread https://github.com/notifications/unsubscribe-auth/AATIiNg3QHT5MhOT6_vxu6VkgCemUoBgks5r3BdOgaJpZM4NSjAT .

ajeetraina commented 7 years ago

BTW..I assume you know how stack deploy works under Swarm Mode which is different from how Docker Compose works for a single server.

If you are planning to use Swarm exec, https://github.com/mavenugo/swarm-exec interest you.

On 06-May-2017 1:56 PM, "Ajeet S Raina" ajeetraina@gmail.com wrote:

The command 'docker ps' shows only the containers running on the local machine. You need to run 'docker service ps' to get the containers for specific service and to know the node it is running on.

On 06-May-2017 12:16 PM, "guillemsola" notifications@github.com wrote:

Nice,

Then what I miss is, how do you get with docker ps the container id? I though it was not possible to do a docker exec in Swarm mode

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ajeetraina/jmeter-docker/issues/1#issuecomment-299620122, or mute the thread https://github.com/notifications/unsubscribe-auth/AATIiNg3QHT5MhOT6_vxu6VkgCemUoBgks5r3BdOgaJpZM4NSjAT .

guillemsola commented 7 years ago

I was trying to use a Swarm service cluster from an azure template to perform a jmeter test with many clients. Your github project gives very good insights but I was struggling to connect with the master jmeter via docker exec as this is not possible with Swarm mode. I will try with the project you have referenced.

As I still confuse a bit between classic swarm and swarm mode this is what I'm using

azureuser@swarmm-master-31109991-0:~$ docker version
Client:
 Version:      17.04.0-ce
 API version:  1.28
 Go version:   go1.7.5
 Git commit:   4845c56
 Built:        Mon Apr  3 18:07:42 2017
 OS/Arch:      linux/amd64

Server:
 Version:      17.04.0-ce
 API version:  1.28 (minimum version 1.12)
 Go version:   go1.7.5
 Git commit:   4845c56
 Built:        Mon Apr  3 18:07:42 2017
 OS/Arch:      linux/amd64
 Experimental: false
azureuser@swarmm-master-31109991-0:~$ docker node ls
ID                           HOSTNAME                           STATUS  AVAILABILITY  MANAGER STATUS
edl0shsmnimcwhdo3069ojxzr    swarmm-master-31109991-1           Ready   Pause         Leader
fyv3wz1g785skf9anl59trg5t    swarmm-agentpublic-31109991000002  Ready   Active
hiorksdmb8y94ifzyaq5ykgyn *  swarmm-master-31109991-0           Ready   Pause         Reachable
qf2346e96d4vzxv5gb221sa05    swarmm-master-31109991-2           Ready   Pause         Reachable
qms6uf6ut9g2frk414y1jiqv6    swarmm-agentpublic-31109991000004  Ready   Active
uz8c0c4zj7e4hxlw16d2u7qdp    swarmm-agentpublic-31109991000003  Ready   Active
azureuser@swarmm-master-31109991-0:~$ docker service ls
ID                  NAME                MODE                REPLICAS            IMAGE
jiecd0kb524e        bar                 replicated          3/3                 jwilder/whoami:latest
jvdlb2cyqwne        alataque_master     replicated          0/1                 ajeetraina/apache-jmeter-master:latest
wmics9kabwuz        foo                 replicated          1/1                 nginx:latest
yjg7u8jdfzys        alataque_slave      global              3/3                 ajeetraina/apache-jmeter-server:latest
azureuser@swarmm-master-31109991-0:~$ docker service ps alataque
ID                  NAME                                       IMAGE                                    NODE                                DESIRED STATE       CURRENT STATE           ERROR               PORTS
si9q167csmnx        alataque_slave.uz8c0c4zj7e4hxlw16d2u7qdp   ajeetraina/apache-jmeter-server:latest   swarmm-agentpublic-31109991000003   Running             Running 13 hours ago
llgxhwo5wvy3        alataque_slave.qms6uf6ut9g2frk414y1jiqv6   ajeetraina/apache-jmeter-server:latest   swarmm-agentpublic-31109991000004   Running             Running 13 hours ago
krehmb64bqj7        alataque_slave.fyv3wz1g785skf9anl59trg5t   ajeetraina/apache-jmeter-server:latest   swarmm-agentpublic-31109991000002   Running             Running 13 hours ago
bfl5e2uc0fq7        alataque_master.1                          ajeetraina/apache-jmeter-master:latest                                       Running             Pending 3 minutes ago
azureuser@swarmm-master-31109991-0:~$

While docker ps shows nothing running on this

azureuser@swarmm-master-31109991-0:~$ docker ps
CONTAINER ID        IMAGE               COMMAND             CREATED             STATUS              PORTS               NAMES
azureuser@swarmm-master-31109991-0:~$

Thanks

ajeetraina commented 7 years ago

You have 3 master and 3 worker node. Now when you create service, you ensure that you scale them to more number of replicas or mark it mode=global so that you can access it on any one of the node. Under your case, you have more nodes but less replicas.

guillemsola commented 7 years ago

I see your point!

I created a swarm cluster too big for my needs 😸

So I put the master to be present on every node with replicas: 3 And I saw that it gets replicated. Also noticed that the desired state is Running but the current is Pending. And maybe that is why there is no master container available for exec.

Is this because the entrypoint for the master container is empty and it just exits?

azureuser@swarmm-master-31109991-0:~/jmeter-docker/apache-jmeter-master$ docker service ps alataque
ID                  NAME                                       IMAGE                                    NODE                                DESIRED STATE       CURRENT STATE           ERROR               PORTS
g07emfynhgve        alataque_slave.fyv3wz1g785skf9anl59trg5t   ajeetraina/apache-jmeter-server:latest   swarmm-agentpublic-31109991000002   Running             Running 8 minutes ago
kij7svbwidei        alataque_slave.uz8c0c4zj7e4hxlw16d2u7qdp   ajeetraina/apache-jmeter-server:latest   swarmm-agentpublic-31109991000003   Running             Running 8 minutes ago
4x4jk7npby3i        alataque_slave.qms6uf6ut9g2frk414y1jiqv6   ajeetraina/apache-jmeter-server:latest   swarmm-agentpublic-31109991000004   Running             Running 8 minutes ago
rnaqlxbatvuo        alataque_master.1                          ajeetraina/apache-jmeter-master:latest                                       Running             Pending 8 minutes ago
d3hqyu1j52an        alataque_master.2                          ajeetraina/apache-jmeter-master:latest                                       Running             Pending 8 minutes ago
m7omr9j7xh2z        alataque_master.3                          ajeetraina/apache-jmeter-master:latest                                       Running             Pending 8 minutes ago
ajeetraina commented 7 years ago

Replicas: 3 just indicates that 3 copies of the task to be created. It doesn't ensure that all the nodes need to have the container running.

Try scaling up the replicas using :

$docker service scale =20

And see if it distributed across the cluster.

If you want all the node to have at least 1 copy of the container, then you need to pass mode: global instead of replicas: 3 under docker-compose.yml

On 08-May-2017 9:29 PM, "guillemsola" notifications@github.com wrote:

I see your point!

I created a swarm cluster too big for my needs 😸

So I put the master to be present on every node with replicats: 3 And I saw that it gets replicated. Also noticed that the desired state is Running but the current is Pending. And maybe that is why there is no master container available for exec.

Is this because the entrypoint for the master container is empty and it just exits?

azureuser@swarmm-master-31109991-0:~/jmeter-docker/apache-jmeter-master$ docker service ps alataque ID NAME IMAGE NODE DESIRED STATE CURRENT STATE ERROR PORTS g07emfynhgve alataque_slave.fyv3wz1g785skf9anl59trg5t ajeetraina/apache-jmeter-server:latest swarmm-agentpublic-31109991000002 Running Running 8 minutes ago kij7svbwidei alataque_slave.uz8c0c4zj7e4hxlw16d2u7qdp ajeetraina/apache-jmeter-server:latest swarmm-agentpublic-31109991000003 Running Running 8 minutes ago 4x4jk7npby3i alataque_slave.qms6uf6ut9g2frk414y1jiqv6 ajeetraina/apache-jmeter-server:latest swarmm-agentpublic-31109991000004 Running Running 8 minutes ago rnaqlxbatvuo alataque_master.1 ajeetraina/apache-jmeter-master:latest Running Pending 8 minutes ago d3hqyu1j52an alataque_master.2 ajeetraina/apache-jmeter-master:latest Running Pending 8 minutes ago m7omr9j7xh2z alataque_master.3 ajeetraina/apache-jmeter-master:latest Running Pending 8 minutes ago

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/ajeetraina/jmeter-docker/issues/1#issuecomment-299909802, or mute the thread https://github.com/notifications/unsubscribe-auth/AATIiFKbVs5Gk-Rtuh2PgEsea7_amvkcks5r3zvQgaJpZM4NSjAT .

guillemsola commented 7 years ago

Still struggling with this 🤒

I have left a single swarm master for simplicity

This way the master for sure keeps in the same machine I am. I boot up the compose but the master is in 0/1 which I understand means that has been created and finished

azureuser@swarmm-master-31109991-0:~/jmeter-docker/apache-jmeter-master$ docker service  ls
ID                  NAME                MODE                REPLICAS            IMAGE                                    PORTS
agc60a1oev8s        myjm_master         replicated          0/1                 ajeetraina/apache-jmeter-master:latest   *:0->60000/tcp
mgzlipx2s7u9        registry            replicated          1/1                 registry:2                               *:5000->5000/tcp
tcc6hmmavb0b        myjm_slave          global              1/3                 ajeetraina/apache-jmeter-server:latest   *:0->50000/tcp,*:0->1099/tcp

My guess is that the entrypoint for the master Dockerfile is empty so that the container starts and simply closes. This way it is not possible to do an exec /bin/bash on it

I have tried to create the master with the jmeter parameters to that it starts to perform the test on start but I cannot find the slave IP's with

$ docker inspect --format '{{ .Name }} => {{ .NetworkSettings.IPAddress }}' $(sudo docker ps -a -q)

as suggested as docker ps -a -q returns nothing

Maybe it is possible to refer the containers using the internal docker DNS system?

thanks!

guillemsola commented 7 years ago

I'm trying with this to found slave IP and pass it in the master image so that it has some entrypoint

docker inspect -f 'myjm_slave.{{.NodeID}}.{{.ID}}' $(docker service ps myjm_slave -q)

Still not working but it sound like a plan to me 😃

What do you think?