Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kubectl apply Deployment to specified Node Group - AWS EKS

I have created multiple stacks (node groups) within my EKS cluster, and each group runs on a different instance type (for example, one group runs on GPU instances). I have added an entry in mapRoles of aws-auth-cm.yaml file for each of the node groups. Now I would like to deploy some Deployments on another. The deployment files look something like this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-1
spec:
  replicas: 1
  selector:
    matchLabels:
      component: component-1
  template:
    metadata:
      labels:
        component: component-1
    spec:
      containers:
        - name: d1
          image: docker-container
          ports:
            - containerPort: 83

The documentation shows that I can run the standard command kubectl apply. Is there any way to specify the group? Maybe something like

kubectl apply -f server-deployment.yaml -group node-group-1

like image 862
Alessandro Avatar asked Jul 16 '26 03:07

Alessandro


1 Answers

Sadly something that you mentioned doesn't exist, but you can read about Affinity and it should solve your problem.

TL;DR you have to add labels or use existing labels on nodes and use these labels to assign pods to correct nodes.

Assuming you have label beta.kubernetes.io/instance-type=highmem

apiVersion: apps/v1
kind: Deployment
metadata:
  name: deployment-1
spec:
  replicas: 1
  selector:
    matchLabels:
      component: component-1
  template:
    metadata:
      labels:
        component: component-1
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: beta.kubernetes.io/instance-typ
                operator: In
                values:
                - highmem
      containers:
        - name: d1
          image: docker-container
          ports:
            - containerPort: 83
like image 160
FL3SH Avatar answered Jul 17 '26 22:07

FL3SH