小编dav*_*amp的帖子

if 语句中的 kubernetes livenessprobe exec 命令环境变量不起作用

我在获取 kubernetes livenessProbe exec 命令来处理环境变量时遇到困难。\n我的目标是让 liveness 探针监视 pod 上的内存使用情况并执行 httpGet 运行状况检查。

\n

“如果容器内存使用量超过资源限制的 90% 或 http 响应代码/health失败,则探测应该失败。”

\n

活性探针配置如下:

\n
\nlivenessProbe:\n  exec:\n    command:\n    - sh\n    - -c\n    - |-\n      "used=$(awk '{ print int($1/1.049e+6) }' /sys/fs/cgroup/memory/memory.usage_in_bytes);\n      thresh=$(awk '{ print int( $1 / 1.049e+6 * 0.9 ) }' /sys/fs/cgroup/memory/memory.limit_in_bytes);\n      health=$(curl -s -o /dev/null --write-out "%{http_code}" http://localhost:8080/health);\n      if [[ ${used} -gt ${thresh} || ${health} -ne 200 ]]; then exit 1; fi"\n  initialDelaySeconds: 240\n  periodSeconds: 60\n  failureThreshold: 3\n  timeoutSeconds: 10\n\n
Run Code Online (Sandbox Code Playgroud)\n

如果我执行到(ubuntu)pod并运行这些命令,它们都可以正常工作并完成工作。 …

kubernetes livenessprobe

5
推荐指数
2
解决办法
1万
查看次数

标签 统计

kubernetes ×1

livenessprobe ×1