-
Notifications
You must be signed in to change notification settings - Fork 6
/
main.jsonnet
105 lines (104 loc) · 2.82 KB
/
main.jsonnet
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
local kubernetes = import '../kubernetes.libsonnet';
local config = import 'generic-operator/config';
{
objects: std.mapWithKey(
// inject owner references into all Kubernetes objects
function(k, v) v {
metadata+: {
ownerReferences: [{
apiVersion: config.apiVersion,
blockOwnerdeletion: true,
controller: true,
kind: config.kind,
name: config.metadata.name,
uid: config.metadata.uid,
}],
},
},
// Generate kubernetes objects in kubernetes function for give params
kubernetes({
name: config.metadata.name,
metadata+: {
namespace: config.metadata.namespace,
},
replicas: config.spec.replicas,
resources: if std.objectHas(config.spec, 'resources') then config.spec.resources else {},
pvc: {
size: '1Gi',
class: 'standard',
},
})
),
rollout: {
apiVersion: 'workflow.kubernetes.io/v1alpha1',
kind: 'Rollout',
metadata: {
name: 'jsonnet',
},
spec: {
groups: [
{
name: 'Rollout CockroachDB',
steps: [
{
action: 'DecommissionNode',
object: 'statefulSet',
},
{
action: 'CreateOrUpdate',
object: 'statefulSet',
success: [
{
fieldComparisons: [
{
name: 'Generation correct',
path: '{.metadata.generation}',
value: {
path: '{.status.observedGeneration}',
},
},
{
name: 'All replicas updated',
path: '{.status.replicas}',
value: {
path: '{.status.updatedReplicas}',
},
},
{
name: 'No replica unavailable',
path: '{.status.unavailableReplicas}',
default: 0,
value: {
static: 0,
},
},
],
},
],
},
{
action: 'CreateOrUpdate',
object: 'service',
},
{
action: 'CreateOrUpdate',
object: 'servicePublic',
},
{
action: 'CreateOrUpdate',
object: 'serviceMonitor',
},
{
action: 'InitializeIfNot',
object: 'statefulSet',
},
{
action: 'RecommissionNode',
object: 'statefulSet',
},
],
},
],
},
},
}