kubernetes - Kubernetes Pod 正在将状态从正在运行更改为已完成,我该如何防止这种情况
问题描述
使用创建了一个 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
解决方案
这是使 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
推荐阅读
- python - 将句子列表拆分为单词并将它们附加到字典
- android - Flutter:flutter pub get 和 flutter packages get failed
- twitter-bootstrap - 纱线更新产生警告“> bootstrap@4.6.0”具有不正确的对等依赖性“popper.js@^1.16.1”
- r - 如何根据 R 中的行值删除矩阵的列?
- mysql - 当我尝试在 phpmyadmin 中创建表时,Phpmyadmin 抛出错误“#1067 - 'end_time' 的默认值无效”
- powerbi - 需要有关 PowerBI 可视化和 DAX/查询的帮助 - 按天显示每个作业的利用率
- c# - 如何禁用未选择的阵列并启用选择的阵列?
- ionic3 - 如何添加 Sign In With Apple 插件 Ionic 3
- angular - Angular中的自定义GMT格式日期管道
- ceph - CEPH 池 img - virsh live attach