
nodeAffinity 추가
Requirements:
Use requiredDuringSchedulingIgnoredDuringExecution node affinity
Key: color
Value: blue
Operator - 키값만
Name: red
Replicas: 2
Image: nginx
NodeAffinity: requiredDuringSchedulingIgnoredDuringExecution
Key: node-role.kubernetes.io/control-plane
Use the right operator
주요 operator 종류
operator 설명
In 값이 지정한 리스트 안에 있으면 매칭
NotIn 값이 지정한 리스트에 없으면 매칭
Exists 해당 key가 노드에 존재하면 매칭
DoesNotExist 해당 key가 노드에 없으면 매칭
Gt 값이 정수형일 때 key의 값이 지정 값보다 크면 매칭
Lt 값이 정수형일 때 key의 값이 지정 값보다 작으면 매칭
k create deploy red --image=nginx --replicas=2 --dry-run=client -o yaml > red.yaml
vi red.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: red
name: red
spec:
replicas: 2
selector:
matchLabels:
app: red
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: red
spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: node-role.kubernetes.io/control-plane
operator: Exists
containers:
- image: nginx
name: nginx
resources: {}
status: {}
spec.affinity 부분 추