How to Make Kubectl run a container after pod is c

2019-08-13 16:15发布

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

1条回答
闹够了就滚
2楼-- · 2019-08-13 16:57

Here is the command which solves the problem:

 kubectl exec gradlecommandfromcommandline -- \
   ./gradlew gatlingRun-simulations.RuntimeParameters \
   -DUSERS=500 -DRAMP_DURATION=5 -DDURATION=30
查看更多
登录 后发表回答