0

I want to deploy pods in the same node in the EKS cluster.

for e.g if I deploy with the following command

kubectl apply -f <deployment.yaml>

is there a way to assign the deployments to a specific node?

1 Answer 1

2

Yes, you can use nodeSelector labels and pod affinity

NodeSelector example

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:
    disktype: ssd

Pod affinity example:

apiVersion: v1
kind: Pod
metadata:
  name: with-node-affinity
spec:
  affinity:
    nodeAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
        nodeSelectorTerms:
        - matchExpressions:
          - key: kubernetes.io/e2e-az-name
            operator: In
            values:
            - e2e-az1
            - e2e-az2

Documentation

Sign up to request clarification or add additional context in comments.

2 Comments

thanks for reaching out. What if I am using a kind: deployment instead of kind: Pod. Can I specify the nodeSelector in the template section of the file?
Yes, you can. Use the same syntax. The Deployment is just a "hat" over the Pod

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.