diff --git a/README.md b/README.md index 6d2edec..460f93a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# :burger: kopsrox +# :hamburger: kopsrox - kopsrox is a script to automate creation and management of simple ha k3s cluster on ProxmoxVE using cloud images :nerd_face: - add more master/worker k3s nodes using a simple config file and cli interface :pray: @@ -15,4 +15,4 @@ # :boom: in progress - Improving Docs - Some code clean up - - Recent: bug fixes + - Recent: bug fixes, machine type optimisations, kubevip improvements diff --git a/dev/img-mirror/get.sh b/dev/img-mirror/get.sh index 033e716..7db46fd 100755 --- a/dev/img-mirror/get.sh +++ b/dev/img-mirror/get.sh @@ -1,12 +1,16 @@ -if [ ! -f mantic-minimal-cloudimg-amd64.img ] +# downloads image for use with serve.sh +ubr="oracular" +if [ ! -f "${ubr}-minimal-cloudimg-amd64.img" ] then -wget https://cloud-images.ubuntu.com/minimal/daily/mantic/current/mantic-minimal-cloudimg-amd64.img +wget "https://cloud-images.ubuntu.com/minimal/daily/${ubr}/current/${ubr}-minimal-cloudimg-amd64.img" 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 -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 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 +#fi diff --git a/docs/SETUP.md b/docs/SETUP.md index fa3e918..de97ddf 100644 --- a/docs/SETUP.md +++ b/docs/SETUP.md @@ -1,13 +1,11 @@ - - -# :baby_symbol: setup +# :hamburger: kopsrox setup ## :hammer_and_wrench: requirements - Proxmox VE with root access or a user who can 'sudo su' without a password - network with internet access configured in proxmox as a bridge or a proxmox sdn network - a range of 10 free Proxmox qm/virtual machine id 'vmids' eg 600 to 610 -- a range of 10 IP's on a network for kopsrox to work with eg 192.168.0.160 to 192.168.0.170 +- 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 - clone the repo and follow the steps below ## :bricks: install packages @@ -17,6 +15,8 @@ _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` diff --git a/docs/USAGE.md b/docs/USAGE.md index add63e3..b215b7d 100644 --- a/docs/USAGE.md +++ b/docs/USAGE.md @@ -7,6 +7,7 @@ documentation is a WIP :construction: - [etcd](#etcd) - [node](#node) - [k3s](#k3s) +- [kubevip](#kubevip) ## :cyclone: image ### :white_check_mark: create @@ -119,4 +120,7 @@ usage: - uninstalls k3s using the usual script - for experimenting with k3s reinstall +## :cyclone: kubevip +### reinstall +- reinstalls kubevip diff --git a/lib/kopsrox_config.py b/lib/kopsrox_config.py index 51fa88c..65af842 100755 --- a/lib/kopsrox_config.py +++ b/lib/kopsrox_config.py @@ -317,7 +317,7 @@ def vm_info(vmid,node=node): except: # no image found - kmsg(kname, 'no template detected - please run "kopsrox image create"', 'err') + kmsg(kname, f'{cluster_name} image not found - please run "kopsrox image create"', 'err') exit(0) # get image info diff --git a/lib/kopsrox_ini.py b/lib/kopsrox_ini.py index c709d57..587df38 100755 --- a/lib/kopsrox_ini.py +++ b/lib/kopsrox_ini.py @@ -45,8 +45,8 @@ def init_kopsrox_ini(): config.add_section('kopsrox') # upstream image - config.set('kopsrox', '; the upstream cloud image used to create the kopsrox template') - config.set('kopsrox', 'cloud_image_url', 'https://cloud-images.ubuntu.com/minimal/daily/mantic/current/mantic-minimal-cloudimg-amd64.img') + config.set('kopsrox', '; the upstream cloud image used to create the kopsrox image') + config.set('kopsrox', 'cloud_image_url', '//cloud-images.ubuntu.com/minimal/daily/oracular/current/oracular-minimal-cloudimg-amd64.img') # disk size for kopsrox vms config.set('kopsrox', '; size of kopsrox vm disk in Gib ') diff --git a/lib/verb_image.py b/lib/verb_image.py index d2878cd..29636ba 100755 --- a/lib/verb_image.py +++ b/lib/verb_image.py @@ -21,23 +21,23 @@ # create image if cmd == 'create': - kmsg(f'{kname}create', f'name:{cluster_name}-i1', 'sys') # get image name from url cloud_image = cloud_image_url.split('/')[-1] - kmsg(f'{kname}download', f'{cloud_image_url}') + kmsg(f'{kname}create', f'{cloud_image}-{k3s_version} {storage}/{cluster_name}-i0/{cluster_id}', 'sys') # check if image already exists if os.path.isfile(cloud_image): - kmsg(kname, f'{cloud_image} already exists', 'err') + kmsg(f'{kname}check', f'Error! {cloud_image} already exists - please delete', 'err') exit(0) # check img can be downloaded try: + kmsg(f'{kname}wget', f'{cloud_image_url}') wget.download(cloud_image_url) print() except: - kmsg(kname, f'unable to download {cloud_image_url}', 'err') + kmsg(f'{kname}check', f'unable to download {cloud_image_url}', 'err') exit(0) # script to install disable selinux on Rocky @@ -59,10 +59,10 @@ cp /dev/null /etc/sysconfig/qemu-ga fi''' # shouldn't really need root but run into permissions problems - patch_cmd = f'sudo virt-customize --smp 2 -m 2048 -a {cloud_image} --install qemu-guest-agent --run-command "{virtc_script}"' + virtc_cmd = f'sudo virt-customize --smp 2 -m 2048 -a {cloud_image} --install qemu-guest-agent --run-command "{virtc_script}"' - kmsg('image_virt-customize', 'configuring image') - patch_out = local_os_process(patch_cmd) + kmsg(f'{kname}virt-customize', 'configuring image') + local_os_process(virtc_cmd) # destroy template if it exists try: @@ -88,26 +88,25 @@ agent = ('enabled=true'), hotplug = 0, ciupgrade = 0, - description = f'
{cluster_name} template\n{cloud_image}\n{k3s_version}',
+    description = f'
{cluster_name} image\nbased on: {cloud_image}\nk3s version: {k3s_version}',
     ciuser = cloudinituser, 
     cipassword = cloudinitpass,
     sshkeys = cloudinitsshkey,
-    tdf = '1',
   ))
 
   # shell to import disk
   # import-from requires the full path os.getcwd required here
   import_cmd = f'''
-sudo qm set {cluster_id} --scsi0 {storage}:0,import-from={os.getcwd()}/{cloud_image},iothread=true,aio=native,discard=on,ssd=1 
+sudo qm set {cluster_id} --scsi0 {storage}:0,import-from={os.getcwd()}/{cloud_image},iothread=true,aio=native
 mv {cloud_image} {cloud_image}.patched'''
 
   # run shell command to import
-  kmsg(f'image_qm-import', f'{cloud_image} > {storage}/{cluster_id}')
   local_os_process(import_cmd)
 
   # convert to template via create base disk also vm config
   task_status(prox.nodes(node).qemu(cluster_id).template.post())
   task_status(prox.nodes(node).qemu(cluster_id).config.post(template = 1))
+  kmsg(f'{kname}qm-import', f'done')
 
 # image info
 if cmd == 'info':
@@ -115,5 +114,5 @@
 
 # destroy image
 if cmd == 'destroy':
-   kmsg(kname, f'{kopsrox_img()}/{cloud_image_desc}', 'warn')
+   kmsg(f'{kname}destroy', f'{kopsrox_img()}/{cloud_image_desc}', 'warn')
    prox_destroy(cluster_id)