-
Notifications
You must be signed in to change notification settings - Fork 4.1k
/
Copy pathnginx-priority.yaml
94 lines (94 loc) · 1.55 KB
/
nginx-priority.yaml
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
#
# Balancer scaling 2 deployments using priority policy.
#
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-1
labels:
app: nginx-1
srv: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx-1
srv: nginx
template:
metadata:
labels:
app: nginx-1
srv: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-2
labels:
app: nginx-2
srv: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx-2
srv: nginx
template:
metadata:
labels:
app: nginx-2
srv: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
---
apiVersion: balancer.x-k8s.io/v1alpha1
kind: Balancer
metadata:
name: nginx
spec:
replicas: 5
selector:
matchLabels:
srv: nginx
policy:
policyName: priority
priorities:
targetOrder: [nginx-1,nginx-2]
fallback:
startupTimeoutSeconds: 180
targets:
- name: nginx-1
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: nginx-1
minReplicas: 1
maxReplicas: 7
- name: nginx-2
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: nginx-2
minReplicas: 1
---
apiVersion: v1
kind: Service
metadata:
name: nginx
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
srv: nginx