Answer a question

Intention is to execute gatling perf tests from command line .Equivalent docker command is

docker run --rm  -w /opt/gatling-fundamentals/ 
tarunkumard/tarungatlingscript:v1.0 
./gradlew gatlingRun-simulations.RuntimeParameters -DUSERS=500 -DRAMP_DURATION=5 -DDURATION=30

Now to map above docker run in Kubernetes using kubectl, I have created a pod for which gradlewcommand.yaml file is below

apiVersion: v1
kind: Pod
metadata:
name: gradlecommandfromcommandline
labels:
purpose: gradlecommandfromcommandline
spec:
containers:
- name: gradlecommandfromcommandline
image: tarunkumard/tarungatlingscript:v1.0
workingDir: /opt/gatling-fundamentals/
command: ["./gradlew"]
args: ["gatlingRun-simulations.RuntimeParameters", "-DUSERS=500", "- 
DRAMP_DURATION=5", "-DDURATION=30"]
restartPolicy: OnFailure

Now pod is created using below command:-

kubectl apply -f gradlewcommand.yaml 

Now comes my actual requirement or question that how do i run or trigger kubectl run command so as to run container inside the above pod created? ,mind you pod name is gradlecommandfromcommandline

Answers

Here is the command which solves the problem:

 kubectl exec gradlecommandfromcommandline -- \
   ./gradlew gatlingRun-simulations.RuntimeParameters \
   -DUSERS=500 -DRAMP_DURATION=5 -DDURATION=30
Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐