-
Notifications
You must be signed in to change notification settings - Fork 0
/
example-02.yml
133 lines (133 loc) · 3.24 KB
/
example-02.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
---
apiVersion: v1
kind: Namespace
metadata:
name: example-02
---
apiVersion: k8s.consol.de/v1beta1
kind: NamespaceManager
metadata:
name: ejemplo-dos
### a manager does not have to reside
### in the same namespace it manages
namespace: namespace-manager
spec:
############################################################
### watch this flag
### to be flipped to true
### by the operator
### when the namespace deletion action
### gets applied
deactivated: false
### this flag
### can be set to true
### right at the creation
### (the manager will be then "dormant")
### and then it can be changed to false
### when one wants to activate the manager
############################################################
namespace: example-02
policies:
- name: delete namespace when specific pods succeed
condition:
type: PODS_SUCCEED
params:
### which pods need to be checked
podLabels:
component: main
type: test
### how much to wait before doing checks
initialDelaySeconds: 60
### interval between checks
periodSeconds: 10
action:
type: DELETE
---
apiVersion: v1
kind: ConfigMap
metadata:
name: helper-scripts
namespace: example-02
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-consistent-tested-superb-app
namespace: example-02
spec:
completions: 3
parallelism: 2
backoffLimit: 0
template:
metadata:
labels:
app: test-app-02
### these pods will be checked for successful completions
component: main
type: test
spec:
restartPolicy: Never
containers:
- name: main
image: alpine
### uncomment to test
### that operator
### will not delete the namespace
### because the pods will fail
# 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-harmonious-acoustic-savory-app
namespace: example-02
spec:
replicas: 2
selector:
matchLabels:
app: test-app-02
component: auxiliary
type: test
template:
metadata:
labels:
app: test-app-02
### these pods will not be checked
component: auxiliary
type: test
spec:
containers:
- name: main
image: alpine
args:
- "sh"
- "-c"
- "while sleep 10; do echo memory stats:; free; echo; done"