-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTaintTolerations.txt
138 lines (110 loc) · 2.48 KB
/
TaintTolerations.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# syntax to taint node
k taint node node-name key=value:taint-effect
>> there are 3 taint-effect
a. NoSchedule
b. PreferNoSchedule
c. NoExecute
e.g
k taint nodes node1 app:blue:NoSchedule
#Tolerations - pods
>> pod-definition.yaml
apiVerison: v1
kind: Pod
metadata:
name: myapp-pod
spec:
containers:
- name: nginx-container
image: nginx
tolerations:
- key: "app"
operator: "Equal"
value: "blue"
effect: NoSchedule
#Label
kubectl label node node01 color=blue
#Taints
kubectl describe node node01 | grep -i taints
kubectl taint nodes node01 spray=mortein:NoSchedule
# cmd to view default enabled admission Controllers
kube-apiserver -h | grep enable-admission-plugins
# tain-tolerations syntax
kubectl taint node node-name key=vlaue:taint-effect
#here type of taint-effect
NoSchedule
PreferNoSchedule
NoExecute
# example to apply taint on node
kubectl taint nodes node1 app=blue:NoSchedule
# example to remove tainet on node
kubectl taint node node1 blue:NoSchedule-
# pod-with-tai n-tolerations.yaml
apiVersion: v1
kind: Pod
metadata:
name: myapp-pod
spec:
containers:
- name: nginx-container
image: nginx
tolerations:
- key: "app"
operator: "Equal"
value: "blue"
effect: "NoSchedule"
# on master node bydefault NoSchedule taint will be get applied
$ kubectl describe node kubemaster | grep taint
# node selector
first label your node
kubectl label nodes node-name label-key=label-value
example
kubectl label nodes node-1 size=Large
# pod-definition-node-selector.yaml
apiVerison: v1
kind: Pod
metadata:
name: myapp-pod
spec:
containers:
- name: data-processor
image: data-processor
nodeSelector:
size: Large
# with NodeSelector we cannot provide
- Large or Medium
- NOT small
so we have to use node affinity
# Node affinity
Types of node Affinity
- Available
requiredDuringSchedulingIgnoredDuringExecution
preferredDuringSchedulingIgnoredDuringExecution
- Planned
RequiredDuringSchedulingRequiredDuringExecution
kubect create deployment blue --image=nginx --replicas=3
kubectl describe node node1 | grep taints
./script-name.sh
sh script-name.sh
bash script-name.sh
# replicaset-definition.yaml
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: simple-webapp
labels:
app: App1
function: Front-end
spec:
replicas: 3
selector:
matchLabels:
app: App1
template:
metadata:
labels:
app: App1
function: Front-end
spec:
containers:
- name: simple-webapp
image: simple-webapp