运行 bash kubernetes pod 中的脚本
Running bash script in a kubernetes pod
我正在尝试 运行 使用以下 yaml 文件的外部 bash 脚本。
该脚本位于 /scripts/run.sh 文件夹中。我也给了 defaultMode: 0777
这是我得到的错误。
sh: 0: Can't open /scripts/run.sh
apiVersion: v1
data:
script.sh: |-
echo "Hello world!"
kubectl get pods
kind: ConfigMap
metadata:
name: script-configmap
---
apiVersion: batch/v1
kind: Job
metadata:
labels:
app: script-job
name: script-job
spec:
backoffLimit: 2
template:
spec:
containers:
- command:
- sh
- /scripts/run.sh
image: 'bitnami/kubectl:1.12'
name: script
volumeMounts:
- name: script-configmap
mountPath: /scripts
subPath: run.sh
readOnly: false
restartPolicy: Never
volumes:
- name: script-configmap
configMap:
name: script-configmap
defaultMode: 0777
文件名是 script.sh
而不是 run.sh
尝试
containers:
- command:
- sh
- /scripts/script.sh
我正在尝试 运行 使用以下 yaml 文件的外部 bash 脚本。
该脚本位于 /scripts/run.sh 文件夹中。我也给了 defaultMode: 0777
这是我得到的错误。
sh: 0: Can't open /scripts/run.sh
apiVersion: v1
data:
script.sh: |-
echo "Hello world!"
kubectl get pods
kind: ConfigMap
metadata:
name: script-configmap
---
apiVersion: batch/v1
kind: Job
metadata:
labels:
app: script-job
name: script-job
spec:
backoffLimit: 2
template:
spec:
containers:
- command:
- sh
- /scripts/run.sh
image: 'bitnami/kubectl:1.12'
name: script
volumeMounts:
- name: script-configmap
mountPath: /scripts
subPath: run.sh
readOnly: false
restartPolicy: Never
volumes:
- name: script-configmap
configMap:
name: script-configmap
defaultMode: 0777
文件名是 script.sh
而不是 run.sh
尝试
containers:
- command:
- sh
- /scripts/script.sh