UpCloud
Table of Contents
Floating IP
sudo vi /etc/netplan/99-floating-ip.yamlnetwork: version: 2 renderer: networkd ethernets: eth0: addresses: - $IP/32sudo netplan tryip addrAdding new disk
lsblkfdisk /dev/vdb # n => p => wlsblkmkfs.ext4 /dev/vdb1blkid | grep vdb1 # note UUIDvi /etc/fstabDisk resize
# both operations could be performed on-linegrowpart /dev/vdb 1resize2fs /dev/vdb1Disk migration
- create new disk with default settings
apt install rsync# stop all services -> databases, dockers, etc!systemctl stop docker docker.socket postgresql mysql nginx# something else?lsblk # shows new device as vdbfdisk /dev/vdb # n (with defaults) => a => p => w (to save) / d (if issues)lsblk # shows new partition: vdb1cat /etc/fstab | grep -v "^#" | head -1 # note UUID of root partitionmkfs.ext4 -U `cat /etc/fstab | grep -v "^#" | head -1 | awk -F/ '{print $5}'` /dev/vdb1mount /dev/vdb1 /mntrsync -avxHAX / /mntdf -h # to check approximate size equalitygrub-install /dev/vdb --root-directory=/mnt --recheckshutdown -h now- eject old disk
- start the server
Firewall via cli
- Create special account
- Make sure your account allows API connections. To do so, log into UpCloud control panel and go to Account -> Permissions -> Allow API connections checkbox.
apt install golang-gogo install github.com/UpCloudLtd/upcloud-cli/v3/...@latestmkdir -p ~/.configcat > ~/.config/upctl.yaml << EOTusername: your_upcloud_usernamepassword: your_upcloud_passwordEOTvi ~/.config/upctl.yaml/root/go/bin/upctl server list curl -Lo upcloud-cli.deb https://github.com/UpCloudLtd/upcloud-cli/releases/download/v3.11.1/upcloud-cli_3.11.1_amd64.debsudo dpkg -i upcloud-cli.debmkdir -p ~/.config cat > ~/.config/upctl.yaml << EOTusername: your_upcloud_usernamepassword: your_upcloud_passwordEOTvi ~/.config/upctl.yamlupctl server listWorking line to enable or disable the UpCloud firewall for the current server:
#!/bin/bashSERVER_ID=$(upctl server list 2>&1 | grep `hostname` | awk '{print $1}') && upctl server modify $SERVER_ID --enable-firewall # --disable-firewallScript to renew certs:
#!/bin/bash#set -eset -x
PATH=$PATH:/root/go/bin
date # for the logs
SCRIPTDIR="$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && cd $SCRIPTDIR
#echo "Bringing firewall down"SERVER_ID=$(upctl server list 2>&1 | grep `hostname` | awk '{print $1}') && upctl server modify $SERVER_ID --disable-firewall
#echo "Starting renewal task"certbot renew
#echo "Bringing firewall back up"SERVER_ID=$(upctl server list 2>&1 | grep `hostname` | awk '{print $1}') && upctl server modify $SERVER_ID --enable-firewallcrontab:
15 2 * * * /root/cert_renew.sh >> /root/cert_renew.log 2>&1And to reboot the server:
30 4 * * MON-THU /bin/sh -c '[ -f /var/run/reboot-required ] && sudo shutdown -r now'Disk clone (SSD to HDD)
upctl storage clone {storage_uuid} --title {example_standard_clone} --zone {my-zone1} --tier standard```
I also needed to convert disk from SSD to HDD: `upctl storage clone <storage-uuid> --title \'Standard Disk\' --zone de-fra1 --tier standard --encrypt`