@yarkivaev/scada 2.22.0 → 2.24.0
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/charts/scada-workloads/Chart.yaml +5 -0
- package/charts/scada-workloads/README.md +45 -0
- package/charts/scada-workloads/templates/_collector.tpl +103 -0
- package/charts/scada-workloads/templates/_control-agent.tpl +80 -0
- package/charts/scada-workloads/templates/_controller.tpl +69 -0
- package/charts/scada-workloads/templates/_etcd-member.tpl +92 -0
- package/charts/scada-workloads/templates/_history-maintenance.tpl +44 -0
- package/charts/scada-workloads/templates/_history-receiver.tpl +88 -0
- package/charts/scada-workloads/templates/_journal-supervisor.tpl +82 -0
- package/charts/scada-workloads/templates/_postgres-role.tpl +43 -0
- package/charts/scada-workloads/templates/_reserve-supervisor.tpl +65 -0
- package/charts/scada-workloads/templates/_site-server.tpl +74 -0
- package/charts/scada-workloads/templates/_supervisor-history.tpl +12 -0
- package/charts/scada-workloads/templates/_supervisor.tpl +87 -0
- package/charts/scada-workloads/templates/_telemetry.tpl +181 -0
- package/db/migrations/E0027__metric_claim_trigger.sql +33 -0
- package/package.json +4 -1
- package/src/application/runtime/applicationRuntime.js +5 -2
- package/src/application/runtime/index.js +3 -0
- package/src/application/runtime/opcuaTask.js +63 -0
- package/src/application/runtime/runCommand.js +10 -0
- package/src/application/runtime/runService.js +14 -0
- package/src/application/siteRuntime/backfillOperationPayloads.js +41 -0
- package/src/application/siteRuntime/centralConnections.js +13 -0
- package/src/application/siteRuntime/edgeIngress.js +25 -0
- package/src/application/siteRuntime/index.js +5 -0
- package/src/application/siteRuntime/startAnalyticsRuntime.js +33 -0
- package/src/infrastructure/deploy/ci/applicationBundleLock.js +51 -0
- package/src/infrastructure/deploy/ci/archiveApplication.py +30 -0
- package/src/infrastructure/deploy/ci/packageApplication.js +63 -0
- package/src/infrastructure/deploy/ci/releaseArtifacts.js +55 -0
- package/src/infrastructure/deploy/ci/scada_gitlab.py +75 -0
- package/src/infrastructure/deploy/ci/scada_registry.py +91 -0
- package/src/infrastructure/deploy/configuredSiteAssets.js +8 -2
- package/src/infrastructure/deploy/executeStages.js +8 -1
- package/src/infrastructure/deploy/index.js +3 -1
- package/src/infrastructure/deploy/installVerifiedTools.js +44 -0
- package/src/infrastructure/deploy/stagedSitePlan.js +3 -1
- package/src/infrastructure/deploy/useApplicationBundle.sh +22 -0
- package/src/infrastructure/opcua/index.js +2 -0
- package/src/infrastructure/opcua/opcuaRecord.js +44 -0
- package/src/infrastructure/opcua/publishOpcuaRecord.js +23 -0
- package/src/infrastructure/persistence/pg/orderedRows.js +31 -0
- package/src/testing/boundedQueue.js +50 -0
- package/stream-processing/project/plugins.sbt +2 -0
- package/stream-processing/src/main/resources/logback.xml +16 -0
- package/stream-processing/src/main/scala/scada/processing/runtime/DurableMachineInput.scala +6 -0
- package/stream-processing/src/main/scala/scada/processing/runtime/WorkerStores.scala +31 -2
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# SCADA workload templates
|
|
2
|
+
|
|
3
|
+
`scada-workloads` is a Helm library included in the SCADA npm package. Add it as a
|
|
4
|
+
dependency of the application chart, and call the named templates from the
|
|
5
|
+
application chart's resource files. A chart in `charts/example` can resolve it
|
|
6
|
+
from its installed SCADA package.
|
|
7
|
+
|
|
8
|
+
```yaml
|
|
9
|
+
dependencies:
|
|
10
|
+
- name: scada-workloads
|
|
11
|
+
version: 0.1.0
|
|
12
|
+
repository: file://../../node_modules/@yarkivaev/scada/charts/scada-workloads
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Use `helm dependency update` to generate the initial lock and
|
|
16
|
+
`helm dependency build --skip-refresh` to prepare dependencies from the lock.
|
|
17
|
+
For example, an application can render its processor Deployment with this
|
|
18
|
+
definition in `templates/processor.yaml`.
|
|
19
|
+
|
|
20
|
+
```gotemplate
|
|
21
|
+
{{- include "scada.workloads.supervisor" (dict "release" .Release "values" .Values) }}
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
Supply the application image, HOCON configuration, runtime environment, Secret
|
|
25
|
+
references, resource budgets and mount settings from the calling chart. The
|
|
26
|
+
application also chooses which templates to call and the resource names and
|
|
27
|
+
selectors used to adopt existing workloads.
|
|
28
|
+
|
|
29
|
+
| Template | Workloads |
|
|
30
|
+
| --- | --- |
|
|
31
|
+
| `scada.workloads.etcdMember` | TLS etcd StatefulSet and Service |
|
|
32
|
+
| `scada.workloads.controller` | Controller Deployment with optional application-provided environment and volumes |
|
|
33
|
+
| `scada.workloads.controlAgent` | Autonomous collector Deployment |
|
|
34
|
+
| `scada.workloads.historyReceiver` | History receiver Deployment and Service |
|
|
35
|
+
| `scada.workloads.historyMaintenance` | Scheduled history purge |
|
|
36
|
+
| `scada.workloads.collector` | Collector Deployment and health Service |
|
|
37
|
+
| `scada.workloads.siteServer` | Site Deployment, internal Service, and optional application-selected NodePort number |
|
|
38
|
+
| `scada.workloads.supervisor` | Processor Deployment and optional ConfigMap using the release name |
|
|
39
|
+
| `scada.workloads.supervisorHistory` | History configuration overlay |
|
|
40
|
+
| `scada.workloads.reserveSupervisor` | Processor Deployment with health probes and a mounted configuration |
|
|
41
|
+
| `scada.workloads.journalSupervisor` | Processor with a persistent journal and optional application-supplied environment |
|
|
42
|
+
| `scada.workloads.postgresRole` | PostgreSQL role bootstrap Job |
|
|
43
|
+
| `scada.workloads.telemetry` | ClickHouse, telemetry ingester, and schema Job |
|
|
44
|
+
|
|
45
|
+
The SCADA application chart in `charts/scada` can be rendered directly.
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
{{- define "scada.workloads.collector" -}}
|
|
2
|
+
{{- $collector := .collector }}
|
|
3
|
+
apiVersion: v1
|
|
4
|
+
kind: Service
|
|
5
|
+
metadata:
|
|
6
|
+
name: {{ .name }}
|
|
7
|
+
spec:
|
|
8
|
+
selector: {app: {{ .app }}}
|
|
9
|
+
ports:
|
|
10
|
+
- {name: health, port: 9091, targetPort: health}
|
|
11
|
+
---
|
|
12
|
+
apiVersion: apps/v1
|
|
13
|
+
kind: Deployment
|
|
14
|
+
metadata:
|
|
15
|
+
name: {{ .name }}
|
|
16
|
+
labels:
|
|
17
|
+
{{- .labels | nindent 4 }}
|
|
18
|
+
spec:
|
|
19
|
+
replicas: 1
|
|
20
|
+
strategy:
|
|
21
|
+
type: Recreate
|
|
22
|
+
rollingUpdate: null
|
|
23
|
+
selector:
|
|
24
|
+
matchLabels: {app: {{ .app }}}
|
|
25
|
+
template:
|
|
26
|
+
metadata:
|
|
27
|
+
labels:
|
|
28
|
+
{{- .labels | nindent 8 }}
|
|
29
|
+
annotations:
|
|
30
|
+
checksum/assignments: {{ $collector.env | toJson | sha256sum }}
|
|
31
|
+
spec:
|
|
32
|
+
imagePullSecrets:
|
|
33
|
+
- name: {{ .pullSecret }}
|
|
34
|
+
{{- if $collector.hostDevices }}
|
|
35
|
+
securityContext: {fsGroup: {{ .hostDeviceGroup }}}
|
|
36
|
+
{{- end }}
|
|
37
|
+
containers:
|
|
38
|
+
- name: collector
|
|
39
|
+
image: {{ $collector.image | quote }}
|
|
40
|
+
command: {{ $collector.command | toJson }}
|
|
41
|
+
{{- if or $collector.hostDevices $collector.readOnlyRootFilesystem }}
|
|
42
|
+
securityContext:
|
|
43
|
+
{{- if $collector.hostDevices }}
|
|
44
|
+
privileged: true
|
|
45
|
+
{{- end }}
|
|
46
|
+
{{- if $collector.readOnlyRootFilesystem }}
|
|
47
|
+
readOnlyRootFilesystem: true
|
|
48
|
+
{{- end }}
|
|
49
|
+
{{- end }}
|
|
50
|
+
{{- with .envFrom }}
|
|
51
|
+
envFrom:
|
|
52
|
+
{{- toYaml . | nindent 12 }}
|
|
53
|
+
{{- end }}
|
|
54
|
+
env:
|
|
55
|
+
{{- range $key, $value := $collector.env }}
|
|
56
|
+
- name: {{ $key }}
|
|
57
|
+
{{- if kindIs "map" $value }}
|
|
58
|
+
{{- toYaml $value | nindent 14 }}
|
|
59
|
+
{{- else }}
|
|
60
|
+
value: {{ $value | quote }}
|
|
61
|
+
{{- end }}
|
|
62
|
+
{{- end }}
|
|
63
|
+
{{- with .extraEnv }}
|
|
64
|
+
{{- toYaml . | nindent 12 }}
|
|
65
|
+
{{- end }}
|
|
66
|
+
ports:
|
|
67
|
+
- name: health
|
|
68
|
+
containerPort: 9091
|
|
69
|
+
readinessProbe:
|
|
70
|
+
httpGet: {path: /ready, port: health}
|
|
71
|
+
initialDelaySeconds: 5
|
|
72
|
+
livenessProbe:
|
|
73
|
+
httpGet: {path: /live, port: health}
|
|
74
|
+
initialDelaySeconds: 15
|
|
75
|
+
{{- with $collector.startupProbe }}
|
|
76
|
+
startupProbe:
|
|
77
|
+
{{- toYaml . | nindent 12 }}
|
|
78
|
+
{{- end }}
|
|
79
|
+
resources:
|
|
80
|
+
{{- toYaml $collector.resources | nindent 12 }}
|
|
81
|
+
{{- if or $collector.hostDevices $collector.volumeMounts }}
|
|
82
|
+
volumeMounts:
|
|
83
|
+
{{- with $collector.volumeMounts }}
|
|
84
|
+
{{- toYaml . | nindent 12 }}
|
|
85
|
+
{{- end }}
|
|
86
|
+
{{- range $index, $path := $collector.hostDevices }}
|
|
87
|
+
- name: serial-{{ add1 $index }}
|
|
88
|
+
mountPath: {{ $path | quote }}
|
|
89
|
+
{{- end }}
|
|
90
|
+
{{- end }}
|
|
91
|
+
{{- if or $collector.hostDevices $collector.volumes }}
|
|
92
|
+
volumes:
|
|
93
|
+
{{- with $collector.volumes }}
|
|
94
|
+
{{- toYaml . | nindent 8 }}
|
|
95
|
+
{{- end }}
|
|
96
|
+
{{- range $index, $path := $collector.hostDevices }}
|
|
97
|
+
- name: serial-{{ add1 $index }}
|
|
98
|
+
hostPath:
|
|
99
|
+
path: {{ $path | quote }}
|
|
100
|
+
type: CharDevice
|
|
101
|
+
{{- end }}
|
|
102
|
+
{{- end }}
|
|
103
|
+
{{- end -}}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
{{- define "scada.workloads.controlAgent" -}}
|
|
2
|
+
apiVersion: apps/v1
|
|
3
|
+
kind: Deployment
|
|
4
|
+
metadata:
|
|
5
|
+
name: {{ .name }}
|
|
6
|
+
spec:
|
|
7
|
+
replicas: 1
|
|
8
|
+
strategy: {type: Recreate}
|
|
9
|
+
selector:
|
|
10
|
+
matchLabels: {app: {{ .name }}}
|
|
11
|
+
template:
|
|
12
|
+
metadata:
|
|
13
|
+
labels: {app: {{ .name }}}
|
|
14
|
+
spec:
|
|
15
|
+
{{- with .values.pullSecret }}
|
|
16
|
+
imagePullSecrets:
|
|
17
|
+
- name: {{ . | quote }}
|
|
18
|
+
{{- end }}
|
|
19
|
+
containers:
|
|
20
|
+
- name: collector
|
|
21
|
+
image: {{ required "agent image required" .values.agent.image | quote }}
|
|
22
|
+
command: {{ .command | toJson }}
|
|
23
|
+
env:
|
|
24
|
+
{{- range $key, $value := .values.agent.env }}
|
|
25
|
+
- name: {{ $key }}
|
|
26
|
+
{{- if kindIs "map" $value }}
|
|
27
|
+
{{- toYaml $value | nindent 14 }}
|
|
28
|
+
{{- else }}
|
|
29
|
+
value: {{ $value | quote }}
|
|
30
|
+
{{- end }}
|
|
31
|
+
{{- end }}
|
|
32
|
+
- name: COLLECTOR_CONTROL_USERNAME
|
|
33
|
+
valueFrom:
|
|
34
|
+
secretKeyRef:
|
|
35
|
+
name: {{ required "agent control auth secret required" .values.agent.authSecret }}
|
|
36
|
+
key: {{ .values.agent.authUsernameKey }}
|
|
37
|
+
- name: COLLECTOR_CONTROL_PASSWORD
|
|
38
|
+
valueFrom:
|
|
39
|
+
secretKeyRef:
|
|
40
|
+
name: {{ .values.agent.authSecret }}
|
|
41
|
+
key: {{ .values.agent.authPasswordKey }}
|
|
42
|
+
envFrom:
|
|
43
|
+
- secretRef:
|
|
44
|
+
name: {{ .values.agent.deliverySecret }}
|
|
45
|
+
ports:
|
|
46
|
+
- {name: health, containerPort: 9091}
|
|
47
|
+
startupProbe:
|
|
48
|
+
{{- toYaml (required "collector startup recovery probe required" .values.agent.startupProbe) | nindent 12 }}
|
|
49
|
+
livenessProbe:
|
|
50
|
+
httpGet: {path: /live, port: health}
|
|
51
|
+
periodSeconds: 10
|
|
52
|
+
readinessProbe:
|
|
53
|
+
httpGet: {path: /ready, port: health}
|
|
54
|
+
securityContext:
|
|
55
|
+
readOnlyRootFilesystem: true
|
|
56
|
+
{{- if .values.agent.hostDevices }}
|
|
57
|
+
privileged: true
|
|
58
|
+
{{- end }}
|
|
59
|
+
resources:
|
|
60
|
+
{{- toYaml (.values.agent.resources | default .values.resources) | nindent 12 }}
|
|
61
|
+
volumeMounts:
|
|
62
|
+
- {name: tls, mountPath: /tls, readOnly: true}
|
|
63
|
+
{{- with .values.agent.volumeMounts }}
|
|
64
|
+
{{- toYaml . | nindent 12 }}
|
|
65
|
+
{{- end }}
|
|
66
|
+
{{- range $index, $device := .values.agent.hostDevices }}
|
|
67
|
+
- {name: serial-{{ $index }}, mountPath: {{ $device | quote }}}
|
|
68
|
+
{{- end }}
|
|
69
|
+
volumes:
|
|
70
|
+
- name: tls
|
|
71
|
+
secret:
|
|
72
|
+
secretName: {{ .values.agent.tlsSecret }}
|
|
73
|
+
{{- with .values.agent.volumes }}
|
|
74
|
+
{{- toYaml . | nindent 8 }}
|
|
75
|
+
{{- end }}
|
|
76
|
+
{{- range $index, $device := .values.agent.hostDevices }}
|
|
77
|
+
- name: serial-{{ $index }}
|
|
78
|
+
hostPath: {path: {{ $device | quote }}, type: CharDevice}
|
|
79
|
+
{{- end }}
|
|
80
|
+
{{- end -}}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
{{- define "scada.workloads.controller" -}}
|
|
2
|
+
---
|
|
3
|
+
apiVersion: apps/v1
|
|
4
|
+
kind: Deployment
|
|
5
|
+
metadata:
|
|
6
|
+
name: {{ .name }}
|
|
7
|
+
spec:
|
|
8
|
+
replicas: 1
|
|
9
|
+
strategy: {type: Recreate}
|
|
10
|
+
selector:
|
|
11
|
+
matchLabels: {app: {{ .name }}}
|
|
12
|
+
template:
|
|
13
|
+
metadata:
|
|
14
|
+
labels: {app: {{ .name }}}
|
|
15
|
+
spec:
|
|
16
|
+
{{- with .values.pullSecret }}
|
|
17
|
+
imagePullSecrets:
|
|
18
|
+
- name: {{ . | quote }}
|
|
19
|
+
{{- end }}
|
|
20
|
+
containers:
|
|
21
|
+
- name: controller
|
|
22
|
+
image: {{ required "controllerImage required" .values.controllerImage | quote }}
|
|
23
|
+
{{- with .workingDir }}
|
|
24
|
+
workingDir: {{ . }}
|
|
25
|
+
{{- end }}
|
|
26
|
+
command: {{ .command | toJson }}
|
|
27
|
+
env:
|
|
28
|
+
- {name: CONTROL_NODE_ID, value: {{ .values.member.id | quote }}}
|
|
29
|
+
- {name: CONTROL_ENDPOINTS, value: {{ .values.endpoints | quote }}}
|
|
30
|
+
- {name: CONTROL_PREFIX, value: {{ .values.prefix | quote }}}
|
|
31
|
+
- {name: CONTROL_CLOCK_SKEW_MS, value: {{ .values.clockSkewMs | quote }}}
|
|
32
|
+
- {name: CONTROL_REPLACEMENT_DELAY_MS, value: {{ .values.replacementDelayMs | quote }}}
|
|
33
|
+
- {name: CONTROL_CA, value: /tls/ca.crt}
|
|
34
|
+
- {name: CONTROL_CERT, value: /tls/tls.crt}
|
|
35
|
+
- {name: CONTROL_KEY, value: /tls/tls.key}
|
|
36
|
+
- name: CONTROL_USERNAME
|
|
37
|
+
valueFrom:
|
|
38
|
+
secretKeyRef:
|
|
39
|
+
name: {{ required "controller auth secret required" .values.controllerAuthSecret }}
|
|
40
|
+
key: {{ .values.authUsernameKey }}
|
|
41
|
+
- name: CONTROL_PASSWORD
|
|
42
|
+
valueFrom:
|
|
43
|
+
secretKeyRef:
|
|
44
|
+
name: {{ .values.controllerAuthSecret }}
|
|
45
|
+
key: {{ .values.authPasswordKey }}
|
|
46
|
+
{{- with .extraEnv }}
|
|
47
|
+
{{- . | nindent 12 }}
|
|
48
|
+
{{- end }}
|
|
49
|
+
{{- with .values.brokerEndpoints }}
|
|
50
|
+
- {name: CONTROL_BROKER_ENDPOINTS, value: {{ . | quote }}}
|
|
51
|
+
{{- end }}
|
|
52
|
+
{{- with .values.rabbitmqManagement }}
|
|
53
|
+
- {name: RABBITMQ_MANAGEMENT, value: {{ . | quote }}}
|
|
54
|
+
{{- end }}
|
|
55
|
+
resources:
|
|
56
|
+
{{- toYaml (.values.controllerResources | default .values.resources) | nindent 12 }}
|
|
57
|
+
volumeMounts:
|
|
58
|
+
- {name: tls, mountPath: /tls, readOnly: true}
|
|
59
|
+
{{- with .volumeMounts }}
|
|
60
|
+
{{- toYaml . | nindent 12 }}
|
|
61
|
+
{{- end }}
|
|
62
|
+
volumes:
|
|
63
|
+
- name: tls
|
|
64
|
+
secret:
|
|
65
|
+
secretName: {{ .tlsSecret | quote }}
|
|
66
|
+
{{- with .volumes }}
|
|
67
|
+
{{- toYaml . | nindent 8 }}
|
|
68
|
+
{{- end }}
|
|
69
|
+
{{- end -}}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{{- define "scada.workloads.etcdMember" -}}
|
|
2
|
+
apiVersion: v1
|
|
3
|
+
kind: Service
|
|
4
|
+
metadata:
|
|
5
|
+
name: {{ .name }}
|
|
6
|
+
spec:
|
|
7
|
+
type: NodePort
|
|
8
|
+
# Preserve the remote member IP checked against the peer certificate SAN.
|
|
9
|
+
externalTrafficPolicy: Local
|
|
10
|
+
selector:
|
|
11
|
+
app: {{ .name }}
|
|
12
|
+
ports:
|
|
13
|
+
- name: client
|
|
14
|
+
port: 2379
|
|
15
|
+
targetPort: 2379
|
|
16
|
+
nodePort: {{ .values.clientPort }}
|
|
17
|
+
- name: peer
|
|
18
|
+
port: 2380
|
|
19
|
+
targetPort: 2380
|
|
20
|
+
nodePort: {{ .values.peerPort }}
|
|
21
|
+
---
|
|
22
|
+
apiVersion: apps/v1
|
|
23
|
+
kind: StatefulSet
|
|
24
|
+
metadata:
|
|
25
|
+
name: {{ .name }}
|
|
26
|
+
spec:
|
|
27
|
+
serviceName: {{ .name }}
|
|
28
|
+
replicas: 1
|
|
29
|
+
selector:
|
|
30
|
+
matchLabels:
|
|
31
|
+
app: {{ .name }}
|
|
32
|
+
template:
|
|
33
|
+
metadata:
|
|
34
|
+
labels:
|
|
35
|
+
app: {{ .name }}
|
|
36
|
+
spec:
|
|
37
|
+
{{- with .values.pullSecret }}
|
|
38
|
+
imagePullSecrets:
|
|
39
|
+
- name: {{ . | quote }}
|
|
40
|
+
{{- end }}
|
|
41
|
+
containers:
|
|
42
|
+
- name: etcd
|
|
43
|
+
image: {{ required "etcdImage required" .values.etcdImage | quote }}
|
|
44
|
+
command: [etcd]
|
|
45
|
+
args:
|
|
46
|
+
- --name={{ .values.member.id }}
|
|
47
|
+
- --data-dir=/data/etcd
|
|
48
|
+
- --listen-client-urls=https://0.0.0.0:2379
|
|
49
|
+
- --listen-peer-urls=https://0.0.0.0:2380
|
|
50
|
+
- --advertise-client-urls=https://{{ .values.member.address }}:{{ .values.clientPort }}
|
|
51
|
+
- --initial-advertise-peer-urls=https://{{ .values.member.address }}:{{ .values.peerPort }}
|
|
52
|
+
- --initial-cluster={{ required "initialCluster required" .values.initialCluster }}
|
|
53
|
+
- --initial-cluster-token={{ required "initialClusterToken required" .values.initialClusterToken }}
|
|
54
|
+
- --initial-cluster-state={{ .values.initialClusterState }}
|
|
55
|
+
- --auto-compaction-mode=periodic
|
|
56
|
+
- --auto-compaction-retention={{ required "autoCompactionRetention required" .values.autoCompactionRetention }}
|
|
57
|
+
- --client-cert-auth=true
|
|
58
|
+
- --trusted-ca-file=/tls/ca.crt
|
|
59
|
+
- --cert-file=/tls/tls.crt
|
|
60
|
+
- --key-file=/tls/tls.key
|
|
61
|
+
- --peer-client-cert-auth=true
|
|
62
|
+
- --peer-trusted-ca-file=/tls/ca.crt
|
|
63
|
+
- --peer-cert-file=/tls/tls.crt
|
|
64
|
+
- --peer-key-file=/tls/tls.key
|
|
65
|
+
ports:
|
|
66
|
+
- {name: client, containerPort: 2379}
|
|
67
|
+
- {name: peer, containerPort: 2380}
|
|
68
|
+
# Local TCP liveness deliberately does not require a quorum.
|
|
69
|
+
livenessProbe:
|
|
70
|
+
tcpSocket: {port: client}
|
|
71
|
+
initialDelaySeconds: 20
|
|
72
|
+
readinessProbe:
|
|
73
|
+
tcpSocket: {port: client}
|
|
74
|
+
resources:
|
|
75
|
+
{{- toYaml (.values.memberResources | default .values.resources) | nindent 12 }}
|
|
76
|
+
volumeMounts:
|
|
77
|
+
- {name: data, mountPath: /data}
|
|
78
|
+
- {name: tls, mountPath: /tls, readOnly: true}
|
|
79
|
+
volumes:
|
|
80
|
+
- name: tls
|
|
81
|
+
secret:
|
|
82
|
+
secretName: {{ required "member TLS secret required" .values.member.tlsSecret }}
|
|
83
|
+
volumeClaimTemplates:
|
|
84
|
+
- metadata:
|
|
85
|
+
name: data
|
|
86
|
+
spec:
|
|
87
|
+
accessModes: [ReadWriteOnce]
|
|
88
|
+
storageClassName: {{ .values.storageClass | quote }}
|
|
89
|
+
resources:
|
|
90
|
+
requests:
|
|
91
|
+
storage: {{ required "etcd storage required" .values.storage }}
|
|
92
|
+
{{- end -}}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
{{- define "scada.workloads.historyMaintenance" -}}
|
|
2
|
+
apiVersion: batch/v1
|
|
3
|
+
kind: CronJob
|
|
4
|
+
metadata:
|
|
5
|
+
name: {{ .name }}
|
|
6
|
+
spec:
|
|
7
|
+
schedule: {{ .schedule | quote }}
|
|
8
|
+
concurrencyPolicy: Forbid
|
|
9
|
+
successfulJobsHistoryLimit: 1
|
|
10
|
+
failedJobsHistoryLimit: 2
|
|
11
|
+
jobTemplate:
|
|
12
|
+
spec:
|
|
13
|
+
backoffLimit: 2
|
|
14
|
+
activeDeadlineSeconds: 300
|
|
15
|
+
template:
|
|
16
|
+
spec:
|
|
17
|
+
{{- if or .alwaysPullSecret .pullSecret }}
|
|
18
|
+
imagePullSecrets:
|
|
19
|
+
- name: {{ if .alwaysPullSecret }}{{ .pullSecret }}{{ else }}{{ .pullSecret | quote }}{{ end }}
|
|
20
|
+
{{- end }}
|
|
21
|
+
restartPolicy: Never
|
|
22
|
+
containers:
|
|
23
|
+
- name: history-retention
|
|
24
|
+
image: {{ required "history maintenance image required" .image | quote }}
|
|
25
|
+
command: [node, --input-type=module, -e]
|
|
26
|
+
args:
|
|
27
|
+
- |
|
|
28
|
+
const response = await fetch(`${process.env.HISTORY_URL}/v1/history/purge`, {
|
|
29
|
+
method: 'POST', signal: AbortSignal.timeout(240000),
|
|
30
|
+
headers: { 'Content-Type': 'application/json', Authorization: `Bearer ${process.env.HISTORY_TOKEN}` },
|
|
31
|
+
body: JSON.stringify({ machine: 'maintenance' })
|
|
32
|
+
});
|
|
33
|
+
if (!response.ok) { throw new Error(`History purge failed: ${response.status}`); }
|
|
34
|
+
env:
|
|
35
|
+
- name: HISTORY_URL
|
|
36
|
+
value: {{ .url | quote }}
|
|
37
|
+
- name: HISTORY_TOKEN
|
|
38
|
+
valueFrom:
|
|
39
|
+
secretKeyRef:
|
|
40
|
+
name: {{ required "history token secret required" .tokenSecret }}
|
|
41
|
+
key: {{ .tokenKey }}
|
|
42
|
+
resources:
|
|
43
|
+
{{- toYaml .resources | nindent 16 }}
|
|
44
|
+
{{- end -}}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
{{- define "scada.workloads.historyReceiver" -}}
|
|
2
|
+
{{- $migrations := .values.receiverMigrationsMode | default "verify" }}
|
|
3
|
+
{{- if not (has $migrations (list "apply" "verify")) }}{{ fail "Invalid history receiver migration mode" }}{{- end }}
|
|
4
|
+
apiVersion: v1
|
|
5
|
+
kind: Service
|
|
6
|
+
metadata:
|
|
7
|
+
name: {{ .name }}
|
|
8
|
+
spec:
|
|
9
|
+
selector: {app: {{ .name }}}
|
|
10
|
+
ports:
|
|
11
|
+
- {name: http, port: 8081, targetPort: http}
|
|
12
|
+
---
|
|
13
|
+
apiVersion: apps/v1
|
|
14
|
+
kind: Deployment
|
|
15
|
+
metadata:
|
|
16
|
+
name: {{ .name }}
|
|
17
|
+
spec:
|
|
18
|
+
replicas: 1
|
|
19
|
+
strategy: {type: Recreate}
|
|
20
|
+
selector:
|
|
21
|
+
matchLabels: {app: {{ .name }}}
|
|
22
|
+
template:
|
|
23
|
+
metadata:
|
|
24
|
+
labels: {app: {{ .name }}}
|
|
25
|
+
spec:
|
|
26
|
+
{{- with .values.pullSecret }}
|
|
27
|
+
imagePullSecrets:
|
|
28
|
+
- name: {{ . | quote }}
|
|
29
|
+
{{- end }}
|
|
30
|
+
containers:
|
|
31
|
+
- name: history-api
|
|
32
|
+
image: {{ required "receiverImage required for local history API" .values.receiverImage | quote }}
|
|
33
|
+
command: {{ .command | toJson }}
|
|
34
|
+
env:
|
|
35
|
+
- name: POSTGRES_URL
|
|
36
|
+
valueFrom:
|
|
37
|
+
secretKeyRef:
|
|
38
|
+
name: {{ required "existing receiver database secret required" .values.receiverDatabaseSecret }}
|
|
39
|
+
key: {{ .values.receiverPostgresKey }}
|
|
40
|
+
- {name: SUPERVISOR_MIGRATIONS, value: {{ $migrations | quote }}}
|
|
41
|
+
{{- if eq $migrations "apply" }}
|
|
42
|
+
- name: POSTGRES_ADMIN_URL
|
|
43
|
+
valueFrom:
|
|
44
|
+
secretKeyRef:
|
|
45
|
+
name: {{ .values.receiverDatabaseSecret }}
|
|
46
|
+
key: {{ .values.receiverAdminKey }}
|
|
47
|
+
{{- end }}
|
|
48
|
+
- name: STATE_HTTP_TOKEN
|
|
49
|
+
valueFrom:
|
|
50
|
+
secretKeyRef:
|
|
51
|
+
name: {{ required "history token secret required" .values.historyTokenSecret }}
|
|
52
|
+
key: {{ .values.historyTokenKey }}
|
|
53
|
+
- {name: STATE_HTTP_PORT, value: '8081'}
|
|
54
|
+
- {name: SINK_DB_PROFILE, value: edge}
|
|
55
|
+
- {name: SINK_PIPELINES, value: 'false'}
|
|
56
|
+
- {name: SUPERVISOR_WRITER_EPOCH, value: {{ required "writerEpoch required for segment admission" .values.writerEpoch | quote }}}
|
|
57
|
+
- {name: SEGMENT_ADMIT_QUEUE, value: {{ .admissionQueue | quote }}}
|
|
58
|
+
- {name: SEGMENT_ADMIT_DESTINATION, value: {{ .admissionDestination | quote }}}
|
|
59
|
+
- {name: HISTORY_AMQP_ENABLED, value: 'true'}
|
|
60
|
+
- {name: HISTORY_AMQP_QUEUE, value: {{ required "local history queue required" .values.historyQueue | quote }}}
|
|
61
|
+
- {name: HISTORY_AMQP_BINDINGS, value: {{ .values.historyBindings | toJson | quote }}}
|
|
62
|
+
- name: HISTORY_AMQP_URL
|
|
63
|
+
valueFrom:
|
|
64
|
+
secretKeyRef:
|
|
65
|
+
name: {{ .deliverySecret }}
|
|
66
|
+
key: {{ .values.historyAmqpKey }}
|
|
67
|
+
- {name: RETENTION_ENABLED, value: 'false'}
|
|
68
|
+
- {name: HISTORY_RETENTION_DAYS, value: {{ .values.historyRetentionDays | quote }}}
|
|
69
|
+
ports:
|
|
70
|
+
- {name: http, containerPort: 8081}
|
|
71
|
+
# The API opens its listener only after migrations have completed.
|
|
72
|
+
startupProbe:
|
|
73
|
+
tcpSocket: {port: http}
|
|
74
|
+
periodSeconds: 5
|
|
75
|
+
failureThreshold: 180
|
|
76
|
+
readinessProbe:
|
|
77
|
+
tcpSocket: {port: http}
|
|
78
|
+
livenessProbe:
|
|
79
|
+
exec:
|
|
80
|
+
command:
|
|
81
|
+
- node
|
|
82
|
+
- -e
|
|
83
|
+
- "fetch('http://127.0.0.1:8081/', {signal:AbortSignal.timeout(2000)}).then(()=>process.exit(0)).catch(()=>process.exit(1))"
|
|
84
|
+
timeoutSeconds: 4
|
|
85
|
+
periodSeconds: 15
|
|
86
|
+
resources:
|
|
87
|
+
{{- toYaml (.values.historyResources | default .values.resources) | nindent 12 }}
|
|
88
|
+
{{- end -}}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{{- define "scada.workloads.journalSupervisor" -}}
|
|
2
|
+
apiVersion: v1
|
|
3
|
+
kind: PersistentVolumeClaim
|
|
4
|
+
metadata:
|
|
5
|
+
name: {{ .claim }}
|
|
6
|
+
spec:
|
|
7
|
+
accessModes: [ReadWriteOnce]
|
|
8
|
+
storageClassName: {{ .supervisor.storageClass | quote }}
|
|
9
|
+
resources:
|
|
10
|
+
requests:
|
|
11
|
+
storage: {{ .supervisor.journalStorage | quote }}
|
|
12
|
+
---
|
|
13
|
+
apiVersion: v1
|
|
14
|
+
kind: ConfigMap
|
|
15
|
+
metadata:
|
|
16
|
+
name: {{ .name }}
|
|
17
|
+
data:
|
|
18
|
+
application.conf: {{ .supervisor.config | quote }}
|
|
19
|
+
{{- if .supervisor.enabled }}
|
|
20
|
+
---
|
|
21
|
+
apiVersion: apps/v1
|
|
22
|
+
kind: Deployment
|
|
23
|
+
metadata:
|
|
24
|
+
name: {{ .name }}
|
|
25
|
+
spec:
|
|
26
|
+
replicas: 1
|
|
27
|
+
strategy:
|
|
28
|
+
type: Recreate
|
|
29
|
+
selector:
|
|
30
|
+
matchLabels:
|
|
31
|
+
app: {{ .app }}
|
|
32
|
+
template:
|
|
33
|
+
metadata:
|
|
34
|
+
labels:
|
|
35
|
+
{{- toYaml .labels | nindent 8 }}
|
|
36
|
+
annotations:
|
|
37
|
+
checksum/config: {{ .supervisor.config | sha256sum }}
|
|
38
|
+
{{- with .supervisor.podAnnotations }}
|
|
39
|
+
{{- toYaml . | nindent 8 }}
|
|
40
|
+
{{- end }}
|
|
41
|
+
spec:
|
|
42
|
+
imagePullSecrets:
|
|
43
|
+
- name: {{ .pullSecret }}
|
|
44
|
+
containers:
|
|
45
|
+
- name: supervisor
|
|
46
|
+
image: {{ .image | quote }}
|
|
47
|
+
args: [/app/config/application.conf]
|
|
48
|
+
{{- with .extraEnv }}
|
|
49
|
+
{{- . | nindent 10 }}
|
|
50
|
+
{{- end }}
|
|
51
|
+
ports:
|
|
52
|
+
- name: health
|
|
53
|
+
containerPort: 9092
|
|
54
|
+
readinessProbe:
|
|
55
|
+
httpGet: {path: /ready, port: health}
|
|
56
|
+
initialDelaySeconds: 15
|
|
57
|
+
livenessProbe:
|
|
58
|
+
httpGet: {path: /health, port: health}
|
|
59
|
+
initialDelaySeconds: 30
|
|
60
|
+
resources:
|
|
61
|
+
{{- toYaml .resources | nindent 12 }}
|
|
62
|
+
volumeMounts:
|
|
63
|
+
- name: config
|
|
64
|
+
mountPath: /app/config
|
|
65
|
+
readOnly: true
|
|
66
|
+
- name: journal
|
|
67
|
+
mountPath: /var/lib/supervisor
|
|
68
|
+
{{- with .supervisor.volumeMounts }}
|
|
69
|
+
{{- toYaml . | nindent 12 }}
|
|
70
|
+
{{- end }}
|
|
71
|
+
volumes:
|
|
72
|
+
- name: config
|
|
73
|
+
configMap:
|
|
74
|
+
name: {{ .name }}
|
|
75
|
+
- name: journal
|
|
76
|
+
persistentVolumeClaim:
|
|
77
|
+
claimName: {{ .claim }}
|
|
78
|
+
{{- with .supervisor.volumes }}
|
|
79
|
+
{{- toYaml . | nindent 8 }}
|
|
80
|
+
{{- end }}
|
|
81
|
+
{{- end }}
|
|
82
|
+
{{- end -}}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{{- define "scada.workloads.postgresRole" -}}
|
|
2
|
+
{{- $role := required "PostgreSQL role is required" .role }}
|
|
3
|
+
{{- if not (regexMatch "^[a-z_][a-z0-9_]{0,62}$" $role) }}
|
|
4
|
+
{{- fail "PostgreSQL role must be a simple unquoted role name" }}
|
|
5
|
+
{{- end }}
|
|
6
|
+
apiVersion: batch/v1
|
|
7
|
+
kind: Job
|
|
8
|
+
metadata:
|
|
9
|
+
name: {{ .name }}
|
|
10
|
+
spec:
|
|
11
|
+
backoffLimit: 3
|
|
12
|
+
activeDeadlineSeconds: 180
|
|
13
|
+
template:
|
|
14
|
+
spec:
|
|
15
|
+
restartPolicy: OnFailure
|
|
16
|
+
imagePullSecrets:
|
|
17
|
+
- name: {{ .pullSecret }}
|
|
18
|
+
containers:
|
|
19
|
+
- name: roles
|
|
20
|
+
image: {{ .image | quote }}
|
|
21
|
+
command: [sh, -ec]
|
|
22
|
+
args:
|
|
23
|
+
- |
|
|
24
|
+
until pg_isready -q; do sleep 2; done
|
|
25
|
+
psql -v ON_ERROR_STOP=1 --command='DO $roles$ BEGIN IF NOT EXISTS (SELECT FROM pg_roles WHERE rolname = '\''{{ $role }}'\'') THEN CREATE ROLE {{ $role }} NOLOGIN; END IF; END $roles$;'
|
|
26
|
+
env:
|
|
27
|
+
- name: PGHOST
|
|
28
|
+
value: {{ .host | quote }}
|
|
29
|
+
- name: PGDATABASE
|
|
30
|
+
value: {{ .database | quote }}
|
|
31
|
+
- name: PGUSER
|
|
32
|
+
valueFrom:
|
|
33
|
+
secretKeyRef:
|
|
34
|
+
name: {{ .secret }}
|
|
35
|
+
key: user
|
|
36
|
+
- name: PGPASSWORD
|
|
37
|
+
valueFrom:
|
|
38
|
+
secretKeyRef:
|
|
39
|
+
name: {{ .secret }}
|
|
40
|
+
key: password
|
|
41
|
+
resources:
|
|
42
|
+
{{- toYaml .resources | nindent 12 }}
|
|
43
|
+
{{- end -}}
|