Skip to content

Commit

Permalink
Create download-ubuntu-2204.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsn0w authored Sep 28, 2024
1 parent 59a093a commit bad9b17
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions download-ubuntu-2204.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
---
apiVersion: v1
kind: ConfigMap
metadata:
name: download-image
data:
entrypoint.sh: |-
#!/usr/bin/env bash
# This script is designed to download a cloud image file (.img) and then convert it to a .raw.gz file.
# This is purpose built so non-raw cloud image files can be used with the "image2disk" action.
# See https://artifacthub.io/packages/tbaction/tinkerbell-community/image2disk.
set -euxo pipefail
if ! which pigz qemu-img &>/dev/null; then
apk add --update pigz qemu-img
fi
image_url=$1
file=$2/${image_url##*/}
file=${file%.*}.raw.gz
if [[ ! -f "$file" ]]; then
wget "$image_url" -O image.img
qemu-img convert -O raw image.img image.raw
pigz <image.raw >"$file"
rm -f image.img image.raw
fi
---
apiVersion: batch/v1
kind: Job
metadata:
name: download-ubuntu-jammy
spec:
template:
spec:
containers:
- name: download-ubuntu-jammy
image: bash:5.2.2
command: ["/script/entrypoint.sh"]
args:
[
"https://cloud-images.ubuntu.com/daily/server/jammy/current/jammy-server-cloudimg-amd64.img",
"/output",
]
volumeMounts:
- mountPath: /output
name: hook-artifacts
- mountPath: /script
name: configmap-volume
restartPolicy: OnFailure
volumes:
- name: hook-artifacts
hostPath:
path: /opt/hook
type: DirectoryOrCreate
- name: configmap-volume
configMap:
defaultMode: 0700
name: download-image

0 comments on commit bad9b17

Please sign in to comment.