Run specific Pods only on specific Node
1 min readMay 24, 2022
Taint the node with NO_SCHEDULE
EKS with existing eks cluster, vpc, subnets & securityGroup.
Add taints
apiVersion: eksctl.io/v1alpha5
kind: ClusterConfig
metadata:
name: my-service-eks-xE
region: us-east-2
vpc:
id: "vpc-foo" # (optional, must match VPC ID used for each subnet below)
securityGroup: "sg-foo" # (optional, must match VPC ID used for each subnet below)
# cidr: "192.168.0.0/16" # (optional, must match CIDR used by the given VPC)
subnets:
# must provide 'private' and/or 'public' subnets by availibility zone as shown
private:
us-east-2b:
id: "subnet-foob"
# cidr: "192.168.128.0/19" # (optional, must match CIDR used by the given subnet)
us-east-2c:
id: "subnet-fooc"
# cidr: "192.168.64.0/19" # (optional, must match CIDR used by the given subnet)
us-east-2a:
id: "subnet-fooa"
# cidr: "192.168.0.0/19" # (optional, must match CIDR used by the given subnet)
managedNodeGroups:
- name: new-subnet-nodegroup
instanceType: t2.medium
desiredCapacity: 1
maxSize: 10
minSize: 1
privateNetworking: true
labels:
role: only4appbuilds
# taints:
# - key: only4appbuilds
# value: true
# effect: NO_SCHEDULE
tags:
k8s.io/cluster-autoscaler/node-template/label/role: only4appbuilds
k8s.io/cluster-autoscaler/node-template/taint/feaster: "true:NoSchedule"
Schedule a pod
add nodeSelector
to make sure that the this pod is not scheduled on any other nodes
AND
add tolerations
to ensure that pods are scheduled only on this node.
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginxdeployment
spec:
replicas: 6
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
nodeSelector:
role: only4appbuilds
containers:
- name: nginx
image: nginx
imagePullPolicy: IfNotPresent
tolerations:
- key: "onlyappbuilds"
operator: "Equal"
value: "true"
effect: "NoSchedule"