Kubernetes job initcontainer

这个模型主要用来做编译部署、编译导入

init 容器可以使用 git 下载代码到 emptyDir,然后由主容器来 build

apiVersion: batch/v1
kind: Job
metadata:
  generateName: test-
  namespace: default
spec:
  backoffLimit: 6
  completions: 1
  parallelism: 1
  template:
    spec:
      initContainers:
        - name: init
          image: ubuntu
          imagePullPolicy: IfNotPresent
          command: ["touch","/tmp/test.txt"]
          volumeMounts:
            - name: mytmp
              mountPath: "/tmp"
      containers: 
        - name: test
          image: ubuntu
          command: ["ls", "/tmp"]
          volumeMounts:
            - name: mytmp
              mountPath: "/tmp"
          imagePullPolicy: IfNotPresent
      dnsPolicy: ClusterFirst
      restartPolicy: Never
      schedulerName: default-scheduler
      securityContext: {}
      terminationGracePeriodSeconds: 30
      volumes:
      - name: mytmp
        emptyDir: {}
Send a Message