K3S Pod stuck in pending: "node(s) had volume node affinity conflict"

44 Views Asked by At

I set up a single-node cluster using K3S and am trying to deploy my first application to it. I'm using a local persistent volume for storage.

The pod is stuck in pending with the following warning:

"Warning FailedScheduling 16m (x2 over 21m) default-scheduler 0/1 nodes are available: 1 node(s) had volume node affinity conflict. preemption: 0/1 nodes are available: 1 Preemption is not helpful for scheduling.."

While both the pv and the pvc are "bound" with no events.

I put my whole configuration in one file:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: vaultwarden
spec:
  selector:
    matchLabels:
      app: vaultwarden
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: vaultwarden
    spec:
      containers:
      - image: vaultwarden/server
        name: vaultwarden
        volumeMounts:
        - name: vaultwarden-storage
          mountPath: /data
        ports:
        - containerPort: 80
          name: vaultwarden
      volumes:
      - name: vaultwarden-storage
        persistentVolumeClaim:
          claimName: vaultwarden-pvc
# Network
---
apiVersion: v1
kind: Service
metadata:
  name: vaultwarden-service
spec:
  ports:
  - name: vaultwarden
    port: 80
    targetPort: vaultwarden
  selector:
    app: vaultwarden
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: vaultwarden-ingress
spec:
  rules:
  - http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: vaultwarden-service
            port:
              name: vaultwarden
# Storage
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: vaultwarden-pvc
spec:
  storageClassName: ""
  volumeName: vaultwarden-pv
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 32Gi
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: vaultwarden-pv
spec:
  local:
    path: /var/container-data/vaultwarden
  capacity:
    storage: 32Gi
  volumeMode: Filesystem
  persistentVolumeReclaimPolicy: Retain
  storageClassName: ""
  accessModes:
    - ReadWriteOnce
  nodeAffinity: 
    required:
      nodeSelectorTerms:
      - matchExpressions:
        - key: name
          operator: In
          values:
          - homeserver


I made sure that the local path exists, and that the name of the node really is "homeserver".

Any ideas on how to approach this issue?

1

There are 1 best solutions below

0
Felix B. On

Apparently matching on the key "name" is not the same as matching on the name. The key name did of course not exist. i replaced it with

- key: kubernetes.io/hostname
  operator: In
  values:
  - homeserver

Now it works