Category: Other

  • Long overdue & my first Firefox addon

    Long overdue – another blog overhaul. It’s building again, now based on the blowfish theme, and if all goes well I will get a better editing experience than this <censored> “open-editor-new-file-add-front-matter” process, which is, frankly, shit. The last theme lasted two full posts. One if you don’t count the one announcing it. Wow.

    Apart from that – I start being a half-fan of “AI”. The possibilities opening up are quite nice.

    For me, that was a successor of a Firefox addon I heavily rely on (“Containerise“), which seemed no longer maintained, and also super cumbersome to use for 2026. Also, ugly.

    So here’s my first Firefox addon: “Container Dispatcher”. You can find more information now on the new project page, and my dispatcher site.

  • Postgres column type inference madness

    Long time no see.

    Anyways.

    This just cost me hours. And it’s “part I” because I just might add all the difficulties I had, which are … plenty.

    DISCLAIMER: In no way I want to bash either Postgres or SQLAlchemy here, which are incredible projects. This is just my personal experience in, well, “experiencing” the learning curve as someone who has basically no clue about all those things.

    Situation: Saving a database table, i get this error:

    Original exception was: (psycopg2.errors.InvalidTextRepresentation) invalid input syntax for type double precision: "offset_key.251"
    E   LINE 1: ...:JSONB, ARRAY['scheduled-item']::VARCHAR[], NULL, 'offset_key.251',...
    E [SQL: INSERT INTO invoice_items (<<tons truncated>> offset_key, <<tons truncated>> ... offset_by_ref, cancelled_by_ref) SELEC ... 1158 characters truncated ... 7, p18, p19,
    E [parameters: {'offset_key__0': 'offset_key.251', <<again tons truncated>> ..., 'offset_key__1': nan, <<blablablablabla>>
    

    After a lot of debugging aorund I was absolutely sure that the value offset_key.251 was supposed to be written in the column offset_key. Which was perfectly fine, and which is both defined as a Mapped[String], as well as actually created as such during the test run. So the actual table column type was absolutely correct.

    After a lot of haggling with ChatGPT the solution was this (copy-pasted, because that stupid thing explains really well sometimes):

    Ah — now it’s crystal clear. Let’s unpack this carefully.

    (well, thanks and fuck you too)

    Sometimes, if the first row’s parameter is NULL, Postgres tries to infer a type. If SQLAlchemy passes ‘offset_key.251’ as a parameter in a position that Postgres already inferred as double precision (from another row, e.g., nan), you get this error.

    Databases are … weird. Shouldn’t it just use the actually defined column type?!? This seems really, really wrong (not the first time with the ChatGPTool …).

    But I digress.

    Notice: the second row is nan.

    Yes.

    In Python, float(‘nan’) is a FLOAT, so SQLAlchemy passes it as double precision.

    Postgres sees nan in row 1 → infers double precision for that column in the multi-row insert.

    Row 0 has ‘offset_key.251’ → cannot cast to float → error.

    ✅ This is a classic multi-row INSERT typing problem with Postgres.

    WTF.

    I was absolutely sure that could not be it. But I was completely out of options, so I went after the nan value – and it turns out, I read this from a Pandas DataFrame. Okay, that makes absolute sense, Pandas quite dislikes None, even in string columns.

    So I re-mapped this to None, ran the test, …

    … and it worked. Unbelievable.

    Again: HOURS.

  • New theme, again

    Every now and then I get that idiotic idea that I would succeed in doing any kind of web / theme design. So the page was in a truly desolate state for a while now, which I now freely admit, and (hopefully) corrected.

    I found the theme Hinode, which seemed kinda nice, and does all I need – for now. Maybe I’ll switch again, maybe not, but I truly and desperately hope that I will never attempt to do this myself – it’s just a waste of time.

    So here we go, an actually working theme again, have fun.

  • Hetzner dedicated server setup

    Dedicated Server

    I have a dedicated server now, from Hetzner. My old one was getting kinda crammed, and I realized that a “cloud based” server would be massively smaller at the same price – so I have now “invested” in a proper and totally oversized dedicated server.

    The goal: To host my services on it, this time using k8s and all the shiny best-practice tools we have available now. No more fiddling around. Also, no more things that can go “meh”, I spent way too much time reigning my old server back in.

    Server installation

    First of all, i basically followed this document.

    • check for RAID controllers (lspci | grep -i raid)
    • i had none, great, software RAID it is
    • wipe hard drive boot sectors, just in case (wipefs -fa /dev/nvme*n1)
    • exec installimage

    Now the question of questions – which OS? Debian, Ubuntu, or Arch Linux?

    • Debian: Rock solid, a bit dusty, rock solid, supported everywhere.
    • Ubuntu: Most popular, annoying commercial stunts, supported also everywhere.
    • Arch Linux: Least supported, most cool.

    Arch it is? … Hm, let’s opt for “rock solid”. Autoupdate should be a given (it is with Debian), so … yeah. Debian. (sadface, a bit, but still – Debian)

    An unreadable editor opens. (lightgray on lightblue? srsly??)

    Some really serious questions though.

    File system & RAID

    BTRFS? But … on top of software RAID? Or “native” BTRFS-RAID? Conveniently, the Hetzner installation script uses mdadm based RAID by default, so this is what I’m going to use.

    Regarding the file system, some research lead to …

    • don’t do BTRFS on top of SW RAID (which Hetzner is kindly setting up for me, so no BTRFS it si then), and
    • ext4 and XFS “meh”, really not much difference.

    Regarding layout, …

    • I thought long and hard and realize the only question is: Do I want to re-install on hard drive failure, or not?

    … and I don’t. So RAID 1 (“mirroring”), no LVM (because yeah, sure, i could extend transparently, but … gooood get on with it already, and KEEP IT SIMPLE!!).

    So, software-based RAID 1 (mdadm), ext4 filesystem, go.

    ##  Hetzner Online GmbH - installimage - standard config
    
    ##  HARD DISK DRIVE(S):
    DRIVE1 /dev/nvme0n1
    DRIVE2 /dev/nvme1n1
    
    ##  SOFTWARE RAID:
    # activate software RAID?  < 0 | 1 >
    SWRAID 1
    # Choose the level for the software RAID < 0 | 1 | 10 >
    SWRAIDLEVEL 1
    
    ##  HOSTNAME:
    HOSTNAME fly3
    
    ##  NETWORK CONFIG:
    # IPV4_ONLY no
    
    ##  MISC CONFIG:
    USE_KERNEL_MODE_SETTING no
    
    ##  PARTITIONS / FILESYSTEMS:
    PART swap   swap       32G
    PART /boot  ext4     1024M
    PART /      ext4       all
    
    ## your system has the following devices:
    # Disk /dev/nvme0n1: 512.12 GB (=> 476.94 GiB)
    # Disk /dev/nvme1n1: 512.12 GB (=> 476.94 GiB)
    
    ## Based on your disks and which RAID level you will choose you have
    ## the following free space to allocate (in GiB):
    # RAID  0: ~952
    # RAID  1: ~476
    
    ##  OPERATING SYSTEM IMAGE:
    IMAGE /root/.oldroot/nfs/install/../images/Debian-1205-bookworm-amd64-base.tar.gz
    

    The nice thing: If you “just do” and don’t think, the whole process it’s going to take you less than 10 minutes.

    K3S installation

    Well, for installing k3s (the k8s distribution of choice) there are were two valid options:

    Decisions, decisions, again. I did for v2 of my server, so that sounded like a no-brainer option. But I had a look at the ansible roles, and I thought “do I really need this?” … and the answer is – no. The only thing I want are managed upgrades, and this is possible either with ansible, or – cloud native 😁 – using a K8S Operator, namely Rancher’s system-upgrade-controller.

    So I am about to try k3sup, which should give me the most simple K8S cluster there is.

    Let’s go:

    k3sup \
        install
        --cluster \
        --host $HOST_IP \
        --merge \
        --user root \
        --ssh-key $HOME/.ssh/id_ed25519
    

    It’s a bit annoying that you have to actually specify your SSH private key if you don’t use RSA, but hey – otherwise it worked like a charm.

    Running: k3sup install
    2024/06/01 13:46:24 fly3.srv.flypenguin.de
    Public IP: <host-ip>
    [INFO]  Finding release for channel stable
    [INFO]  Using v1.29.5+k3s1 as release
    [INFO]  Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.29.5+k3s1/sha256sum-amd64.txt
    [INFO]  Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.29.5+k3s1/k3s
    [INFO]  Verifying binary download
    [INFO]  Installing k3s to /usr/local/bin/k3s
    [INFO]  Skipping installation of SELinux RPM
    [INFO]  Creating /usr/local/bin/kubectl symlink to k3s
    [INFO]  Creating /usr/local/bin/crictl symlink to k3s
    [INFO]  Creating /usr/local/bin/ctr symlink to k3s
    [INFO]  Creating killall script /usr/local/bin/k3s-killall.sh
    [INFO]  Creating uninstall script /usr/local/bin/k3s-uninstall.sh
    [INFO]  env: Creating environment file /etc/systemd/system/k3s.service.env
    [INFO]  systemd: Creating service file /etc/systemd/system/k3s.service
    [INFO]  systemd: Enabling k3s unit
    Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
    [INFO]  systemd: Starting k3s
    Result: [INFO]  Finding release for channel stable
    [INFO]  Using v1.29.5+k3s1 as release
    [INFO]  Downloading hash https://github.com/k3s-io/k3s/releases/download/v1.29.5+k3s1/sha256sum-amd64.txt
    [INFO]  Downloading binary https://github.com/k3s-io/k3s/releases/download/v1.29.5+k3s1/k3s
    [INFO]  Verifying binary download
    [INFO]  Installing k3s to /usr/local/bin/k3s
    [INFO]  Skipping installation of SELinux RPM
    [INFO]  Creating /usr/local/bin/kubectl symlink to k3s
    [INFO]  Creating /usr/local/bin/crictl symlink to k3s
    [INFO]  Creating /usr/local/bin/ctr symlink to k3s
    [INFO]  Creating killall script /usr/local/bin/k3s-killall.sh
    [INFO]  Creating uninstall script /usr/local/bin/k3s-uninstall.sh
    [INFO]  env: Creating environment file /etc/systemd/system/k3s.service.env
    [INFO]  systemd: Creating service file /etc/systemd/system/k3s.service
    [INFO]  systemd: Enabling k3s unit
    [INFO]  systemd: Starting k3s
     Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
    
    Merging config into file: /Users/tm/Dev/private/tf-spaghetti/kubeconfig
    Saving file to: /Users/tm/Dev/private/tf-spaghetti/kubeconfig
    
    # Test your cluster with:
    export KUBECONFIG=/Users/tm/Dev/private/tf-spaghetti/kubeconfig
    kubectl config use-context default
    kubectl get node -o wide
    
    🚀 Speed up GitHub Actions/GitLab CI + reduce costs: https://actuated.dev
    

    It also seems the cluster is named default, which is kind of the worst name for a cluster, so after doing this I did do this:

    • vim $HOME/.kube/config and change basically everything (context, cluster & user name) to $MYCLUSTER

    Or in case you like automation, simply use yq (using vim is actually faster in that case, though):

    KC=/home/.kube/config
    yq eval -i '(.clusters[] | select(.name=="default")).cluster.server="https://localhost:56443"' $KC
    yq eval -i '(.clusters[] | select(.name=="default")).name="MYCLUSTER"' $KC
    yq eval -i '(.contexts[] | select(.name=="default")).context.cluster="MYCLUSTER"' $KC
    yq eval -i '(.contexts[] | select(.name=="default")).contest.user="MYCLUSTER"' $KC
    yq eval -i '(.contexts[] | select(.name=="default")).name="MYCLUSTER"' $KC
    yq eval -i '(.users[] | select(.name=="default")).name="MYCLUSTER"' $KC
    

    Firewall

    So to finally protect the server, let’s install and activate ufw (the “uncomplicated firewall”), following this blog post, slightly modifying based on this article, some general ufw docs from digital ocean, and an overview of flannel networking interfaces from here:

    # sudo apt-get install ufw, naturally ;)
    ufw default deny
    ufw default allow routed
    ufw allow ssh
    
    ufw allow in on cni0 from 10.42.0.0/16              comment "K3s kube-system pod traffic"
    ufw allow in on flannel.1 from 10.42.0.0/16 comment "K3s"
    
    ufw allow "www"        comment "K8s Ingress"
    ufw allow "www Secure" comment "K8s Ingress"
    

    I did not enable ufw and copy-pasted this tmux, so if my ssh connectino broke I could restart the server and would not have been locked out. (I don’t have a root password, so …)

    Controller-based upgrades

    Since this is already taking long, let’s quickly install the upgrade controller and schedule a more in-depth review later 🙂 .

    RANCH=https://github.com/rancher/system-upgrade-controller/releases/latest
    kubectl apply -f $RANCH/download/crd.yaml
    kubectl apply -f $RANCH/download/system-upgrade-controller.yaml
    

    Finally, let’s install FluxCD

    From the professional life I recently came in contact with ArgoCD, and I like it. So I had a look around, and found FluxCD – and this seems also cool.

    So I’m going to try this for myself for now. So, to deploy flux, we have to …

    • Create a cluster-state repository (in my case on GitLab)
    • Create a personal access token with full read/write permissions (there are ways to not do this, which I would definitely do the next time, but this time I was too late). Note that you do this in your Profile, and not the repository settings.
    • Execute flux bootstrap

    After I did the first two things, here I went:

    # Create a gitlab PERSONAL access token with all permissions first.
    # that is done IN YOUR PROFILE, not in the repository.
    # (it should be possible without, yet it was kinda too late)
    flux bootstrap gitlab \
      --owner=my-group \
      --repository=my-state-repo \
      --components source-controller,kustomize-controller,helm-controller,notification-controller
    

    The whole thing is … weird. On the one hand, super cool, everything done. On the other hand, super complex, meeeeh. If you look in the repository online you will notice a new folder flux-system, which we will use right now to add a “Kustomization” I want.

    • Clone out the repo,
    • modify the file flux-system/kustomization.yaml and add this content,
    • perform a git push,
    • “wait” or do this: flux reconcile ks flux-system --with-source.

    And while doing this I learned that FluxCD has no Web UI (well, now it has a 3rd party UI but …). So you can’t really see at a glance whether this worked or not. Or click “update” / “refresh” to get an idea. So … the whole “managing FluxCD” part is … annoying already. Let’s see if this becomes less annoying over time.

    So … maybe also ArgoCD?

    So, since the whole FluxCD thingy was … not so cool, I might actually co-install ArgoCD and see where it leads me.

    But for now, that’s it.

  • Create ODT files using ZIP

    So I wanted to test something, for which I needed to create or modify an ODT file. Since ODT files are just ZIPs, I thought “open, edit, zip, done” would be sufficient.

    It’s not:

    • you need to create the ODT file using a special procedure.
    • you may not include extra files into the ODT file (e.g. no “notes.txt” or sth)

    The 2nd thing you have to take care of yourself, for the first I wrote a small Mac automator script, using bin/bash as shell:

    SAVE_DIR="$PWD"
    
    while read input_dir ; do
        [[ -d "$input_dir" ]] || continue
    
        cd "$input_dir"
        touch _odt_create_log.txt
        exec > _odt_create_log.txt
        exec 2>&1
    
        set -x
        ODT_FILE="../$(basename "$input_dir").odt"
        rm -f "$ODT_FILE"
        zip      "$ODT_FILE" -0 mimetype
        zip -ruo "$ODT_FILE"    .         -x mimetype _odt_create_log.txt
        cd "$SAVE_DIR"
        set +x
    done
    
  • Hugo: index vs. _index

    I renamed ./content/about.md to ./content/index.md, and poof! … all tags gone, all blog postings gone.

    What?!

    It makes sense, if you think about it.

    index.md is a special file, which automatically marks the directory it is in as a so-called “leaf-bundle“, which then makes all the files and directories and all directories become “irrelevant” – a leaf bundle has no children.

    So, what I actually wanted to do was to rename it to _index.md, which marks ./content as what it is – a branch bundle.

    Or in short: don’t put index.md files in ./content. If you want to update your home page, use _index.md.

    Sources:

  • Flypenguin Theme …

    The blog gets a new theme: The flypenguin theme.

    The old one (Cactus) served me well, but I wanted to do something on my own. Sometimes you just have to part ways.

    This theme will be mine and mine alone, it will not be designed for re-use, and I hope I will not totally suck in designing it.

    Let’s see.

  • pg_dump and pg_restore

    Since I can never remember … . Using pg_dump and pg_restore, tested with AWS RDS.

    First option, pg_dump can create SQL dumps, which can be read from psql.

    # save database; "user" can be admin user (tested) or db_user (untested)
    pg_dump    -p my-db.host   -U user      -d db   > my_backup.sql
    
    # restore database; maybe you can also use the admin user here (untested)
    psql       -p my-db.host   -U db_user   -d db   < my_backup.sql
    

    Second option, let’s now create a pg_dump “custom” dump file, and restore that with pg_restore.

    # save the db ... (add "-v" for more verbosity)
    pg_dump    -p my-db.host   -U user      -d db   -Fc -b -f   my_dump_file.pg_dump
    
    # and restore it. (add "-v" for more verbosity)
    pg_restore -p my-db.host   -U db_user   -d db   -1          my_dump_file.pg_dump
    
  • Terraform for_each and output values

    Let’s say you have conditionally created a “thing” using for_each:

    resource "aws_instance" "this" {
        for_each = var.create_me == true ? toset(["yaaay"]) : toset([])
      # ...
    }
    

    Now you want to use the instance’s IP address, lets say in the module’s “output”, just to have an example (you can use it within the module as well, anywhere you want). I always have to look into existing code to remember, so here are the multiple possible ways I’ve used so far 🙂 :

    output "instance_ip_address_method_1" {
      type        = string
      value       = element(values(aws_instance.this), 0)["public_ip"]
    }
    
    output "instance_ip_address_method_2" {
      type        = string
      value       = element([for v in values(aws_instance.this) : v.public_ip], 0)
    }
    
    output "instance_ip_address_method_3" {
      description = "method 3"
      type        = string
      value       = aws_instance.this["yaaay"].public_ip
    }
    
  • Use VSCodium with Microsoft’s proprietary marketplace

    Yeah, MicroSoft again. The Company That Embraced Open Source (as long as it’s useful to them).

    The original VS Code builds have telemetry. Also, a closed source marketplace. Because of that, VSCodium was created. And VSCodium is good.

    Unfortunately, MicroSoft is still anything but a “good” company, and it does open source purely out of egoistic motives. So it developed a (really good) open source editor (VS Code), but with closed source extensions (Pylance), which are only available on their marketplace, and don’t run on alternative builds of VS Code. Because, hey, more lock-in, more good, ya know?

    So if you want to run Pylance (a good language server) with VS Codium, you have to switch VS Codium back to the original market place, and modify the editor’s “name” identification.

    Here’s how to do that:

    • on a Mac, create the file product.json in the folder $HOME/Library/Application Support/VSCodium
    • enter the following content: json { "nameShort": "Visual Studio Code", "nameLong": "Visual Studio Code", "extensionsGallery": { "serviceUrl": "https://marketplace.visualstudio.com/_apis/public/gallery", "cacheUrl": "https://vscode.blob.core.windows.net/gallery/index", "itemUrl": "https://marketplace.visualstudio.com/items" } }

    Then you cann install Pylance from the official marketplace, and it should run.

    Sources: