How to use Kaniko on the local kubernetes

5/6/2019

I use kubernetes on docker for windows.
And I want to use Kaniko but I could not build an image on local 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

But ContainerCannotRun error occurred.

kubectl describe pods kaniko
result is

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
But there was no output.

I think "--destination=" option is needed for kaniko, but I cannot find the information.
What should I do?

-- k_trader
docker
kaniko
kubernetes

1 Answer

5/6/2019

Try to remove this lines:

  command:
    - sleep
    - infinity
-- Vasily Angapov
Source: StackOverflow