{"id":67,"date":"2018-11-16T15:01:28","date_gmt":"2018-11-16T15:01:28","guid":{"rendered":"http:\/\/boernig.de\/wordpress\/?p=67"},"modified":"2018-11-16T15:45:32","modified_gmt":"2018-11-16T15:45:32","slug":"run-a-defined-workload-on-a-docker-or-kubernetes-environment","status":"publish","type":"post","link":"http:\/\/boernig.de\/wordpress\/2018\/11\/16\/run-a-defined-workload-on-a-docker-or-kubernetes-environment\/","title":{"rendered":"Run a defined workload on a Docker or Kubernetes environment"},"content":{"rendered":"<p>Sometimes you want to stress test a container environment or you are measuring CPU and memory in such an environment and you want to test, of your metrics reporting is correct.<\/p>\n<h2>Introducing docker-stress<\/h2>\n<p>This small tool allows to gauge metrics reporting using the\u00a0 simple command line utility &#8220;stress&#8221; inside a docker container.<\/p>\n<p>The needed Dockerfile can be found in this repository:<\/p>\n<pre><a href=\"https:\/\/github.com\/iboernig\/docker-stress\/\">https:\/\/github.com\/iboernig\/docker-stress\/<\/a><\/pre>\n<p>One can use this tool on a local container host or on a Kubernetes cluster. I will show podman for local deployment and OpenShift for the cluster deployment here.<\/p>\n<h3>Local usage with podman (or docker if you wish)<\/h3>\n<p>For the local deployment i will use &#8220;podman&#8221; here. As a proud Fedora user, I use the native and easiest tool that can be used by a normal user with no special rights to work with containers locally. If you need more information to podman have a look here:\u00a0<a href=\"https:\/\/podman.io\/\">https:\/\/podman.io\/<\/a>.<\/p>\n<p>If you prefer docker to podman, feel free to use docker. the command line is exactly the same.<\/p>\n<p>To start, clone the repository:<\/p>\n<pre>[iboernig@t470 Projects]$ git clone https:\/\/github.com\/iboernig\/docker-stress.git\r\n[iboernig@t470 Projects]$ cd docker-stress\/<\/pre>\n<p>Build locally using podman (you can use &#8220;docker&#8221; with the same arguments, if you do not have podman)<\/p>\n<pre>[iboernig@t470 Projects]$ podman build -t stress .\r\nSTEP 1: FROM fedora:latest\r\nSTEP 2: RUN yum -y install stress procps-ng \r\n--&gt; Using cache 8f2c95619aeb7799ae9806fd94d83605f894a458d344659910240092ed7efc4d\r\nSTEP 3: FROM 8f2c95619aeb7799ae9806fd94d83605f894a458d344659910240092ed7efc4d\r\n^[[OSTEP 4: ENV CPU_LOAD=1 MEM_LOAD=1 MEM_SIZE=256M\r\n--&gt; Using cache 401365dae085f9a53d39e2eb6a2a14e6b21129d0e19d9f75a16503fc780b2bd5\r\nSTEP 5: FROM 401365dae085f9a53d39e2eb6a2a14e6b21129d0e19d9f75a16503fc780b2bd5\r\nSTEP 6: CMD stress --cpu $CPU_LOAD --vm $MEM_LOAD --vm-bytes $MEM_SIZE\r\n--&gt; Using cache 8f71320d0ecad024efcbf98be0504eaf3354c08e6469e76a028c6f3b55e0bc95\r\nSTEP 7: COMMIT<\/pre>\n<p>and then run it:<\/p>\n<pre>[iboernig@t470 docker-stress]$ podman run -it -rm stress \r\nstress: info: [1] dispatching hogs: 1 cpu, 0 io, 1 vm, 0 hdd<\/pre>\n<p>You can change the parameters by setting the enviroment variables:<\/p>\n<pre>[iboernig@t470 docker-stress]$ podman run -it -rm -e CPU_LOAD=2 -e MEM_LOAD=1 -e MEM_SIZE=512M stress\r\nstress: info: [1] dispatching hogs: 2 cpu, 0 io, 1 vm, 0 hdd<\/pre>\n<p>Note that each number of CPU_LOAD and each number of MEM_LOAD allocates one thread. The memory in the variable MEM_SIZE is the size one MEM_LOAD thread consumes. So if you use more than one, you will consume a multiple of MEM_SIZE memory. For more infomation see &#8220;man stress&#8221;.<\/p>\n<h3>Cluster deployment in OpenShift<\/h3>\n<p>In OpenShift you only have to define a new app based on this repository:<\/p>\n<pre>oc new-app https:\/\/github.com\/iboernig\/docker-stress.git<\/pre>\n<p>OpenShift then pulls the repository, starts a docker build and deploys the image in one go.<\/p>\n<p>If you need to tune the parameters you can do so by adding the environment variable to the deplyoment config. Either in the webconsole or by changing the deploymentconfig manually:<\/p>\n<pre>oc set env dc\/docker-stress CPU_LOAD=2 MEM_LOAD=1 MEM_SIZE=512M<\/pre>\n<p>Happy stressing!<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Sometimes you want to stress test a container environment or you are measuring CPU and memory in such an environment and you want to test, of your metrics reporting is correct. Introducing docker-stress This small tool allows to gauge metrics reporting using the\u00a0 simple command line utility &#8220;stress&#8221; inside a docker container. The needed Dockerfile &hellip; <a href=\"http:\/\/boernig.de\/wordpress\/2018\/11\/16\/run-a-defined-workload-on-a-docker-or-kubernetes-environment\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Run a defined workload on a Docker or Kubernetes environment&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,4,10,11],"tags":[],"_links":{"self":[{"href":"http:\/\/boernig.de\/wordpress\/wp-json\/wp\/v2\/posts\/67"}],"collection":[{"href":"http:\/\/boernig.de\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/boernig.de\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/boernig.de\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/boernig.de\/wordpress\/wp-json\/wp\/v2\/comments?post=67"}],"version-history":[{"count":2,"href":"http:\/\/boernig.de\/wordpress\/wp-json\/wp\/v2\/posts\/67\/revisions"}],"predecessor-version":[{"id":69,"href":"http:\/\/boernig.de\/wordpress\/wp-json\/wp\/v2\/posts\/67\/revisions\/69"}],"wp:attachment":[{"href":"http:\/\/boernig.de\/wordpress\/wp-json\/wp\/v2\/media?parent=67"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/boernig.de\/wordpress\/wp-json\/wp\/v2\/categories?post=67"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/boernig.de\/wordpress\/wp-json\/wp\/v2\/tags?post=67"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}