Deprecated: Returning a value from a constructor is deprecated in /var/www/michaelwiller.dk/public_html/blog/wp-includes/pomo/streams.php on line 317

Deprecated: Function spl_object_hash() is deprecated since 8.6, consider using spl_object_id() instead in /var/www/michaelwiller.dk/public_html/blog/wp-includes/plugin.php on line 1014

Warning: Cannot modify header information - headers already sent by (output started at /var/www/michaelwiller.dk/public_html/blog/wp-includes/pomo/mo.php:11) in /var/www/michaelwiller.dk/public_html/blog/wp-includes/feed-rss2.php on line 8
Michael on IT https://michaelwiller.dk Ramblings from an old geek Sun, 19 Apr 2026 15:19:42 +0000 en-GB hourly 1 https://wordpress.org/?v=6.9.12 188526966
Deprecated: Function spl_object_hash() is deprecated since 8.6, consider using spl_object_id() instead in /var/www/michaelwiller.dk/public_html/blog/wp-includes/plugin.php on line 1014
Setup of OpenShift demo environment for CNPG https://michaelwiller.dk/2026/04/19/setup-of-openshift-demo-environment-for-cnpg/ Sun, 19 Apr 2026 15:19:42 +0000 https://michaelwiller.dk/?p=116 Summary

The purpose of this post is to show how to configure a CRC-based OpenShift environment (aka Red Hat OpenShift Local) to demo EDB CNPG.

I’ll end up with a working OpenShift cluster (CRC), the CNPG operator installed with MinIO as the destination for WAL- and backup files.

Expect to use around 60 minutes, if you follow along in the instructions.

Why this blog post

EDB recently changed how the OpenShift-compatible CNPG operator is installed. Previously, you could install the subscription-based CNPG operator and get a 30-day trial “out of the box”. With the release of EDB CNPG v. 1.29 that path will be gone soon.

These days, if I want the operator from EDB’s repositories at docker.enterprisedb.com, I need a pull secret. That pull secret is the EDB download token (also referred to as the EDB subscription token).

Because I periodically run CNPG workshops for customers, I would need a token available during the workshop. I could use the Global EDB Token – but I don’t want that to leak – it has access to everything EDB ships.

The initial goal here was to create a setup where the pull secret couldn’t be decoded by random CNPG deployer (i.e. users using oc apply to deploy Postgres Clusters).

However, after a long session of reseach I’ve come to the conclusion that hiding the pull secret is not possible. Actually, even if you add the pull secret to a protected namespace like openshift-operators where only cluster-admins can roam around, the operator will copy the pull secret out to the namespace where CNPG clusters are being deployed – the operator needs that Secret in the local namespace.

So consider this a “getting started with the CNPG operator and CRC-based OpenShift clusters”.

What I will build

  • A local OpenShift cluster using CRC
  • MinIO configured so I can use S3 buckets in demos (for example, backups) and I can show the content of MinIO using the web interface.
  • The EDB CNPG operator installed from the OperatorHub in OpenShift
  • A simple deployment and sanity check to see that WAL files are being archived correctly and a backup of the demo-cluster can be performed.

Step-by-step guide

Create the OpenShift environment (CRC)

CRC is downloaded from the Red Hat OpenShift Local page. There is no brew package available for the install. Remember to copy the pull secret on the download page (you’ll need it shortly).

Once you have installed the package, the crc command should be available in your terminal.

With the command below you create the OpenShift cluster.

Note: You’ll need to add at least 16GB of RAM and 8 CPUs to the cluster. Otherwise things won’t install correctly.

crc setup
crc config set memory 16384
crc config set cpus 8
crc config set developer-password developer
crc config set kubeadmin-password kubeadmin
crc start

Note: Here you’ll need the pull secret from Red Hat. Paste it into the terminal when requested.

Once the process is complete you’ll see output similar to:

Started the OpenShift cluster.
The server is accessible via web console at:
https://console-openshift-console.apps-crc.testing
Log in as administrator:
Username: kubeadmin
Password: kubeadmin
Log in as user:
Username: developer
Password: developer
Use the 'oc' command line interface:
$ eval $(crc oc-env)
$ oc login -u developer https://api.crc.testing:6443

Deploy MinIO

A production-ready installation of MinIO would involve MinIO AIStor and MinIO’s Key Encryption Service – that’s a bit much for a quick setup. So, we’ll use the open source version of MinIO instead (for now).

oc new-project cnpg-developer \
  --display-name="CNPG Developer" \
  --description="Project for CNPG + MinIO PoC"
oc project cnpg-developer

Now create the minio.yaml file with this content:

---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: minio-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
  volumeMode: Filesystem
---
apiVersion: v1
kind: Secret
metadata:
  name: minio-secret
stringData:
  # For a PoC; change these for anything non-demo
  minio_root_user: minio
  minio_root_password: minio12345
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: minio
spec:
  replicas: 1
  selector:
    matchLabels:
      app: minio
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: minio
    spec:
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: minio-pvc
      containers:
        - name: minio
          image: quay.io/minio/minio:latest
          args:
            - server
            - /data
            - --console-address
            - :9090
          env:
            - name: MINIO_ROOT_USER
              valueFrom:
                secretKeyRef:
                  name: minio-secret
                  key: minio_root_user
            - name: MINIO_ROOT_PASSWORD
              valueFrom:
                secretKeyRef:
                  name: minio-secret
                  key: minio_root_password
          ports:
            - containerPort: 9000
              protocol: TCP
            - containerPort: 9090
              protocol: TCP
          volumeMounts:
            - name: data
              mountPath: /data
              subPath: minio
---
apiVersion: v1
kind: Service
metadata:
  name: minio-service
spec:
  type: ClusterIP
  selector:
    app: minio
  ports:
    - name: api
      port: 9000
      targetPort: 9000
      protocol: TCP
    - name: ui
      port: 9090
      targetPort: 9090
      protocol: TCP
---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
  name: minio-api
spec:
  to:
    kind: Service
    name: minio-service
    weight: 100
  port:
    targetPort: api
  tls:
    termination: edge
    insecureEdgeTerminationPolicy: Redirect
---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
  name: minio-ui
spec:
  to:
    kind: Service
    name: minio-service
    weight: 100
  port:
    targetPort: ui
  tls:
    termination: edge
    insecureEdgeTerminationPolicy: Redirect

This YAML, when applied:

  • Creates a PersistentVolumeClaim for MinIO to use
  • Creates a Secret with username and password (minio/minio12345) to use in the MinIO Web Console
  • Creates a Deployment of MinIO with a single pod
  • Creates Services for both the UI and API interface in MinIO
  • Creates Routes for both UI and API

The routes enable us to access the UI outside the OpenShift cluster.

Apply the YAML:

oc apply -f minio.yaml

Verify the install:

oc get pods
oc logs deploy/minio

You should see something like:

NAME                     READY   STATUS    RESTARTS   AGE
minio-55b597d6ff-lq726   1/1     Running   0          23s
INFO: Formatting 1st pool, 1 set(s), 1 drives per set.
INFO: WARNING: Host local has more than 0 drives of set. A host failure will result in data becoming unavailable.
MinIO Object Storage Server
Copyright: 2015-2026 MinIO, Inc.
License: GNU AGPLv3 - https://www.gnu.org/licenses/agpl-3.0.html
Version: RELEASE.2025-09-07T16-13-09Z (go1.24.6 linux/arm64)
API: http://10.217.0.66:9000  http://127.0.0.1:9000
WebUI: http://10.217.0.66:9090 http://127.0.0.1:9090
Docs: https://docs.min.io

The URLs specified here are the log output from a standard install. We can’t use those as they only work inside the Kubernetes cluster.

Check the route:

oc get route minio-ui -o wide

You should see something like:

NAME       HOST/PORT                           PATH   SERVICES        PORT   TERMINATION     WILDCARD
minio-ui   minio-ui-default.apps-crc.testing          minio-service   ui     edge/Redirect   None

So https://minio-ui-default.apps-crc.testing should work in your browser (use minio/minio12345 as username and password).

Create a bucket using the UI; I’ll call mine cnpg.

Before we install the CNPG operator we need to set up a Secret for CNPG Backup to use.

Connect as developer in the terminal, create a project for cnpg (cnpg-developer) and create the secret:

oc login -u developer https://api.crc.testing:6443
oc new-project cnpg-developer
oc create secret generic cnpg-minio-creds \
  -n cnpg-developer \
  --from-literal=ACCESS_KEY_ID=minio \
  --from-literal=ACCESS_SECRET_KEY=minio12345

Obtain the EDB subscription token

On the EDB home page, once you have logged in, you can find your token in “My account” → “Account Settings”. It’s the “Repos 2.0 token” on this page.

Note: if you don’t have an EDB account, you can create one (it’s free) and request a token. This will provide you with access for 30 days, without a subscription.

Install CNPG operator

Prior to installing the EDB CNPG Operator, you need to create a pull secret for the operator to use (even the install process needs that pull secret).

The pull secret will be created in the openshift-operators namespace. This is where the CNPG operator will be installed, and where it expects to find the pull secret. The operator will automatically copy this secret into <CLUSTER-NAME>-pull for each deployed cluster.

Note: once the secret exists in the workload namespace, anyone with permission to read secrets in that namespace can extract and decode it — so placing the pull secret in openshift-operators only limits who can see the original secret; it does not prevent exposure in the target namespace. In general, a good rule of thumb in both Kubernetes and OpenShift is “Secrets are not secret”: they are base64-encoded text strings. The encoding simply prevents “casual” reading. A base64 decode is all that is needed to read the original content.

export EDB_SUBSCRIPTION_TOKEN="**** MY TOKEN ***"
oc create secret docker-registry postgresql-operator-pull-secret \
  -n openshift-operators \
  --docker-server=docker.enterprisedb.com \
  --docker-username=k8s \
  --docker-password="$EDB_SUBSCRIPTION_TOKEN"

After the secret is created navigate to the Software Catalog and search for “EDB Postgres for Kubernetes”. Installing it is a simple click on install.

Deploy PostgreSQL cluster with Barman backup and WAL streaming to MinIO

Now all the “plumbing” should be done, and we can get to the fun stuff: deploying clusters and demoing CNPG features.

For now, let’s deploy our first cluster:

apiVersion: postgresql.k8s.enterprisedb.io/v1
kind: Cluster
metadata:
  name: pg-demo
  namespace: cnpg-developer
spec:
  instances: 1
  storage:
    size: 5Gi
  backup:
    barmanObjectStore:
      destinationPath: s3://cnpg/pg-demo
      endpointURL: http://minio-service.default.svc:9000
      s3Credentials:
        accessKeyId:
          name: cnpg-minio-creds
          key: ACCESS_KEY_ID
        secretAccessKey:
          name: cnpg-minio-creds
          key: ACCESS_SECRET_KEY
      wal:
        compression: gzip
        maxParallel: 4
      data:
        compression: gzip
      retentionPolicy: "7d"

This YAML creates a simple Postgres cluster with a single instance.

Note that the endpoint for MinIO is http://minio-service.default.svc:9000 since MinIO is deployed in the default namespace.

With this you should see PostgreSQL starting to archive WALs into the bucket:

oc get pods
oc logs pg-demo-1

You should see files popping into the MinIO Web console as well.

What we have done so far

In this post we have:

  • Created an OpenShift cluster using “Red Hat OpenShift Local” (formerly known as Code Ready Containers, hence the crc name of the utility)
  • Installed and configured open source MinIO to use as the destination for backup- and WAL-files from CNPG clusters
  • Installed the EDB CNPG operator from the Red Hat Operator Hub
  • Deployed a simple CNPG cluster with a single instance
  • Validated that WAL files are archived in MinIO
]]>
116
Mastodon: How toots are distributed between timeline https://michaelwiller.dk/2022/11/23/mastodon-how-toots-are-distributed-between-timeline/ Wed, 23 Nov 2022 15:17:20 +0000 https://michaelwiller.dk/?p=87 On Mastodon @zatnosk@helvede.net shared the image below about where a Toot is displayed.

Since I’m learning Python and Python in my view is so readable that anyone, I thought I’d share it here with a bit of (incomplete) Python code implementing the diagram. (edit: diagram removed, as the code brought a semantic error to light)

This piece of code is how I understand the decisions – but that might just be me…

def display_toot(toot,my_user):
  '''
  An incomplete function showing how public toots will be
  displayed on respective timelines.
  This code is not representative of any Mastodon API.
  It is simply a way for the writer to understand the
  decisions on where a toot is shown.
  '''
  if is_public(toot):
    if toot.user.followed_by(my_user):
      show_on_home_timeline(toot)
    else:
      if toot.user.on_server(my_user.server):
        show_on_local_timeline(toot)
      else:
        everyone_followed_on_server =
          get_all_followed_on(my_user.server)
        if (
              toot.user.followed_by_any( 
                everyone_followed_on_server)
              or
              toot.boosted_by_any(
                everyone_followed_on_server)
              or 
              toot.response_from_any_on(my_user.server)
           ):
              show_on_federated_timeline(toot)
  else:
    pass # Incomplete. Non-public toots missing
]]>
87
PostgreSQL High Availability on Kubernetes https://michaelwiller.dk/2021/02/21/postgresql-high-availability-on-kubernetes/ Sun, 21 Feb 2021 16:36:14 +0000 https://michaelwiller.dk/?p=55

In this post I will discuss why single-node PostgreSQL deployments are not a viable way to run PostgreSQL on Kubernetes in Production, as well as an overview of what needs to be done to protect yourself from data loss and downtime.

Why this post?

A few months ago I was in a call with a possible customer regarding their PostgreSQL workloads, support and requirements for High Availability (HA). The assigned seller and I tried to explain to a them what HA actually entailed. Their techie, on the call, insisted that they would deploy PostgreSQL to Kubernetes with PVC and by doing so would attain HA with no extra work, refusing to listen to why this was not enough.

As part of a Sales organisation I can easily pass this off as “just a lost sale”. Annoying, true. But no huge problem.

But the Techie in me can’t stop thinking about the consequence for the company. They think that they have a HA setup but they really don’t. My worry is that they will lose their data at some point.

It seems to me that the business side don’t realise how little the Kubernetes features actually help, when it comes to stateful deployments on Kubernetes. For true Production worthy deployments – you’ll need an operator to automate the deployment.

This post tries to explain why Kubernetes isn’t a Silver Bullet for highly available stateful workloads. We’ll use a PostgreSQL database as an example here. But I’m fairly sure the observations made here applies to other stateful deployments as well.

Stateless vs. Stateful deployments

Let first define Stateless vs. Stateful.

Stateless means that the calls coming in to an application doesn’t make change to the application – a call to a specific resource will always return the same result, regardless of what came before. Think of this as static HTML: no matter how often you load the homepage, it will never change.

Now lets expand this a bit. An application may have a stateful backend. For example a wiki uses some sort of backend to store the actual content of the pages. But, the wiki application itself doesn’t store anything. This means that you could kill the application, move it elsewhere (maybe a bigger server), hook it up to the backend storage .. and it would produce the same pages. Point being that the application itself (the wiki engine) can be replaced by a copy with no adverse effect. You could even run multiple wiki-engines connecting to the same backend storage. And they would all be identical.

Stateful, on the other hand, contains internal state. The storage backend for the wiki is a perfect example. Typically this is a database, like MySQL. If you were to update a row in the database, that would be a change in state. If you were to copy the database, you would now have two databases but since one is being used .. they will have different state after a while (since someone changed something on a page). If you used the copy of the original database instead – then all the changes made since the copy would be lost.

Kubernetes was originally built to manage stateless deployments. Stateful deployments have become possible relatively recently.

The single-node Kubernetes deployment

A typical single-node Kubernetes PostgreSQL deployment is just that: a single node (think: server) with a persistent volume (disk storage) attached.

If the PostgreSQL node fails, Kubernetes will create a new running node with the same Volume to the node.

This is the way Kubernetes self-heals: Failing nodes are replaced by new copies, identical to the originally deployed node.

Single-node deployment

Why is this not High Availability?

This type of self-healing is fine for Stateless workloads. For Stateful workloads, such as a database, this is not enough. To understand why, we need to take a quick look into how databases are set up without Kubernetes, and why this is done.

Standard Database – High Availability Setups

When setting up a High Availability database we want to set up more than one database – at least two: a Primary database and a Standby database. In many cases more that two databases. Changes to data are replicated between the databases – logical or physical replication, or even a combination.

The Primary database is the one applications will use to update the state/contents of the database.

The standby database is there to take over, when the Primary fails. The is process is known as failover.

The “Replication and Failover Management” process is a simplified way of showing all the different processes monitoring the database and ensuring that failover is performed correctly.

Failover happens can happen for a number of reasons. For example the server running the database can lose power, a disk can fail, .. any number of reason. In some cases restarting the database, with extra work needed is possible. In some case however that is not the case.

This type of setup is done for many reason:

  1. It allows failover, which will allow the applications to continue their work without too much interruption, should the active server fail.
  2. It safe-guards the data contained in the database. By replicating the data, that very act ensures that you have at least one clean copy of your data, should a hardware- or software-error result in file corruption.

Why you should avoid single-node database deployments?

Single-node database deployment (as the one illustrated above) are at risk of losing not only availability but also losing data.

One type of failure, where “restarting the database” with a new node deployed is not possible, is datafile corruption.

This type of failure is the result of a failed write to the one of the files used to maintain state in the database. In essence these files are the content of the tables and other objects in the database.

If such a datafile contains a faulty write – and this could be anything from a single wrong byte to several pages or blocks missing – the database will fail to read this area and generate an unrecoverable error.

No database can recover from this error automatically. This goes for databases running Kubernetes as well. No amount of self-healing in the cluster can resolve this – because the problem is not in the node running the database. It’s in the filesystem backing the database.

The only way to guard against this type of error, is by running a setup inside Kubernetes that looks like the ones run outside. In other words: Kubernetes is not a Silver Bullet when it comes to Stateful Deployments.

Where to find more information

There are several places on the web. For Kubernetes in general I would suggest http://kubernetes.io. For PostgreSQL http://postgresql.org and http://edbpostgres.com.

For information on different ways to deploy PostgreSQL, EDB maintains a list of Reference Architectures on GitHub.

For deploying PostgreSQL on Kubernetes (as it should be done) I would suggest Cloud Native Postgres from EDB

Kubernetes logo by kubernetes.io
PostgreSQL logo by PostgreSQL.org

]]>
55
On using tls certificates and .ssh/config. https://michaelwiller.dk/2021/01/26/on-using-tls-certificates-and-ssh-config/ Tue, 26 Jan 2021 17:49:48 +0000 http://michaelwiller.dk/?p=12 Just a quick note here on TLS certificates. Because I had to look it up and figure it out. Again!

It is possible to define several keys for a site and login as different users using each certificate.

I found myself needing to do just that for github.com, as my employer has private repositories there that I need to access.

Adding something like this to $HOME/.ssh/config

Host github-personal
    HostName github.com
    IdentityFile ~/.ssh/id_rsa_personal

Host github-edb
    HostName github.com
    IdentityFile ~/.ssh/id_rsa_edb

Host gitlab-personal
    HostName gitlab.com
    IdentityFile ~/.ssh/id_rsa_personal

So instead of

git clone git@github.com:EnterpriseDB/somerepo.git

I’ll write:

$ git clone git@github-edb:EnterpriseDB/somerepo.git

or

$ git clone git@github-personal:michaelwiller/somerepo.git

… and the correct certificate will be applied to log me in.

The same can be used for ssh shortcut names for servers and users. See this post as a reference.

Photo by Markus Winkler on Unsplash ]]>
12
New professional role https://michaelwiller.dk/2020/07/26/new-professional-role/ https://michaelwiller.dk/2020/07/26/new-professional-role/#respond Sun, 26 Jul 2020 17:08:24 +0000 http://michaelwiller.dk/?p=6 A year ago I started at EDB.

Since then my blog has been silent.

I aim to change that, I promise.

I have just moved my hosting. And since I haven’t written anything useful in over a year, I decided that now was a good time to reset the blog, and start again…

So, information incoming.. but be patient.

]]>
https://michaelwiller.dk/2020/07/26/new-professional-role/feed/ 0 6