从 Init Container 中执行的 Python 脚本创建 Kubernetes Pod 失败?

问题描述 投票:0回答:1

是否有可能通过从 Init 容器执行的 Python 脚本失败/终止 Pod 创建?

初始化容器:

apiVersion: v1
kind: Pod
metadata:
  name: myapp-pod
  labels:
    app.kubernetes.io/name: MyApp
spec:
  containers:
  - name: myapp-container
    image: busybox:1.28
    command: ['sh', '-c', 'echo The app is running! && sleep 3600']
  initContainers:
  - name: init-myservice
    image: busybox:1.28
    command: ["python3", "/scripts/example.py"]

示例.py

What would this Python script contain?

谢谢!

kubernetes
1个回答
0
投票

从 Python 脚本失败/终止 pod 创建

尝试:

command: ["python3", "-c", "import sys; sys.exit(1)"]

© www.soinside.com 2019 - 2024. All rights reserved.