Mixing CPU/Memory Resources and nodeSelectors fails

9/8/2017

I've got an ACS k8s Windows cluster setup and working. Early on I discovered I needed to use a nodeSelector or k8s would try and assign my pods to the master node (Linux) even though my container images are Windows. I used this:

  nodeSelector:
    beta.kubernetes.io/os: windows

Now I'm trying to assign memory and cpu resources to my pods and k8s is unable to find a suitable node. It shows this error:

No nodes are available that match all of the following predicates:: Insufficient memory (2), MatchNodeSelector (1)

I have a super small resource assignment and my nodes have plenty of room for these:

  resources:
    requests:
      memory: 1Mi

And here is the full k8s deployment yaml:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: forest-worker-res
spec:
  replicas: 1
  revisionHistoryLimit: 0
  selector:
    matchLabels:
      app: forest-worker
  template:
    metadata:
      labels:
        app: forest-worker
        env: debug
    spec:
      containers:
        - name: forest-worker
          image: intmadras.azurecr.io/forest-worker
          resources:
            requests:
              memory: 10Mi
      nodeSelector:
        beta.kubernetes.io/os: windows
      imagePullSecrets:
        - name: azurereg

If I remove the nodeSelector then the depoyment proceeds but again fails because k8s assigns it to the master node. So I'm stuck. How do I use a nodeSelector and assign resources?

-- BrettRobi
azure-container-service
kubernetes

1 Answer

9/16/2017

@BrettRobi What is the version of k8s you have deployed? k8s windows node doesn't have node metric (cpu, memory, etc.) implemented in 1.6 and was added to 1.7 recently. So nodeSelector is required to deploy to windows node. Can you verify if kubectl describe nodes, windows node has node metric shown correctly?

-- jiangtli
Source: StackOverflow