Problem I need to solve: Running mongoDB on specific K3s node(s).

My mongoDB 4.x - 6.x upgrade failed miserably, as mongoDB version 6.x (and 5.x) only support processers with Advanced Vector Extensions (AVX) support - and my hardware do not support AVX. AVX is quit commonly supported (also on older CPU’s) but not on this specific hardware (Intel J4105).  Not an option to replace the hardware, so added 2xAMD GX-222GC. Result is 4xJ4105 which cannot run mongoDB and 2xGX-222GC than can run version 5/6.x. Therefore, need to make sure mongoDB is only deployed on the last two GX-222GC nodes.

Intel J4105 (2017): www.cpu-world.com
AMD GX-222GC (2015): www.cpu-world.com

As with anything K8s there is ten different ways of doing this. My simple requirement was to make sure mongoDB was only deployed on two specific nodes: A static setup (nodes don't chance CPU) and not concerned with other deployments. I added the necessary node constrains with nodeSelector/labels (kubernetes.io/docs) First added labels to the two GX-222GC nodes (node6 and node7). I went with: 'flag=avx' but anything is fine.

kubectl label nodes node6 flag=avx
kubectl get nodes --show-labels| grep avx
node6   Ready    agent                       45h   v1.24.10+k3s1   beta.kubernetes.io/arch=amd64, beta.kubernetes.io/instance-type=k3s,beta. kubernetes.io/os=linux,egress.k3s.io/cluster=true,flag=avx,kubernetes.io/arch=amd64,kubernetes.io/hostname=node6, kubernetes.io/os=linux,kubernetes.io/role=agent,node.kubernetes.io/instance-type=k3s
node7   Ready    agent                       45h   v1.24.10+k3s1   beta.kubernetes.io/arch=amd64, beta.kubernetes.io/instance-type=k3s,beta. kubernetes.io/os=linux,egress.k3s.io/cluster=true,flag=avx,kubernetes.io/arch=amd64,kubernetes.io/hostname=node7, kubernetes.io/os=linux,kubernetes.io/role=agent,node.kubernetes.io/instance-type=k3s

Added the 5 lines below in the values.yaml file:

  nodeSelector:
    flag: avx
  arbiter:
    nodeSelector:
      flag: avx

And run something like: "helm install -f values.yaml mongo bitnami/mongodb --version 13.8.1 --create-namespace --namespace mongodb". Could be anything.

Not solved: If no 'flag=avx' label is found on any nodes, the helm chart will still (try to) deploy mongodb on any node.