66 lines
No EOL
1.7 KiB
Bash
Executable file
66 lines
No EOL
1.7 KiB
Bash
Executable file
#!/bin/bash
|
|
|
|
# Script to create K3s VMs directly on Proxmox
|
|
# Run this on your Proxmox host (10.0.0.2)
|
|
|
|
echo "Creating K3s cluster VMs on Proxmox..."
|
|
|
|
# Your SSH public key
|
|
SSH_KEY="ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHLyVSEEAEbGZZqwPwEup0XrlTpu3x3iF9ExvvQPA4xN graham@mcintire.me"
|
|
|
|
# Create a temporary file with the SSH key
|
|
echo "$SSH_KEY" > /tmp/authorized_keys
|
|
|
|
# Start with higher VM IDs to avoid conflicts
|
|
BASE_ID=130
|
|
|
|
echo "Using VM IDs starting from $BASE_ID"
|
|
|
|
# Control plane nodes
|
|
for i in 1 2 3; do
|
|
VMID=$((BASE_ID + i - 1))
|
|
echo "Creating vntx-control-$i (VM $VMID)..."
|
|
qm clone 9000 $VMID --name vntx-control-$i
|
|
qm set $VMID \
|
|
--cores 4 \
|
|
--memory 8192 \
|
|
--net0 virtio,bridge=vmbr0 \
|
|
--ipconfig0 ip=10.0.0.$((100 + i))/24,gw=10.0.0.1 \
|
|
--sshkey /tmp/authorized_keys
|
|
qm resize $VMID scsi0 50G
|
|
qm start $VMID
|
|
sleep 2
|
|
done
|
|
|
|
# Worker nodes
|
|
for i in 1 2; do
|
|
VMID=$((BASE_ID + 3 + i - 1))
|
|
echo "Creating vntx-worker-$i (VM $VMID)..."
|
|
qm clone 9000 $VMID --name vntx-worker-$i
|
|
qm set $VMID \
|
|
--cores 8 \
|
|
--memory 16384 \
|
|
--net0 virtio,bridge=vmbr0 \
|
|
--ipconfig0 ip=10.0.0.$((110 + i))/24,gw=10.0.0.1 \
|
|
--sshkey /tmp/authorized_keys
|
|
qm resize $VMID scsi0 50G
|
|
# Add additional disk for storage
|
|
qm set $VMID --scsi1 local-lvm:200
|
|
qm start $VMID
|
|
sleep 2
|
|
done
|
|
|
|
# Clean up
|
|
rm -f /tmp/authorized_keys
|
|
|
|
echo
|
|
echo "All VMs created and started!"
|
|
echo
|
|
echo "VMs created:"
|
|
echo " vntx-control-1: 10.0.0.101 (VM ID: 130)"
|
|
echo " vntx-control-2: 10.0.0.102 (VM ID: 131)"
|
|
echo " vntx-control-3: 10.0.0.103 (VM ID: 132)"
|
|
echo " vntx-worker-1: 10.0.0.111 (VM ID: 133)"
|
|
echo " vntx-worker-2: 10.0.0.112 (VM ID: 134)"
|
|
echo
|
|
echo "Wait 60 seconds for cloud-init to complete, then run Ansible" |