Skip to content

Instantly share code, notes, and snippets.

@ondrejmo
Created October 29, 2021 09:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ondrejmo/8928807c9d1c9f67bb567c338078784c to your computer and use it in GitHub Desktop.
Save ondrejmo/8928807c9d1c9f67bb567c338078784c to your computer and use it in GitHub Desktop.
Drone CI pipeline for building multiplatform images with kube-runner and podman
---
kind: pipeline
type: kubernetes
name: linux-amd64
trigger:
ref:
include:
- refs/tags/myapp-*
event:
- tag
- custom
node_selector:
kubernetes.io/arch: amd64
clone:
skip_verify: yes
depth: 1
steps:
- name: build & push
image: quay.io/podman/stable:v3.3.1
privileged: yes
commands:
- |
cat > /etc/containers/registries.conf.d/wolfpack.conf <<EOF
[[registry]]
location="registry.local:5000"
insecure=true
EOF
- podman build -t myapp:${DRONE_TAG##*-}-linux-amd64 .
- podman push myapp:${DRONE_TAG##*-}-linux-amd64 docker://registry.local:5000/myapp:${DRONE_TAG##*-}-linux-amd64
---
kind: pipeline
type: kubernetes
name: linux-arm64
trigger:
ref:
include:
- refs/tags/myapp-*
event:
- tag
- custom
node_selector:
kubernetes.io/arch: arm64
clone:
skip_verify: yes
depth: 1
steps:
- name: build & push
image: quay.io/podman/stable:v3.3.1
privileged: yes
commands:
- |
cat > /etc/containers/registries.conf.d/wolfpack.conf <<EOF
[[registry]]
location="registry.local:5000"
insecure=true
EOF
- podman build -t myapp:${DRONE_TAG##*-}-linux-arm64 .
- podman push myapp:${DRONE_TAG##*-}-linux-arm64 docker://registry.local:5000/myapp:${DRONE_TAG##*-}-linux-arm64
---
kind: pipeline
type: kubernetes
name: manifest
trigger:
ref:
include:
- refs/tags/myapp-*
event:
- tag
- custom
clone:
disable: yes
steps:
- name: create & push
image: quay.io/podman/stable:v3.3.1
privileged: true
commands:
- |
cat > /etc/containers/registries.conf.d/wolfpack.conf <<EOF
[[registry]]
location="registry.local:5000"
insecure=true
EOF
- podman manifest create myapp:${DRONE_TAG##*-} registry.local:5000/myapp:${DRONE_TAG##*-}-linux-amd64 registry.local:5000/myapp:${DRONE_TAG##*-}-linux-arm64
- podman manifest push myapp:${DRONE_TAG##*-} docker://registry.local:5000/myapp:${DRONE_TAG##*-}
depends_on:
- linux-amd64
- linux-arm64
@ondrejmo
Copy link
Author

Better version of https://gist.github.com/ondrejmo/2cf8e1a6d9b016a95a5b440cd926b6fd

Improvements

  • docker-free (at least if your cluster runs on cri-o)
  • fewer containers, as it doesn't need docker-in-docker
  • kube-runner instead of docker-runner

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment