初始化容器未在kubernetes中初始化

时间:2019-07-31 15:17:15

标签: kubernetes

我正在尝试从Yaml中的gitlab检索一些代码。 不幸的是,这项工作未能激发豆荚。我已经检查了所有日志,但失败,并显示以下消息:

0 container "filter-human-genome-and-create-mapping-stats" in pod "create-git-container-5lhp2" is waiting to start: PodInitializing

这是Yaml文件:

apiVersion: batch/v1
kind: Job
metadata:
  name: create-git-container
  namespace: diag
spec:
  template:
    spec:
      initContainers:
        - name:  bash-script-git-downloader
          image: alpine/git
          volumeMounts:
            - mountPath: /bash_scripts
              name: bash-script-source
          command: ["/bin/sh","-c"]
          args: ["git", "clone", "https://.......@gitlab.com/scripts.git" ]
      containers:
        - name: filter-human-genome-and-create-mapping-stats
          image: myimage
           env:
             - name: OUTPUT
               value: "/output"
          command: ["ls"]
         volumeMounts:
           - mountPath: /bash_scripts
             name: bash-script-source
           - mountPath: /output
             name: output
      volumes:
        - name: bash-script-source
          emptyDir: {}
        - name: output
          persistentVolumeClaim:
            claimName: output
      restartPolicy: Never

1 个答案:

答案 0 :(得分:2)

如果使用bash -c,则只需要一个参数。因此,您必须将args[]作为一个参数传递。有多种方法可以做到:

command: ["/bin/sh","-c"]
args: ["git clone https://.......@gitlab.com/scripts.git"]

command: ["/bin/sh","-c", "git clone https://.......@gitlab.com/scripts.git"]

args: ["/bin/sh","-c", "git clone https://.......@gitlab.com/scripts.git"]

command:
- /bin/sh
- -c
- |
  git clone https://.......@gitlab.com/scripts.git

args:
- /bin/sh
- -c
- |
  git clone https://.......@gitlab.com/scripts.git