Home > Back-end >  How can I deploy pods in the same node in AWS EKS
How can I deploy pods in the same node in AWS EKS

Time:11-11

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?

CodePudding user response:

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

  • Related