Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to exclude labels with nodeSelector?

Tags:

kubernetes

i want to do something like

nodeSelector:
  role: "!database"

in order to schedule pods on nodes which don't host the database.

Thank you

like image 657
Smana Avatar asked Oct 17 '15 17:10

Smana


People also ask

What is difference between labels and selectors in Kubernetes?

Labels can be used to organize and to select subsets of objects. Via a label selector, the client/user can identify a set of objects. The label selector is the core grouping primitive in Kubernetes. In a nutshell label selectors depend on labels to select a group of resources such as pods.

What is nodeSelector?

A node selector specifies a map of key/value pairs that are defined using custom labels on nodes and selectors specified in pods. For the pod to be eligible to run on a node, the pod must have the same key/value node selector as the label on the node.


2 Answers

from here: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/

apiVersion: v1
kind: Pod
metadata:
  name: with-node-affinity
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: role
            operator: NotIn
            values:
            - database
like image 82
avloss Avatar answered Nov 22 '22 16:11

avloss


Not right now.

Such a form was initially discussed in issue #341 and you can follow issue #15494 to track progress on a more configurable label selector.

like image 40
Robert Bailey Avatar answered Nov 22 '22 15:11

Robert Bailey