How to set the nodeSelector for deployment? #4779
Answered
by
rohanKanojia
hanming-nls
asked this question in
Q&A
-
May I know what is the equivalent of setting the nodeSelector in the yaml under the spec as below apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
nodeSelector:
nodetype: worker It seems that the DeploymentSpec object do include the nodeSelector but the DeploymentSpec selector uses a LabelSelector instead of a NodeSelect. I'm not sure how can I specify the NodeSelector in the DeploymentSpec, thus, would greatly appreciate any advice. |
Beta Was this translation helpful? Give feedback.
Answered by
rohanKanojia
Jan 19, 2023
Replies: 1 comment 1 reply
-
NodeSelector seems to be in PodTemplate rather than DeploymentSpec: new DeploymentBuilder()
.withNewMetadata()
.withName("deploy1")
.endMetadata()
.withNewSpec()
.withReplicas(1)
.withNewSelector()
.addToMatchLabels("app", "nginx")
.endSelector()
.withNewTemplate()
.withNewSpec()
.addNewContainer()
.withName("nginx")
.withImage("nginx:1.7.9")
.addNewPort().withContainerPort(80).endPort()
.endContainer()
.addToNodeSelector("nodetype", "worker")
.endSpec()
.endTemplate()
.endSpec()
.build(); |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
hanming-nls
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
NodeSelector seems to be in PodTemplate rather than DeploymentSpec: