-1

I am trying to execute a pre install job using helm charts. Can someone help getting result of command (parameter in yaml file) that I put in the below file:

apiVersion: batch/v1
kind: Job
metadata:
  name: pre-install-job
  annotations:
    "helm.sh/hook": "pre-install"
spec:
  template:
    spec:
      containers:
      - name: pre-install
        image: busybox
        imagePullPolicy: IfNotPresent
        command: ['sh', '-c', 'touch somefile.txt && echo $PWD && sleep 15']
      restartPolicy: OnFailure
      terminationGracePeriodSeconds: 0

  backoffLimit: 3
  completions: 1
  parallelism: 1 

I want to know where somefile.txt is created and echo is printed. And the reason I know it is working because "sleep 15" works. I see a 15 second difference in start and end time of pod creation.

1 Answers1

2

Any file you create in a container environment is created inside the container filesystem. Unless you've mounted some storage into the container, the file will be lost as soon as the container exits.

Anything a Kubernetes process writes to its stdout will be captured by the Kubernetes log system. You can retrieve it using kubectl logs pre-install-job-... -c pre-install.

David Maze
  • 130,717
  • 29
  • 175
  • 215
  • Thanks, I was able to see the the result of echo. Issue was the pod gets completed so I couldn't get the interactive shell to check whether my file was created or not. – Rohit Ratnesh Sep 01 '21 at 05:46