Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
be5566e
Update README.md
simonccc Aug 31, 2024
8084dbe
bug fix for delete on other node
simonccc Sep 2, 2024
e3cd577
fix ini
simonccc Oct 26, 2024
2c56fa3
get date on image and other fixes
simonccc Nov 8, 2024
25a2958
some image stuff
simonccc Nov 9, 2024
0acfb1b
add network_ip config to traefik helm chart values
simonccc Nov 9, 2024
8f28b89
move kubevip to autoinstall
simonccc Nov 9, 2024
d158f33
more kubevip clean up
simonccc Nov 9, 2024
f651766
small fixes to kubevip install
simonccc Nov 9, 2024
c8ab3f9
fixes for helm
simonccc Nov 9, 2024
f19e289
move s3 creds to k3s config file
simonccc Nov 30, 2024
7c31e69
more startup config
simonccc Nov 30, 2024
10b0f08
update git ignore
simonccc Dec 6, 2024
8792d41
code clean
simonccc Dec 7, 2024
18b2f58
add nodes to cluster post k3s config files fix
simonccc Jan 4, 2025
afaf193
some more config level tweaks
simonccc Jan 5, 2025
53c9aed
Update SETUP.md
simonccc Jan 24, 2025
8b9ce08
Update FAQ.md
simonccc Jan 24, 2025
9398bf7
Update GETSTARTED.md
simonccc Jan 24, 2025
cf5e61a
adds cluster restore option
simonccc Feb 1, 2025
7688945
pre lenny
simonccc Feb 1, 2025
18b910f
Update README.md
simonccc Feb 2, 2025
58a5d85
start to speed up config check
simonccc Feb 2, 2025
4a33dc0
lastest fixes
simonccc Feb 7, 2025
28c7ec3
add worker fix
simonccc Feb 8, 2025
6764f16
dev helper script update
simonccc Feb 9, 2025
0b82ed7
fixes to node creation
simonccc Feb 9, 2025
b747a2b
scripts update
simonccc Feb 16, 2025
0c838fc
worker fix
simonccc Feb 16, 2025
e3b8515
latest ci fixes
simonccc Mar 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@ lib/__pycache__/
*.swp
*.img
*.etcd.token
kopsrox.k3stoken
kopsrox.kubeconfig
kopsrox_disk_import.log
kopsrox_imgpatch.log
kopsrox.etcd*
*.k3stoken
*.kubeconfig
19 changes: 10 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
# :hamburger: kopsrox
# kopsrox

- kopsrox is a script to automate creation and management of simple ha k3s cluster on ProxmoxVE using cloud images :nerd_face:
- kopsrox is a script to create simple ha k3s cluster on ProxmoxVE
- use upstream cloud images - no iso's to mess around with
- add more master/worker k3s nodes using a simple config file and cli interface :pray:
- kube-vip ( https://kube-vip.io/ ) built in providing full HA setup for the kube api :atom:
- kube-vip ( https://kube-vip.io/ ) built in providing full HA setup for the kube api and traefik :atom:
- easy management of etcd S3 snapshot/restore operations - easily restore a cluster from s3! :floppy_disk:
- export the k3s token, your kubeconfig etc etc - its all automatic :nerd_face:
- export the k3s token, your kubeconfig etc etc - its all automatic :nerd_face:

# :book: docs
get it https://github.com/simonccc/kopsrox/releases

# docs
- [SETUP.md](docs/SETUP.md)
- [GETSTARTED.md](docs/GETSTARTED.md)
- [USAGE.md](docs/USAGE.md)
- [FAQ.md](docs/FAQ.md)

# :boom: in progress
- Improving Docs
- Some code clean up
- Recent: bug fixes, machine type optimisations, kubevip improvements
# in progress
- Recent: add cluster restore option
2 changes: 2 additions & 0 deletions dev/helm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
c=`grep ^cluster_name kopsrox.ini | cut -d ' ' -f3`
helm --kubeconfig=${c}.kubeconfig ${@}
2 changes: 2 additions & 0 deletions dev/img-mirror/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
*.img
*.qcow
log.txt
PID
13 changes: 6 additions & 7 deletions dev/img-mirror/get.sh
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# downloads image for use with serve.sh
ubr="oracular"
if [ ! -f "${ubr}-minimal-cloudimg-amd64.img" ]
if [ ! -f "noble-server-cloudimg-amd64.img" ]
then
wget "https://cloud-images.ubuntu.com/minimal/daily/${ubr}/current/${ubr}-minimal-cloudimg-amd64.img"
wget "https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img"
fi

# untested
#if [ ! -f amzn2-kvm-2.0.20240306.2-x86_64.xfs.gpt.qcow2 ]
#then
#wget https://cdn.amazonlinux.com/os-images/2.0.20240306.2/kvm/amzn2-kvm-2.0.20240306.2-x86_64.xfs.gpt.qcow2
#fi
if [ ! -f amzn2-kvm-2.0.20240306.2-x86_64.xfs.gpt.qcow2 ]
then
wget https://cdn.amazonlinux.com/os-images/2.0.20240306.2/kvm/amzn2-kvm-2.0.20240306.2-x86_64.xfs.gpt.qcow2
fi
#if [ ! -f Rocky-9-GenericCloud.latest.x86_64.qcow2 ]
#then
#wget https://mirrors.vinters.com/rocky/9/images/x86_64/Rocky-9-GenericCloud.latest.x86_64.qcow2
Expand Down
4 changes: 3 additions & 1 deletion dev/img-mirror/serve.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
#!/usr/bin/env bash
python3 -m http.server -b "::"
kill -9 $(cat PID) > /dev/null 2>&1
python3 -m http.server -b "::" > log.txt 2>&1 &
echo $! > PID
64 changes: 16 additions & 48 deletions dev/rls_test.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env bash

set -e
#set -x

Expand All @@ -11,6 +13,7 @@ KCI="$KC info"
KCC="$KC create"
KCU="$KC update"
KCD="$KC destroy"
KCR="$KC restore"
KI="$K image"
KID="$KI destroy"
KIC="$KI create"
Expand All @@ -30,69 +33,34 @@ kc() {
# get pods
get_pods="$KC kubectl get pods -A"

# 0 size cluster
kc workers 0 ; kc masters 1
# 1 size cluster
$KCD

# create image
$KIC

# create / update cluster
$KCC ; $KCU

# take snapshot
$KES

# destroy cluster
kc workers 0 ; kc masters 1
$KCD

# create / update cluster
$KCC ; $KCU

# restore snapshot
$KERL
# ** 1 MASTER, SNAPSHOT RESTOR
# create image, create and update cluster
$KIC ; $KCC ; $KCU

# update cluster
$KCU
# take snapshot , destroy cluster, create, restore
$KES ; $KCD ; $KCC ; $KERL

# ** MULTIPLE MASTERS AND WORKERS TEST
# add a worker and delete it
kc workers 1 ; $KCU ; kc workers 0 ; $KCU

# re add worker
kc workers 1 ; $KCU
kc workers 2 ; $KCU

# add 3 masters and go back to 1
kc masters 3 ; $KCU ; kc masters 1 ; $KCU

# add 3 masters
kc masters 3 ; $KCU

# take snapshot
$KES

# destroy cluster
$KCD

# create / update cluster
$KCC ; $KCU
#
# # restore snapshot
$KERL
#
# update cluster
$KCU

# change back to 1 node
kc masters 1 ; $KCU ; kc workers 0 ; $KCU

# destroy cluster
$KCD

# create / update cluster
$KCC ; $KCU
#restore snapshot
$KERL
kc masters 1 ; kc workers 0

# ** TEST cluster restore
# destroy cluster
$KCD ; $KCR

finish_time=$(date +%s)
echo $((finish_time - start_time)) secs
2 changes: 1 addition & 1 deletion docs/FAQ.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# :question: FAQ
# kopsrox FAQ

:question: __can I migrate the kopsrox vms to other hosts in my proxmox cluster?__

Expand Down
8 changes: 4 additions & 4 deletions docs/GETSTARTED.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# :burger: get started
# get started

## 🇧🇸 setup kopsrox.ini
## setup a kopsrox.ini

`./kopsrox.py` - a default kopsrox.ini will be created

Expand All @@ -12,13 +12,13 @@ follow the guide in [SETUP.md](SETUP.md)

`./kopsrox.py image create`

## 🥑 create a cluster
## create a cluster

`./kopsrox.py cluster create`

## 🚑 add a worker

edit `kopsrox.ini` and set `workers = 1` in the `[cluster]` section
for example edit `kopsrox.ini` and set `workers = 1` in the `[cluster]` section

`./kopsrox.py cluster update`

Expand Down
5 changes: 5 additions & 0 deletions docs/IMAGES.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# cloud images


# amazon linux ( qcow )
https://cdn.amazonlinux.com/al2023/os-images/2023.6.20250123.4/
31 changes: 5 additions & 26 deletions docs/SETUP.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# :hamburger: kopsrox setup
# kopsrox setup

## :hammer_and_wrench: requirements

Expand All @@ -7,18 +7,12 @@
- a range of 10 free Proxmox qm/virtual machine id 'vmids' eg 600 to 610
- a range of 10 IP's on a network with internet access for kopsrox to work with eg 192.168.0.160 to 192.168.0.170

## :bricks: install

## :bricks: install

- clone the repo - or probably better one of the releases or stable branches - the 'main' branch can often be a bit broken
- sudo apt install libguestfs-tools python3-termcolor -y`
- get one of the releases or stable branches - the 'main' branch can often be a bit broken
- sudo apt install libguestfs-tools python3-termcolor python3-wget -y`
- pip3 install --break-system-packages --user -r requirements.txt`

_installs the required pip packages vs using os packages_

( this will be improved in the future )

## :star: generate api key

`sudo pvesh create /access/users/root@pam/token/kopsrox`
Expand All @@ -29,9 +23,9 @@ _installs the required pip packages vs using os packages_

run `./kopsrox.py` and an example _kopsrox.ini_ will be generated - you will need to edit this for your setup

Most values should be obvious and commented accordingly - see below for more info
Most values should be hopefully obvious and commented accordingly...

# :mag_right: kopsrox.ini
# kopsrox.ini

## :computer: cluster_id

Expand Down Expand Up @@ -66,18 +60,3 @@ would result in this:
|9|629|192.168.0.179|worker 5|kopsrox-w5|

The VIP IP ( here 192.168.0.170 ) is used by kube-vip to provide a highly available IP for the API when you have 3 master nodes

## :pencil2: kopsrox

### :rainbow: cloud_image_url

`https://cloud-images.ubuntu.com/minimal/daily/mantic/current/mantic-minimal-cloudimg-amd64.img`

url to the cloud image you want to use as the koprox base template.

during `kopsrox.py image create` this is downloaded and patched via `virt-customise` to install `qemu-guest-agent`

Tested images so far:

https://cdn.amazonlinux.com/os-images/2.0.20240306.2/kvm/amzn2-kvm-2.0.20240306.2-x86_64.xfs.gpt.qcow2
https://mirrors.vinters.com/rocky/9/images/x86_64/Rocky-9-GenericCloud.latest.x86_64.qcow2
10 changes: 4 additions & 6 deletions kopsrox.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"create" : '',
"update" : '',
"destroy" : '',
'restore' : '',
},
"k3s": {
"export-token" : '',
Expand All @@ -48,9 +49,6 @@
"reboot" : 'hostname',
"k3s-uninstall" : 'hostname',
"rejoin-slave" : 'hostname',
},
"kubevip": {
"reinstall": '',
}
}

Expand Down Expand Up @@ -87,12 +85,12 @@ def cmds_help(verb):

# if verb not found in cmds dict
if not verb in verbs:
exit()
exit(0)

# verb not found or passed
except:
verbs_help()
exit()
exit(0)

# handle command
try:
Expand All @@ -105,7 +103,7 @@ def cmds_help(verb):
if not cmd in list(cmds[verb]):
exit()

#
# cmd not found
except:
cmds_help(verb)
exit()
Expand Down
Loading