Selecting nodes based on architecture

I’m running a test cluster on Raspberry Pis and one bigger machine as master and agent.

Cluster information:

Kubernetes version: v1.17.2+k3s1
Cloud being used: bare-metal (raspberry pis and x86 machine)
Installation method: k3s
Host OS: Ubuntu 18.04.4 LTS or 18.04.3 LTS
CNI and version: flannel v0.3.1 I believe
CRI and version:

Version:  0.1.0
RuntimeName:  containerd
RuntimeVersion:  v1.3.3-k3s1
RuntimeApiVersion:  v1alpha2

Some helm charts however don’t have arm or arm64 images and I would like to limit scheduling of those charts to machine with specific architectures.
What would be the most appropriate way to do so?
I see there are several labels and some other info which could be used, so I’m unsure which one to select and how.

$ kubectl get node rpi3p -o json
{
    "apiVersion": "v1",
    "kind": "Node",
    "metadata": {
        "..." // some other info
        "labels": {
            "beta.kubernetes.io/arch": "arm64",
            "beta.kubernetes.io/instance-type": "k3s",
            "beta.kubernetes.io/os": "linux",
            "k3s.io/hostname": "rpi3p",
            "k3s.io/internal-ip": "10.0.0.105",
            "kubernetes.io/arch": "arm64",
            "kubernetes.io/hostname": "rpi3p",
            "kubernetes.io/os": "linux",
            "node-role.kubernetes.io/master": "true",
            "node.kubernetes.io/instance-type": "k3s"
        },
        "name": "rpi3p",
        "..." // other info
    },
    "spec": {
        "podCIDR": "10.42.0.0/24",
        "podCIDRs": [
            "10.42.0.0/24"
        ],
        "providerID": "k3s://rpi3p"
    },
    "status": {
        "addresses": [
            {
                "address": "10.0.0.105",
                "type": "InternalIP"
            },
            {
                "address": "rpi3p",
                "type": "Hostname"
            }
        ],
        "allocatable": {
            "cpu": "4",
            "ephemeral-storage": "29642188777",
            "memory": "933992Ki",
            "pods": "110"
        },
        "capacity": {
            "cpu": "4",
            "ephemeral-storage": "30471000Ki",
            "memory": "933992Ki",
            "pods": "110"
        },
        "conditions": [ ... ],
        "daemonEndpoints": { ... },
        "images": [ ... ]
        "nodeInfo": {
            "architecture": "arm64",
            "bootID": "37de8048-af37-419e-89cb-c02187d29280",
            "containerRuntimeVersion": "containerd://1.3.3-k3s1",
            "kernelVersion": "4.15.0-1054-raspi2",
            "kubeProxyVersion": "v1.17.2+k3s1",
            "kubeletVersion": "v1.17.2+k3s1",
            "machineID": "a3c14b5eccab4034a96aa9de3ae0b371",
            "operatingSystem": "linux",
            "osImage": "Ubuntu 18.04.4 LTS",
            "systemUUID": "a3c14b5eccab4034a96aa9de3ae0b371"
        }
    }
}

Can I select by status.nodeInfo.architecture? Are labels better?
Thank you.

You can use nodeSelector on your pods to specify labels of the nodes you want to deploy to. The simplest solution is probably to add a specific label on the nodes you want to deploy your pods. See Assigning Pods to Nodes - Kubernetes for more information

Thank you.
So nodeSelector works on labels only and can’t select based on status.nodeInfo.architecture.
In that case kubernetes.io/arch would seem the most appropriate.

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:
    kubernetes.io/arch: arm64
1 Like