0

我在 docker for windows 上使用 kubernetes。
我想使用 Kaniko,但我无法在本地 kubernetes 上构建图像。

Dockerfile

FROM ubuntu:18.04
RUN apt update
RUN apt install -y ssh

kanikopod.yaml

apiVersion: v1
kind: Pod
metadata:
  name: kaniko
spec:
  containers:
    - image: gcr.io/kaniko-project/executor:latest
      args: 
      - --dockerfile=/mnt/Dockerfile 
      - --context= /mnt
      - --no-push
      name: kaniko
      command:
        - sleep
        - infinity
      volumeMounts:
        - mountPath: /mnt
          name: mount-volume

  restartPolicy: Never
  volumes:
    - name: mount-volume
      persistentVolumeClaim:
        claimName: kaniko-workspace

但是发生了 ContainerCannotRun 错误。

kubectl describe pods kaniko
结果是

Name:               kaniko
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               docker-desktop/192.168.65.3
Start Time:         Mon, 06 May 2019 18:13:47 +0900
Labels:             <none>
Annotations:        kubectl.kubernetes.io/last-applied-configuration:
                      {"apiVersion":"v1","kind":"Pod","metadata":{"annotations":{},"name":"kaniko","namespace":"default"},"spec":{"containers":[{"args":["--dock...
Status:             Pending
IP:
Containers:
  kaniko:
    Container ID:
    Image:         gcr.io/kaniko-project/executor:latest
    Image ID:
    Port:          <none>
    Host Port:     <none>
    Command:
      sleep
      infinity
    Args:
      --dockerfile=/mnt/Dockerfile
      --context= /mnt
      --no-push
    State:          Waiting
      Reason:       ContainerCreating
    Ready:          False
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /mnt from mount-volume (rw)
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-spjnr (ro)
Conditions:
  Type              Status
  Initialized       True
  Ready             False
  ContainersReady   False
  PodScheduled      True
Volumes:
  mount-volume:
    Type:       PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace)
    ClaimName:  kaniko-workspace
    ReadOnly:   false
  default-token-spjnr:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-spjnr
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:
  Type    Reason     Age   From               Message
  ----    ------     ----  ----               -------
  Normal  Scheduled  4s    default-scheduler  Successfully assigned default/kaniko to docker-desktop

kubectl logs kaniko
但是没有输出。

我认为 kaniko 需要“--destination=”选项,但我找不到信息。
我应该怎么办?

4

1 回答 1

1

尝试删除此行:

  command:
    - sleep
    - infinity
于 2019-05-06T10:11:22.043 回答