创建pod后如何使Kubectl运行容器 [英] How to Make Kubectl run a container after pod is created
问题描述
目的是从命令行执行加特林性能测试.等效的docker命令是
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
现在要使用kubectl映射在Kubernetes中运行的docker上方,我创建了一个pod,其gradlewcommand.yaml文件位于下面
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
现在是我的实际要求或问题,我该如何运行或触发kubectl run命令以便在上面创建的容器中运行容器? ,请注意,您的广告连播名称是来自命令行的gradlecommand
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
推荐答案
以下是解决该问题的命令:
Here is the command which solves the problem:
kubectl exec gradlecommandfromcommandline -- \
./gradlew gatlingRun-simulations.RuntimeParameters \
-DUSERS=500 -DRAMP_DURATION=5 -DDURATION=30
这篇关于创建pod后如何使Kubectl运行容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!