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

4

1 回答 1

2

您在容器环境中创建的任何文件都是在容器文件系统中创建的。除非您已将一些存储安装到容器中,否则该文件将在容器退出后立即丢失。

Kubernetes 进程写入其标准输出的任何内容都将被 Kubernetes 日志系统捕获。您可以使用kubectl logs pre-install-job-... -c pre-install.

于 2021-08-20T12:05:10.323 回答