@toa.io/operations 1.0.0-alpha.28 → 1.0.0-alpha.282
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +212 -0
- package/image/runtime.Dockerfile +4 -0
- package/package.json +10 -10
- package/readme.md +16 -0
- package/src/deployment/.deployment/.describe/components.js +1 -5
- package/src/deployment/.deployment/.describe/compositions.js +8 -7
- package/src/deployment/.deployment/.describe/dependencies.js +1 -6
- package/src/deployment/.deployment/.describe/events.js +63 -0
- package/src/deployment/.deployment/.describe/index.js +4 -13
- package/src/deployment/.deployment/.describe/mounts.js +20 -0
- package/src/deployment/.deployment/.describe/resources.js +33 -0
- package/src/deployment/.deployment/.describe/services.js +28 -5
- package/src/deployment/.deployment/.describe/services.test.js +61 -0
- package/src/deployment/.deployment/.describe/variables.js +6 -9
- package/src/deployment/.deployment/declare.js +1 -5
- package/src/deployment/.deployment/describe.js +133 -9
- package/src/deployment/.deployment/index.js +3 -9
- package/src/deployment/.deployment/merge.js +46 -6
- package/src/deployment/.deployment/merge.test.js +72 -0
- package/src/deployment/chart/templates/compositions.yaml +70 -0
- package/src/deployment/chart/templates/mono.yaml +181 -0
- package/src/deployment/chart/templates/services.yaml +75 -4
- package/src/deployment/chart/values.yaml +11 -1
- package/src/deployment/composition.js +2 -5
- package/src/deployment/deployment.js +19 -12
- package/src/deployment/factory.js +50 -28
- package/src/deployment/images/composition.Dockerfile +2 -2
- package/src/deployment/images/composition.js +26 -22
- package/src/deployment/images/factory.js +15 -10
- package/src/deployment/images/format.js +48 -0
- package/src/deployment/images/format.test.js +74 -0
- package/src/deployment/images/image.fixtures.js +11 -11
- package/src/deployment/images/image.js +20 -22
- package/src/deployment/images/image.test.js +6 -5
- package/src/deployment/images/index.js +1 -5
- package/src/deployment/images/mono.Dockerfile +18 -0
- package/src/deployment/images/mono.js +72 -0
- package/src/deployment/images/runtime-base.test.js +91 -0
- package/src/deployment/images/service.Dockerfile +3 -3
- package/src/deployment/images/service.js +8 -8
- package/src/deployment/index.js +1 -5
- package/src/deployment/operator.js +6 -6
- package/src/deployment/operator.test.js +8 -7
- package/src/deployment/registry.js +66 -22
- package/src/deployment/registry.test.js +177 -0
- package/src/deployment/service.js +1 -5
- package/src/deployment/workspace.js +13 -8
- package/src/index.js +1 -3
- package/src/process.js +2 -8
- package/src/process.test.js +20 -0
- package/types/_deployment/composition.d.ts +1 -1
- package/types/_deployment/dependency.d.ts +3 -1
- package/types/_deployment/deployment.d.ts +3 -3
- package/types/_deployment/factory.d.ts +2 -2
- package/types/_deployment/images/factory.d.ts +2 -2
- package/types/_deployment/images/image.d.ts +4 -2
- package/types/_deployment/images/registry.d.ts +2 -2
- package/types/_deployment/operator.d.ts +2 -2
- package/types/_deployment/registry.d.ts +10 -8
- package/types/_deployment/service.d.ts +4 -1
- package/types/dependency.ts +73 -0
- package/types/index.ts +1 -0
- package/types/dependency.d.ts +0 -39
- package/types/index.d.ts +0 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import * as desc from './.describe/index.js'
|
|
2
|
+
import { addVariables } from './.describe/variables.js'
|
|
3
|
+
import { addMounts } from './.describe/mounts.js'
|
|
4
|
+
import { resources } from './.describe/resources.js'
|
|
5
|
+
import { events } from './.describe/events.js'
|
|
2
6
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
const describe = (context, compositions, dependency) => {
|
|
7
|
+
export const describe = (context, compositions, dependency, image) => {
|
|
6
8
|
const { services } = dependency
|
|
7
9
|
|
|
8
10
|
dependency.variables.global ??= []
|
|
@@ -17,18 +19,140 @@ const describe = (context, compositions, dependency) => {
|
|
|
17
19
|
}
|
|
18
20
|
)
|
|
19
21
|
|
|
20
|
-
const
|
|
22
|
+
const atomicity = context.atomicity
|
|
23
|
+
|
|
24
|
+
if (atomicity?.redis !== undefined) {
|
|
25
|
+
const addresses = Array.isArray(atomicity.redis) ? atomicity.redis : [atomicity.redis]
|
|
26
|
+
|
|
27
|
+
// a lock is taken on `floor(n / 2) + 1` of them, so an even number tolerates no more
|
|
28
|
+
// losses than the odd number below it, and two tolerate fewer than one does
|
|
29
|
+
if (addresses.length % 2 === 0)
|
|
30
|
+
throw new Error(`'atomicity.redis' takes an odd number of addresses, ` +
|
|
31
|
+
`${addresses.length} given`)
|
|
32
|
+
|
|
33
|
+
dependency.variables.global.push({
|
|
34
|
+
name: 'TOA_ATOMICITY_REDIS',
|
|
35
|
+
value: addresses.join(' ')
|
|
36
|
+
})
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
if (atomicity?.interval !== undefined)
|
|
40
|
+
dependency.variables.global.push({
|
|
41
|
+
name: 'TOA_ATOMICITY_INTERVAL',
|
|
42
|
+
value: String(atomicity.interval)
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const outbox = context.outbox
|
|
46
|
+
|
|
47
|
+
if (outbox?.interval !== undefined)
|
|
48
|
+
dependency.variables.global.push({
|
|
49
|
+
name: 'TOA_OUTBOX_INTERVAL',
|
|
50
|
+
value: String(outbox.interval)
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
if (outbox?.batch !== undefined)
|
|
54
|
+
dependency.variables.global.push({
|
|
55
|
+
name: 'TOA_OUTBOX_BATCH',
|
|
56
|
+
value: String(outbox.batch)
|
|
57
|
+
})
|
|
58
|
+
|
|
59
|
+
if (outbox?.retention !== undefined)
|
|
60
|
+
dependency.variables.global.push({
|
|
61
|
+
name: 'TOA_OUTBOX_RETENTION',
|
|
62
|
+
value: String(outbox.retention)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
events(context, dependency)
|
|
66
|
+
|
|
21
67
|
const credentials = context.registry?.credentials
|
|
22
68
|
|
|
23
|
-
|
|
24
|
-
|
|
69
|
+
if (image !== undefined) {
|
|
70
|
+
const mono = unit(context, dependency)
|
|
71
|
+
|
|
72
|
+
mono.image = image.reference
|
|
73
|
+
|
|
74
|
+
const values = {
|
|
75
|
+
compositions: [],
|
|
76
|
+
components: mono.components,
|
|
77
|
+
services: [],
|
|
78
|
+
credentials,
|
|
79
|
+
mono
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
resources(context, values)
|
|
25
83
|
|
|
26
|
-
|
|
84
|
+
return values
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const components = desc.components(compositions)
|
|
88
|
+
|
|
89
|
+
desc.compositions(compositions, dependency)
|
|
90
|
+
desc.services(services, dependency.variables, dependency.probe, context.ingress)
|
|
91
|
+
|
|
92
|
+
const values = {
|
|
27
93
|
compositions,
|
|
28
94
|
components,
|
|
29
95
|
services,
|
|
30
96
|
credentials
|
|
31
97
|
}
|
|
98
|
+
|
|
99
|
+
resources(context, values)
|
|
100
|
+
|
|
101
|
+
return values
|
|
32
102
|
}
|
|
33
103
|
|
|
34
|
-
|
|
104
|
+
function unit (context, dependency) {
|
|
105
|
+
const components = (context.components ?? []).map((component) => component.locator.label)
|
|
106
|
+
|
|
107
|
+
const variables = dependency.variables ?? {}
|
|
108
|
+
const mounts = dependency.mounts ?? {}
|
|
109
|
+
|
|
110
|
+
const mono = {
|
|
111
|
+
replicas: context.mono?.replicas,
|
|
112
|
+
resources: context.mono?.resources,
|
|
113
|
+
components,
|
|
114
|
+
variables: []
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
if (context.ingress !== undefined)
|
|
118
|
+
mono.ingress = Object.assign({}, context.ingress)
|
|
119
|
+
|
|
120
|
+
addVariables(mono, variables, Object.keys(variables))
|
|
121
|
+
addMounts(mono, dependency.mounts, Object.keys(mounts))
|
|
122
|
+
|
|
123
|
+
for (const service of dependency.services ?? []) {
|
|
124
|
+
if (service.variables !== undefined)
|
|
125
|
+
for (const variable of service.variables)
|
|
126
|
+
if (!mono.variables.some((item) => item.name === variable.name))
|
|
127
|
+
mono.variables.push(variable)
|
|
128
|
+
|
|
129
|
+
// every declared port is bound by the single mono process, none is primary
|
|
130
|
+
if (service.port !== undefined)
|
|
131
|
+
(mono.backends ??= []).push({ port: service.port, path: service.ingress?.path ?? '/' })
|
|
132
|
+
|
|
133
|
+
// one Service fronts every backend, so its annotations are the union
|
|
134
|
+
if (service.annotations !== undefined)
|
|
135
|
+
mono.annotations = Object.assign(mono.annotations ?? {}, service.annotations)
|
|
136
|
+
|
|
137
|
+
if (service.ingress !== undefined) {
|
|
138
|
+
const { path, hosts, ...ingress } = service.ingress
|
|
139
|
+
|
|
140
|
+
mono.ingress = Object.assign(mono.ingress ?? {}, ingress)
|
|
141
|
+
|
|
142
|
+
// one Ingress serves every path, so its hosts are the union, not the last word
|
|
143
|
+
if (hosts !== undefined)
|
|
144
|
+
mono.ingress.hosts = [...new Set([...(mono.ingress.hosts ?? []), ...hosts])]
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (service.probe !== undefined && service.probe !== false)
|
|
148
|
+
mono.probe = service.probe
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (mono.probe === undefined && dependency.probe !== undefined && dependency.probe !== false)
|
|
152
|
+
mono.probe = dependency.probe
|
|
153
|
+
|
|
154
|
+
// the more specific prefix must come first, whatever the controller's tie-break
|
|
155
|
+
mono.backends?.sort((a, b) => b.path.length - a.path.length)
|
|
156
|
+
|
|
157
|
+
return mono
|
|
158
|
+
}
|
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const { describe } = require('./describe')
|
|
5
|
-
const { merge } = require('./merge')
|
|
6
|
-
|
|
7
|
-
exports.declare = declare
|
|
8
|
-
exports.describe = describe
|
|
9
|
-
exports.merge = merge
|
|
1
|
+
export { declare } from './declare.js'
|
|
2
|
+
export { describe } from './describe.js'
|
|
3
|
+
export { merge } from './merge.js'
|
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const merge = (dependencies) => {
|
|
1
|
+
export const merge = (dependencies) => {
|
|
4
2
|
/** @type {toa.deployment.dependency.Reference[]} */
|
|
5
3
|
const references = []
|
|
6
4
|
|
|
@@ -13,14 +11,58 @@ const merge = (dependencies) => {
|
|
|
13
11
|
/** @type {toa.deployment.dependency.Variables} */
|
|
14
12
|
const variables = {}
|
|
15
13
|
|
|
14
|
+
/** event labels consumed by something other than a component's own receivers */
|
|
15
|
+
const events = []
|
|
16
|
+
|
|
17
|
+
const mounts = {}
|
|
18
|
+
|
|
19
|
+
/** @type {toa.deployment.dependency.Probe | false | undefined} */
|
|
20
|
+
let probe
|
|
21
|
+
|
|
16
22
|
for (const dependency of dependencies) {
|
|
17
23
|
if (dependency.references !== undefined) references.push(...dependency.references)
|
|
18
24
|
if (dependency.services !== undefined) services.push(...dependency.services)
|
|
19
25
|
if (dependency.proxies !== undefined) proxies.push(...dependency.proxies)
|
|
20
26
|
if (dependency.variables !== undefined) append(variables, dependency.variables)
|
|
27
|
+
if (dependency.events !== undefined) events.push(...dependency.events)
|
|
28
|
+
if (dependency.mounts !== undefined) append(mounts, dependency.mounts)
|
|
29
|
+
if (dependency.probe !== undefined) probe = dependency.probe
|
|
21
30
|
}
|
|
22
31
|
|
|
23
|
-
|
|
32
|
+
reserve(services, probe)
|
|
33
|
+
|
|
34
|
+
return { references, services, proxies, variables, mounts, events, probe }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* In Kubernetes these are separate pods, but `toa mono` and a local run put every
|
|
39
|
+
* service in one process — so a port may be claimed once and only once.
|
|
40
|
+
*/
|
|
41
|
+
const reserve = (services, probe) => {
|
|
42
|
+
const claimed = new Map()
|
|
43
|
+
|
|
44
|
+
if (probe !== undefined && probe !== false)
|
|
45
|
+
claimed.set(probe.port, 'the readiness probe')
|
|
46
|
+
|
|
47
|
+
for (const service of services)
|
|
48
|
+
for (const [port, claimant] of ports(service)) {
|
|
49
|
+
const conflicting = claimed.get(port)
|
|
50
|
+
|
|
51
|
+
if (conflicting !== undefined)
|
|
52
|
+
throw new Error(`Port ${port} is claimed by both ${conflicting} and ${claimant}`)
|
|
53
|
+
|
|
54
|
+
claimed.set(port, claimant)
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function * ports (service) {
|
|
59
|
+
const name = `'${service.group}-${service.name}'`
|
|
60
|
+
|
|
61
|
+
if (service.port !== undefined)
|
|
62
|
+
yield [service.port, name]
|
|
63
|
+
|
|
64
|
+
if (service.probe !== undefined && service.probe !== false && service.probe.port !== service.port)
|
|
65
|
+
yield [service.probe.port, `the readiness probe of ${name}`]
|
|
24
66
|
}
|
|
25
67
|
|
|
26
68
|
const append = (merged, variables) => {
|
|
@@ -30,5 +72,3 @@ const append = (merged, variables) => {
|
|
|
30
72
|
merged[component].push(...vars)
|
|
31
73
|
}
|
|
32
74
|
}
|
|
33
|
-
|
|
34
|
-
exports.merge = merge
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { describe, it } from 'node:test'
|
|
2
|
+
import assert from 'node:assert/strict'
|
|
3
|
+
|
|
4
|
+
import { merge } from './merge.js'
|
|
5
|
+
|
|
6
|
+
const service = (name, extra = {}) => ({ group: 'group', name, version: '0', ...extra })
|
|
7
|
+
|
|
8
|
+
it('should merge services of all dependencies', () => {
|
|
9
|
+
const merged = merge([
|
|
10
|
+
{ services: [service('one', { port: 8000 })] },
|
|
11
|
+
{ services: [service('two', { port: 8001 })] }
|
|
12
|
+
])
|
|
13
|
+
|
|
14
|
+
assert.strictEqual(merged.services.length, 2)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
* In Kubernetes these are separate pods, but `toa mono` and a local run put every
|
|
19
|
+
* service in one process.
|
|
20
|
+
*/
|
|
21
|
+
describe('port reservation', () => {
|
|
22
|
+
it('should reject two services claiming one port', () => {
|
|
23
|
+
const dependencies = [
|
|
24
|
+
{ services: [service('one', { port: 8000 })] },
|
|
25
|
+
{ services: [service('two', { port: 8000 })] }
|
|
26
|
+
]
|
|
27
|
+
|
|
28
|
+
assert.throws(() => merge(dependencies), (error) => /Port 8000 is claimed by both 'group-one' and 'group-two'/.test(error.message))
|
|
29
|
+
})
|
|
30
|
+
|
|
31
|
+
it('should reject a service claiming the port of the readiness probe', () => {
|
|
32
|
+
const dependencies = [
|
|
33
|
+
{ probe: { path: '/.ready', port: 8001 } },
|
|
34
|
+
{ services: [service('one', { port: 8001 })] }
|
|
35
|
+
]
|
|
36
|
+
|
|
37
|
+
assert.throws(() => merge(dependencies), (error) => /Port 8001 is claimed by both the readiness probe and 'group-one'/.test(error.message))
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
it('should reject a probe claiming the port of another service', () => {
|
|
41
|
+
const dependencies = [
|
|
42
|
+
{ services: [service('one', { port: 8000 })] },
|
|
43
|
+
{ services: [service('two', { port: 8002, probe: { path: '/.ready', port: 8000 } })] }
|
|
44
|
+
]
|
|
45
|
+
|
|
46
|
+
assert.throws(() => merge(dependencies), (error) => /Port 8000 is claimed by both 'group-one' and the readiness probe of 'group-two'/.test(error.message))
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
it('should allow a service to probe its own port', () => {
|
|
50
|
+
const dependencies = [
|
|
51
|
+
{ services: [service('one', { port: 8000, probe: { path: '/.ready', port: 8000 } })] }
|
|
52
|
+
]
|
|
53
|
+
|
|
54
|
+
assert.doesNotThrow(() => merge(dependencies))
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
it('should ignore services without a port', () => {
|
|
58
|
+
const dependencies = [
|
|
59
|
+
{ services: [service('one'), service('two')] }
|
|
60
|
+
]
|
|
61
|
+
|
|
62
|
+
assert.doesNotThrow(() => merge(dependencies))
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
it('should ignore a disabled probe', () => {
|
|
66
|
+
const dependencies = [
|
|
67
|
+
{ probe: false, services: [service('one', { port: 8000, probe: false })] }
|
|
68
|
+
]
|
|
69
|
+
|
|
70
|
+
assert.doesNotThrow(() => merge(dependencies))
|
|
71
|
+
})
|
|
72
|
+
})
|
|
@@ -5,6 +5,9 @@ metadata:
|
|
|
5
5
|
name: composition-{{ required "composition name is required" .name }}
|
|
6
6
|
spec:
|
|
7
7
|
replicas: {{ .replicas | default 2 }}
|
|
8
|
+
# A backstop for stuck rollouts only. Must stay above the `helm upgrade --timeout`
|
|
9
|
+
# the deploy runs with, so a slow but progressing rollout is not marked failed.
|
|
10
|
+
progressDeadlineSeconds: 900
|
|
8
11
|
selector:
|
|
9
12
|
matchLabels:
|
|
10
13
|
toa.io/composition: {{ .name }}
|
|
@@ -19,15 +22,82 @@ spec:
|
|
|
19
22
|
containers:
|
|
20
23
|
- name: {{ .name }}
|
|
21
24
|
image: {{ .image }}
|
|
25
|
+
{{- if .resources }}
|
|
26
|
+
resources:
|
|
27
|
+
{{- if or .resources.cpu .resources.memory }}
|
|
28
|
+
requests:
|
|
29
|
+
{{- if .resources.cpu }}
|
|
30
|
+
cpu: {{ index .resources.cpu 0 }}
|
|
31
|
+
{{- end }}
|
|
32
|
+
{{- if .resources.memory }}
|
|
33
|
+
memory: {{ index .resources.memory 0 }}
|
|
34
|
+
{{- end }}
|
|
35
|
+
limits:
|
|
36
|
+
{{- if .resources.cpu }}
|
|
37
|
+
cpu: {{ index .resources.cpu 1 }}
|
|
38
|
+
{{- end }}
|
|
39
|
+
{{- if .resources.memory }}
|
|
40
|
+
memory: {{ index .resources.memory 1 }}
|
|
41
|
+
{{- end }}
|
|
42
|
+
{{- end }}
|
|
43
|
+
{{- end }}
|
|
22
44
|
{{- if .variables }}
|
|
23
45
|
env:
|
|
24
46
|
{{- range .variables }}
|
|
25
47
|
{{- include "env.var" . | indent 12 }}
|
|
26
48
|
{{- end }}
|
|
27
49
|
{{- end }}
|
|
50
|
+
{{- if .probe }}
|
|
51
|
+
ports:
|
|
52
|
+
- containerPort: {{ .probe.port }}
|
|
53
|
+
startupProbe:
|
|
54
|
+
httpGet:
|
|
55
|
+
path: {{ .probe.path }}
|
|
56
|
+
port: {{ .probe.port }}
|
|
57
|
+
{{- if .probe.delay }}
|
|
58
|
+
initialDelaySeconds: {{ .probe.delay }}
|
|
59
|
+
{{- end }}
|
|
60
|
+
periodSeconds: 2
|
|
61
|
+
timeoutSeconds: 3
|
|
62
|
+
failureThreshold: 150
|
|
63
|
+
readinessProbe:
|
|
64
|
+
httpGet:
|
|
65
|
+
path: {{ .probe.path }}
|
|
66
|
+
port: {{ .probe.port }}
|
|
67
|
+
periodSeconds: 10
|
|
68
|
+
timeoutSeconds: 3
|
|
69
|
+
failureThreshold: 3
|
|
70
|
+
{{- end }}
|
|
71
|
+
{{- if .mounts }}
|
|
72
|
+
volumeMounts:
|
|
73
|
+
{{- range .mounts }}
|
|
74
|
+
- name: {{ .name }}
|
|
75
|
+
mountPath: {{ .path }}
|
|
76
|
+
{{- end }}
|
|
77
|
+
{{- end }}
|
|
78
|
+
lifecycle:
|
|
79
|
+
preStop:
|
|
80
|
+
exec:
|
|
81
|
+
command: [sleep, "5"]
|
|
82
|
+
terminationGracePeriodSeconds: 45
|
|
28
83
|
{{- if $.Values.credentials }}
|
|
29
84
|
imagePullSecrets:
|
|
30
85
|
- name: {{ $.Values.credentials }}
|
|
31
86
|
{{- end }}
|
|
87
|
+
{{- if .mounts }}
|
|
88
|
+
volumes:
|
|
89
|
+
{{- range .mounts }}
|
|
90
|
+
- name: {{ .name }}
|
|
91
|
+
persistentVolumeClaim:
|
|
92
|
+
claimName: {{ .claim }}
|
|
93
|
+
{{- end }}
|
|
94
|
+
{{- end }}
|
|
95
|
+
topologySpreadConstraints:
|
|
96
|
+
- maxSkew: 1
|
|
97
|
+
topologyKey: kubernetes.io/hostname
|
|
98
|
+
whenUnsatisfiable: ScheduleAnyway
|
|
99
|
+
labelSelector:
|
|
100
|
+
matchLabels:
|
|
101
|
+
toa.io/composition: {{ .name }}
|
|
32
102
|
---
|
|
33
103
|
{{- end }}
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
{{- if .Values.mono }}
|
|
2
|
+
{{- with .Values.mono }}
|
|
3
|
+
apiVersion: apps/v1
|
|
4
|
+
kind: Deployment
|
|
5
|
+
metadata:
|
|
6
|
+
name: mono
|
|
7
|
+
spec:
|
|
8
|
+
replicas: {{ .replicas | default 2 }}
|
|
9
|
+
progressDeadlineSeconds: 900
|
|
10
|
+
strategy:
|
|
11
|
+
type: RollingUpdate
|
|
12
|
+
rollingUpdate:
|
|
13
|
+
maxUnavailable: 0
|
|
14
|
+
maxSurge: 50%
|
|
15
|
+
selector:
|
|
16
|
+
matchLabels:
|
|
17
|
+
toa.io/composition: mono
|
|
18
|
+
template:
|
|
19
|
+
metadata:
|
|
20
|
+
labels:
|
|
21
|
+
toa.io/composition: mono
|
|
22
|
+
{{- range .components }}
|
|
23
|
+
{{ . }}: "1"
|
|
24
|
+
{{- end }}
|
|
25
|
+
spec:
|
|
26
|
+
containers:
|
|
27
|
+
- name: mono
|
|
28
|
+
image: {{ .image }}
|
|
29
|
+
{{- if or .backends .probe }}
|
|
30
|
+
ports:
|
|
31
|
+
{{- range .backends }}
|
|
32
|
+
- containerPort: {{ .port }}
|
|
33
|
+
{{- end }}
|
|
34
|
+
{{- if .probe }}
|
|
35
|
+
- containerPort: {{ .probe.port }}
|
|
36
|
+
{{- end }}
|
|
37
|
+
{{- end }}
|
|
38
|
+
{{- if .resources }}
|
|
39
|
+
resources:
|
|
40
|
+
{{- if or .resources.cpu .resources.memory }}
|
|
41
|
+
requests:
|
|
42
|
+
{{- if .resources.cpu }}
|
|
43
|
+
cpu: {{ index .resources.cpu 0 }}
|
|
44
|
+
{{- end }}
|
|
45
|
+
{{- if .resources.memory }}
|
|
46
|
+
memory: {{ index .resources.memory 0 }}
|
|
47
|
+
{{- end }}
|
|
48
|
+
limits:
|
|
49
|
+
{{- if .resources.cpu }}
|
|
50
|
+
cpu: {{ index .resources.cpu 1 }}
|
|
51
|
+
{{- end }}
|
|
52
|
+
{{- if .resources.memory }}
|
|
53
|
+
memory: {{ index .resources.memory 1 }}
|
|
54
|
+
{{- end }}
|
|
55
|
+
{{- end }}
|
|
56
|
+
{{- end }}
|
|
57
|
+
{{- if .variables }}
|
|
58
|
+
env:
|
|
59
|
+
{{- range .variables }}
|
|
60
|
+
{{- include "env.var" . | indent 12 }}
|
|
61
|
+
{{- end }}
|
|
62
|
+
{{- end }}
|
|
63
|
+
{{- if .probe }}
|
|
64
|
+
startupProbe:
|
|
65
|
+
httpGet:
|
|
66
|
+
path: {{ .probe.path }}
|
|
67
|
+
port: {{ .probe.port }}
|
|
68
|
+
{{- if .probe.delay }}
|
|
69
|
+
initialDelaySeconds: {{ .probe.delay }}
|
|
70
|
+
{{- end }}
|
|
71
|
+
periodSeconds: 2
|
|
72
|
+
timeoutSeconds: 3
|
|
73
|
+
failureThreshold: 150
|
|
74
|
+
readinessProbe:
|
|
75
|
+
httpGet:
|
|
76
|
+
path: {{ .probe.path }}
|
|
77
|
+
port: {{ .probe.port }}
|
|
78
|
+
periodSeconds: 10
|
|
79
|
+
timeoutSeconds: 3
|
|
80
|
+
failureThreshold: 3
|
|
81
|
+
{{- end }}
|
|
82
|
+
{{- if .mounts }}
|
|
83
|
+
volumeMounts:
|
|
84
|
+
{{- range .mounts }}
|
|
85
|
+
- name: {{ .name }}
|
|
86
|
+
mountPath: {{ .path }}
|
|
87
|
+
{{- end }}
|
|
88
|
+
{{- end }}
|
|
89
|
+
lifecycle:
|
|
90
|
+
preStop:
|
|
91
|
+
exec:
|
|
92
|
+
command: [sleep, "5"]
|
|
93
|
+
terminationGracePeriodSeconds: 45
|
|
94
|
+
{{- if $.Values.credentials }}
|
|
95
|
+
imagePullSecrets:
|
|
96
|
+
- name: {{ $.Values.credentials }}
|
|
97
|
+
{{- end }}
|
|
98
|
+
{{- if .mounts }}
|
|
99
|
+
volumes:
|
|
100
|
+
{{- range .mounts }}
|
|
101
|
+
- name: {{ .name }}
|
|
102
|
+
persistentVolumeClaim:
|
|
103
|
+
claimName: {{ .claim }}
|
|
104
|
+
{{- end }}
|
|
105
|
+
{{- end }}
|
|
106
|
+
topologySpreadConstraints:
|
|
107
|
+
- maxSkew: 1
|
|
108
|
+
topologyKey: kubernetes.io/hostname
|
|
109
|
+
whenUnsatisfiable: ScheduleAnyway
|
|
110
|
+
labelSelector:
|
|
111
|
+
matchLabels:
|
|
112
|
+
toa.io/composition: mono
|
|
113
|
+
{{- if .backends }}
|
|
114
|
+
---
|
|
115
|
+
apiVersion: v1
|
|
116
|
+
kind: Service
|
|
117
|
+
metadata:
|
|
118
|
+
name: mono
|
|
119
|
+
{{- if .annotations }}
|
|
120
|
+
annotations:
|
|
121
|
+
{{ toYaml .annotations | indent 4 }}
|
|
122
|
+
{{- end }}
|
|
123
|
+
spec:
|
|
124
|
+
type: ClusterIP
|
|
125
|
+
selector:
|
|
126
|
+
toa.io/composition: mono
|
|
127
|
+
ports:
|
|
128
|
+
{{- range .backends }}
|
|
129
|
+
- name: port-{{ .port }}
|
|
130
|
+
protocol: TCP
|
|
131
|
+
port: {{ .port }}
|
|
132
|
+
targetPort: {{ .port }}
|
|
133
|
+
{{- end }}
|
|
134
|
+
{{- end }}
|
|
135
|
+
{{- if .ingress }}
|
|
136
|
+
---
|
|
137
|
+
apiVersion: networking.k8s.io/v1
|
|
138
|
+
kind: Ingress
|
|
139
|
+
metadata:
|
|
140
|
+
name: mono
|
|
141
|
+
{{- if .ingress.annotations }}
|
|
142
|
+
annotations:
|
|
143
|
+
{{ toYaml .ingress.annotations | indent 4 }}
|
|
144
|
+
{{- end }}
|
|
145
|
+
spec:
|
|
146
|
+
{{- if .ingress.class }}
|
|
147
|
+
ingressClassName: {{ .ingress.class }}
|
|
148
|
+
{{- end }}
|
|
149
|
+
{{- $backends := .backends }}
|
|
150
|
+
rules:
|
|
151
|
+
{{- range .ingress.hosts }}
|
|
152
|
+
- host: {{ . }}
|
|
153
|
+
http:
|
|
154
|
+
paths:
|
|
155
|
+
{{- range $backends }}
|
|
156
|
+
- path: {{ .path }}
|
|
157
|
+
pathType: Prefix
|
|
158
|
+
backend:
|
|
159
|
+
service:
|
|
160
|
+
name: mono
|
|
161
|
+
port:
|
|
162
|
+
number: {{ .port }}
|
|
163
|
+
{{- end }}
|
|
164
|
+
{{- end }}
|
|
165
|
+
{{- if .ingress.default }}
|
|
166
|
+
- http:
|
|
167
|
+
paths:
|
|
168
|
+
{{- range $backends }}
|
|
169
|
+
- path: {{ .path }}
|
|
170
|
+
pathType: Prefix
|
|
171
|
+
backend:
|
|
172
|
+
service:
|
|
173
|
+
name: mono
|
|
174
|
+
port:
|
|
175
|
+
number: {{ .port }}
|
|
176
|
+
{{- end }}
|
|
177
|
+
{{- end }}
|
|
178
|
+
{{- end }}
|
|
179
|
+
---
|
|
180
|
+
{{- end }}
|
|
181
|
+
{{- end }}
|