-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample-03.yml
225 lines (225 loc) · 4.78 KB
/
example-03.yml
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
---
apiVersion: v1
kind: Namespace
metadata:
name: example-03
---
apiVersion: k8s.consol.de/v1beta1
kind: NamespaceManager
metadata:
name: przyklad-trzeci
namespace: example-03
spec:
namespace: example-03
policies:
- name: scale down deployments and stateful sets when specific pods succeed
condition:
type: PODS_SUCCEED
params:
podLabels:
component: main
initialDelaySeconds: 60
periodSeconds: 10
action:
type: SCALE_DOWN
params:
selectors:
- kind: Deployment
labels:
### these are labels on Deployments
### and not the labels of their Pods
isScaleDown: "yes"
- kind: StatefulSet
### no "labels" property
### so all StatefulSets
### are going to be scaled down
---
apiVersion: v1
kind: ConfigMap
metadata:
name: helper-scripts
namespace: example-03
data:
simulate-long-running-test.sh: |-
#!/usr/bin/env sh
set -e
echo simulating long running test
COUNTER=0
while [ ${COUNTER} -lt ${MOCK_TEST_ITERATIONS:-20} ]; do
COUNTER=`expr ${COUNTER} + 1`
sleep ${MOCK_TEST_SLEEP_SECONDS:-3}
echo finished iteration ${COUNTER}
done
if [ ! -z "${MOCK_TEST_SIMULATE_FAILURE}" ]; then
echo simulating failure
exit 1
fi
echo success
---
apiVersion: batch/v1
kind: Job
metadata:
name: my-lonely-chivalrous-careful-app
namespace: example-03
spec:
completions: 3
parallelism: 2
backoffLimit: 0
template:
metadata:
labels:
app: test-app-03
component: main
spec:
restartPolicy: Never
containers:
- name: main
image: alpine
### uncomment to test
### that operator will not
### scale down the namespace
# env:
# - name: MOCK_TEST_SIMULATE_FAILURE
# value: "yes"
command:
- "/opt/helper-scripts/simulate-long-running-test.sh"
volumeMounts:
- mountPath: /opt/helper-scripts
name: helper-scripts
volumes:
- name: helper-scripts
configMap:
name: helper-scripts
defaultMode: 0555
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-marked-comfortable-curious-app
namespace: example-03
labels:
### it will be scaled down
isScaleDown: "yes"
spec:
replicas: 5
selector:
matchLabels:
app: test-app-03
component: c1
template:
metadata:
labels:
app: test-app-03
component: c1
spec:
containers:
- name: main
image: alpine
args:
- "sh"
- "-c"
- "while sleep 10; do echo memory stats:; free; echo; done"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: my-hot-amusing-protective-app
namespace: example-03
### it will not be scaled down
spec:
replicas: 3
selector:
matchLabels:
app: test-app-03
component: c2
template:
metadata:
labels:
app: test-app-03
component: c2
spec:
containers:
- name: main
image: alpine
args:
- "sh"
- "-c"
- "while sleep 10; do echo memory stats:; free; echo; done"
---
apiVersion: v1
kind: Service
metadata:
name: my-outrageous-seemly-unarmed-app
namespace: example-03
spec:
ports:
- port: 80
name: web
selector:
app: test-app-03
component: c3
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: my-outrageous-seemly-unarmed-app
namespace: example-03
spec:
serviceName: my-outrageous-seemly-unarmed-app
replicas: 3
selector:
matchLabels:
app: test-app-03
component: c3
template:
metadata:
labels:
app: test-app-03
component: c3
spec:
containers:
- name: main
image: alpine
args:
- "sh"
- "-c"
- "while sleep 10; do echo memory stats:; free; echo; done"
---
apiVersion: v1
kind: Service
metadata:
name: my-imminent-whispering-wholesale-app
namespace: example-03
spec:
ports:
- port: 80
name: web
selector:
app: test-app-03
component: c4
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: my-imminent-whispering-wholesale-app
namespace: example-03
spec:
serviceName: my-imminent-whispering-wholesale-app
replicas: 3
selector:
matchLabels:
app: test-app-03
component: c4
template:
metadata:
labels:
app: test-app-03
component: c4
spec:
containers:
- name: main
image: alpine
args:
- "sh"
- "-c"
- "while sleep 10; do echo memory stats:; free; echo; done"