Post

Kaniko

Kaniko

Kaniko is a tool to build container images from a Dockerfile, inside a container or Kubernetes cluster.

kaniko doesn’t depend on a Docker daemon and executes each command within a Dockerfile completely in userspace. This enables building container imagesin environments that can’t easily or securely run a Docker daemon, such as a standard Kubernetes cluster.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
root@scw-k8s-cmdx:~# cat kaniko-pod.yaml
---
apiVersion: v1
data:
  REGISTRY_IP: 51.15.247.30
kind: ConfigMap
metadata:
  creationTimestamp: null
  name: registry-cm

---
apiVersion: v1
data:
  Dockerfile: |-
    FROM nginx:alpine
    RUN echo "Kaniko dude!" > /usr/share/nginx/html/index.html
kind: ConfigMap
metadata:
  name: dockerfile
  namespace: default

---
apiVersion: v1
kind: Pod
metadata:
  name: kaniko
spec:
  containers:
  - name: kaniko
    image: gcr.io/kaniko-project/executor:latest
    args: [ "--verbosity=debug",
            "--insecure",
            "--dockerfile=/workspace/Dockerfile",
            "--context=dir://workspace",
            "--destination=$(REGISTRY_IP):5000/supercool:1.0"]
    env:
      - name: REGISTRY_IP
        valueFrom:
          configMapKeyRef:
            name: registry-cm
            key: REGISTRY_IP
    volumeMounts:
      - name: dockerfile-cm
        mountPath: /workspace
  restartPolicy: Never
  volumes:
    - name: dockerfile-cm
      configMap:
        name: dockerfile
        items:
        - key: "Dockerfile"
          path: "Dockerfile"


See whether a container was pushed
1
root@scw-k8s-cmdx:~# curl -X GET http://$(curl ifconfig.me):5000/v2/_catalog
This post is licensed under CC BY 4.0 by the author.