0

使用创建了一个 pod yaml,一旦创建了 pod,我kubectl exec就会运行我的 gatling perf 测试代码

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

但这将在 kubectl 控制台结束,并显示以下消息:-

命令以退出代码 137 终止

在调查中,它发现 pod 正在从运行状态更改为已完成阶段。

我如何增加 pod 的寿命,以便它等待我的命令被执行。这里是 pod 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
4

1 回答 1

2

这是使 pod 始终运行的 yaml 文件 apiVersion: v1

kind: Pod
metadata:
name: gradlecommandfromcommandline
labels:
purpose: gradlecommandfromcommandline
spec:
volumes:
- name: docker-sock
  hostPath:
    path: /home/vagrant/k8s/pods/gatling/user-files/simulations    # A file or 
directory location on the node that you want to mount into the Pod
  #  command: [ "git clone https://github.com/TarunKDas2k18/PerfGatl.git" ]
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"]

- name: gatlingperftool
  image: tarunkumard/gatling:FirstScript     # Run the ubuntu 16.04
  command: [ "/bin/bash", "-c", "--" ]       # You need to run some task inside a 
  container to keep it running
  args: [ "while true; do sleep 10; done;" ] # Our simple program just sleeps inside 
  an infinite loop
  volumeMounts:
    - mountPath: /opt/gatling/user-files/simulations     # The mount path within the 
  container
      name: docker-sock                   # Name must match the hostPath volume name
  ports:
    - containerPort: 80
于 2018-12-13T15:04:28.880 回答