Configuring a Linux image sourced from CoreWeave Cloud
Objective: Use our Packer Virtual Server to configure a Linux image from CoreWeave Cloud.
Overview: Combining examples from Configuring a Windows Image sourced from CoreWeave Cloud and Configuring an externally sourced cloud Linux image, we will use our Packer Worker Virtual Server to configure a Linux image sourced from CoreWeave Cloud.
References:
Selecting a source image
Following the example in Copying CoreWeave Images to a Writeable PVC, we will search for the latest CentOS image in the vd-images namespace:
We will then clone this image into our namespace:
apiVersion: cdi.kubevirt.io/v1beta1kind: DataVolumemetadata:annotations:labels:name: centos7-docker-master-clone-20210813-ord1namespace: tenant-<name>spec:pvc:accessModes:- ReadWriteOnceresources:requests:storage: 40GistorageClassName: block-nvme-ord1volumeMode: Blocksource:pvc:name: centos7-docker-master-20210813-ord1namespace: vd-images
Setting up the Packer Environment
Following the example in Creating a Packer Worker Virtual Server, we'll mount our CentOS PVC as an additional disk:
additionalDisks:- name: CentOS_7spec:persistentVolumeClaim:claimName: centos7-docker-master-clone-20210813-ord1
Configuring the Packer manifest
Our Packer manifest will be a combination of our previous Windows and Ubuntu examples:
{"builders": [{"type": "qemu","accelerator": "kvm","communicator": "ssh","headless": true,"disk_image": false,"cpus": "6","memory": "16384","format": "raw","iso_checksum": "none","iso_url": "/dev/vdb","skip_resize_disk": false,"skip_compaction": false,"disk_size": "40000M","qemuargs": [["-machine","pc-q35-4.2,accel=kvm,usb=off,vmport=off,dump-guest-core=off"],["-cpu", "host"],[ "-smp", "cpus=4,sockets=1" ],[ "-cdrom", "cidata.iso" ],["-drive", "file=/dev/vdb"]],"ssh_username": "user","ssh_password": "packer","net_device": "virtio-net","shutdown_command": "sudo shutdown --poweroff --no-wall now"}],"provisioners": [{"type": "shell","execute_command": "{{.Vars}} sudo -S -E bash '{{.Path}}'","inline": ["yum update -y","yum upgrade -y","yum clean all -y"]}]}
/dev/vdb refers to our cloned block device
The credentials in this configuration are created when the VM reads the image output of create-ci-data.sh
In this example, we are using the shell provisioner to install package updates. To learn more and view more provisioners, view Hashicorp's documentation.
Execute Packer docker image
Similar to our Windows example, we'll kick off our CentOS build with launch-docker.sh win.json
. Since we're writing to our PVC directly, all changes are made directly to our cloned disk.