How to pass nodeSelector for deployment config

Latest response

Hi,

I'm playing a bit with OpenShift - testing it really and let's say I want to configure node independency within the same cluster in a way that live pods are hosted on live nodes, test pods can share live nodes (if resources allow) based on the label. It's not the live example etc, I'm testing on my own VMs at the moment some use cases.
So let's say in the 'potential' cluster I could have 10 nodes whereas 4 out of 10 would have a label 'environment=test'. What I want is to configure deployment and build config that all the builds and pod placements for the desired project will only be deployed to the nodes with label 'environment=test'. Is this achievable at all? I only found solution to configure builds to happen on selected node and deployment for pod to happen by specifying a node hostname so not really something I need.

Thanks!

Responses

to achieve this I would recommend changing node-selector for your project

oc edit namespace your-project-name

annotations:
    openshift.io/node-selector: "environment=test"

HTH :)

Swapnil

Also see the following link on how to do this multiple ways. How to force a pod to schedule to a specific node in OpenShift Container Platform

Hi,

Thanks for your input.

Yeah I knew you could set that project-wide using oadm new-project test --node-selector='environment=testing' --admin='user' but on that stage the entire project is tied to the specific namespace + when the user will delete the project and recreate it... that namespace is gone. I have read that you can specify that per pod so in theory you can have 1 project which can run your test and live pods depends on how user will label it. This is what I was really about.

@Ryan - yes, please read my last sentence "I only found solution to configure builds to happen on selected node" but this is something I don't want as if the node will go down you lose all the pods and they won't be scheduled anywhere as they won't find appropriate fit.

Regards, Jarek

@jgrzabel - I think I need to better explain this in the Knowledge Solution. It outlines using nodeSelector and in the example the nodeSelector is pointing to a label specific to only one node. It is possible to use a nodeSelector that references a label that is tied to a group of nodes.

apiVersion: v1
kind: DeploymentConfig
  template:
    spec:
      nodeSelector:                                    ### ADD
        environment: testing                      ### ADD

How to force a pod to schedule to a specific node using nodeSelector in OCP

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.