如何使Kubectl运行一个容器中创建吊舱后,(How to Make Kubectl run a

2019-10-16 12:16发布

意图是从执行命令行格林PERF的测试.Equivalent搬运工命令是

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

我们上面的映射在码头工人使用Kubernetes运行kubectl,我创建了一个吊舱,其gradlewcommand.yaml文件如下

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

现在吊舱使用以下命令创建: -

kubectl apply -f gradlewcommand.yaml 

现在到了我的实际需求或疑问,如何运行或触发kubectl运行命令,以便运行中创建的上述吊舱内的容器? ,你要知道窗格名称是gradlecommandfromcommandline

Answer 1:

这里是一个解决问题的命令:

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


文章来源: How to Make Kubectl run a container after pod is created