Running bash script in a kubernetes pod

jeril

I am trying to run an external bash script using the below yaml file.

The script is inside the /scripts/run.sh folder. I have also given the defaultMode: 0777

This is the error I get.

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
Yuri G.

The file name is script.sh and not run.sh

Try

containers:
    - command:
        - sh
        - /scripts/script.sh

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

Running a command in a new terminal instance in a bash script

分類Dev

Kubernetes Horizontal Pod Autoscaler(HPA)テスト

分類Dev

how to stop/pause a pod in kubernetes

分類Dev

Variable notation when running python commands with arguments in a bash script

分類Dev

pod install -bash: pod: command not found

分類Dev

Can I mount a GCS bucket inside Kubernetes Pod?

分類Dev

Access built-in etcd within kubernetes pod container

分類Dev

Prometheus with multi-container pod on kubernetes

分類Dev

Azure Kubernetes - not able to connect pod containers

分類Dev

how to modify pod memory limit of a running pod

分類Dev

Save file to Kubernetes pod during deployment

分類Dev

Keep process running on remote machine after exiting ssh session inside bash script

分類Dev

Two containers within same pod on Kubernetes

分類Dev

Kubernetes pod auto-scaling

分類Dev

Monitor custom kubernetes pod metrics using Prometheus

分類Dev

snipeit on kubernetes not running

分類Dev

How to Configure Pod initialization in a specific order in Kubernetes?

分類Dev

Kubernetes - Get EBS Volume of a Pod

分類Dev

Can volumeMounts: in kubernetes pod be optional

分類Dev

Kubernetes MLflow Service Pod Connection

分類Dev

How to connect to a private IP from Kubernetes Pod

分類Dev

Script not running at startup

分類Dev

Block all default commands while a bash script are running?

分類Dev

How to change bash script output when the script is running?

分類Dev

Script running only once

分類Dev

Running a bash script to append .csv to files in a subdirectory moved/delted all files from computer

分類Dev

Running a bash script from an xsession to toggle startup programs

分類Dev

Helping with this jquery script that is not running

分類Dev

Running a shell script with and without "bash" command

Related 関連記事

  1. 1

    Running a command in a new terminal instance in a bash script

  2. 2

    Kubernetes Horizontal Pod Autoscaler(HPA)テスト

  3. 3

    how to stop/pause a pod in kubernetes

  4. 4

    Variable notation when running python commands with arguments in a bash script

  5. 5

    pod install -bash: pod: command not found

  6. 6

    Can I mount a GCS bucket inside Kubernetes Pod?

  7. 7

    Access built-in etcd within kubernetes pod container

  8. 8

    Prometheus with multi-container pod on kubernetes

  9. 9

    Azure Kubernetes - not able to connect pod containers

  10. 10

    how to modify pod memory limit of a running pod

  11. 11

    Save file to Kubernetes pod during deployment

  12. 12

    Keep process running on remote machine after exiting ssh session inside bash script

  13. 13

    Two containers within same pod on Kubernetes

  14. 14

    Kubernetes pod auto-scaling

  15. 15

    Monitor custom kubernetes pod metrics using Prometheus

  16. 16

    snipeit on kubernetes not running

  17. 17

    How to Configure Pod initialization in a specific order in Kubernetes?

  18. 18

    Kubernetes - Get EBS Volume of a Pod

  19. 19

    Can volumeMounts: in kubernetes pod be optional

  20. 20

    Kubernetes MLflow Service Pod Connection

  21. 21

    How to connect to a private IP from Kubernetes Pod

  22. 22

    Script not running at startup

  23. 23

    Block all default commands while a bash script are running?

  24. 24

    How to change bash script output when the script is running?

  25. 25

    Script running only once

  26. 26

    Running a bash script to append .csv to files in a subdirectory moved/delted all files from computer

  27. 27

    Running a bash script from an xsession to toggle startup programs

  28. 28

    Helping with this jquery script that is not running

  29. 29

    Running a shell script with and without "bash" command

ホットタグ

アーカイブ