- First install a k3s cluster or any other k8s distribution Make sure to use INSTALL_K3S_VERSION="v.1.27.10+k3s1" as k3s version https://docs.k3s.io/quick-start
- than install helm https://helm.sh/docs/intro/install/#through-package-managers
- use helm to install rancher https://ranchermanager.docs.rancher.com/getting-started/quick-start-guides/deploy-rancher-manager/helm-cli
- acces the webui and setup password
- setup the proxmox-ui-cluster https://github.com/cuza/rancher-ui-driver-proxmoxve?tab=readme-ov-file#using-the-proxmox-ve-ui-driver
- use the script inside the gist taken from here and create a new template. ! make SURE you have libguestfs-tools
Last active
January 30, 2024 10:21
-
-
Save 7h3730B/e0dc270d66abefa06822392e27df503b to your computer and use it in GitHub Desktop.
create_template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -xeu | |
export IMGID=9007 | |
export BUILD_DAY="20240102-1614" | |
export BASE_IMG="debian-12-genericcloud-amd64-${BUILD_DAY}.qcow2" | |
export IMG="debian-12-genericcloud-amd64-${IMGID}.qcow2" | |
export STORAGEID="local" | |
if [ ! -f "${BASE_IMG}" ];then | |
wget https://cloud.debian.org/images/cloud/bookworm/${BUILD_DAY}/${BASE_IMG} | |
fi | |
if [ ! -f "${IMG}" ];then | |
cp -f "${BASE_IMG}" "${IMG}" | |
fi | |
# if [ ! -f "/mnt/tmp" ];then | |
# mkdir /mnt/tmp | |
# fi | |
# prepare mounts | |
guestmount -a ${IMG} -m /dev/sda1 /mnt/tmp/ | |
mount --bind /dev/ /mnt/tmp/dev/ | |
mount --bind /proc/ /mnt/tmp/proc/ | |
# add dns server | |
rm /mnt/tmp/etc/resolv.conf | |
echo "nameserver 1.1.1.1" > /mnt/tmp/etc/resolv.conf | |
echo "nameserver 8.8.4.4" >> /mnt/tmp/etc/resolv.conf | |
echo "151.101.246.132 deb.debian.org" >> /mnt/tmp/etc/hosts | |
# install desired apps | |
chroot /mnt/tmp /bin/bash -c "apt-get update" | |
chroot /mnt/tmp /bin/bash -c "DEBIAN_FRONTEND=noninteractive apt-get install -y net-tools curl qemu-guest-agent nfs-common open-iscsi lsscsi sg3-utils multipath-tools scsitools" | |
# https://www.electrictoolbox.com/sshd-hostname-lookups/ | |
sed -i 's:#UseDNS no:UseDNS no:' /mnt/tmp/etc/ssh/sshd_config | |
sed -i '/package-update-upgrade-install/d' /mnt/tmp/etc/cloud/cloud.cfg | |
cat > /mnt/tmp/etc/cloud/cloud.cfg.d/99_custom.cfg << '__EOF__' | |
#cloud-config | |
# Install additional packages on first boot | |
# | |
# Default: none | |
# | |
# if packages are specified, this apt_update will be set to true | |
# | |
# packages may be supplied as a single package name or as a list | |
# with the format [<package>, <version>] wherein the specifc | |
# package version will be installed. | |
#packages: | |
# - qemu-guest-agent | |
# - nfs-common | |
ntp: | |
enabled: true | |
datasource_list: [ NoCloud, ConfigDrive ] | |
__EOF__ | |
cat > /mnt/tmp/etc/multipath.conf << '__EOF__' | |
defaults { | |
user_friendly_names yes | |
find_multipaths yes | |
} | |
__EOF__ | |
# enable services | |
chroot /mnt/tmp systemctl enable open-iscsi.service || true | |
chroot /mnt/tmp systemctl enable multipath-tools.service || true | |
# copy ssh keys | |
cp -a --force /root/.ssh/authorized_keys /mnt/tmp/root/.ssh/authorized_keys | |
# umount everything | |
umount /mnt/tmp/dev | |
umount /mnt/tmp/proc | |
umount /mnt/tmp | |
# create template | |
qm create ${IMGID} --memory 512 --net0 virtio,bridge=vmbr0 | |
qm importdisk ${IMGID} ${IMG} ${STORAGEID} --format qcow2 | |
qm set ${IMGID} --scsihw virtio-scsi-pci --scsi0 ${STORAGEID}:$IMGID/vm-$IMGID-disk-0.qcow2 | |
qm set ${IMGID} --ide2 ${STORAGEID}:cloudinit | |
qm set ${IMGID} --boot c --bootdisk scsi0 | |
qm set ${IMGID} --serial0 socket --vga serial0 | |
qm template ${IMGID} | |
# set host cpu, ssh key, etc | |
qm set ${IMGID} --scsihw virtio-scsi-pci | |
qm set ${IMGID} --cpu host | |
qm set ${IMGID} --agent enabled=1 | |
qm set ${IMGID} --autostart | |
qm set ${IMGID} --onboot 1 | |
qm set ${IMGID} --ostype l26 | |
qm set ${IMGID} --ipconfig0 "ip=dhcp" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment