datadouble-kubernetes 0.0.3__tar.gz
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.
- datadouble_kubernetes-0.0.3/.gitignore +21 -0
- datadouble_kubernetes-0.0.3/LICENSE +21 -0
- datadouble_kubernetes-0.0.3/PKG-INFO +267 -0
- datadouble_kubernetes-0.0.3/README.md +246 -0
- datadouble_kubernetes-0.0.3/pyproject.toml +44 -0
- datadouble_kubernetes-0.0.3/src/datadouble_kubernetes/__init__.py +580 -0
- datadouble_kubernetes-0.0.3/src/datadouble_kubernetes/py.typed +0 -0
- datadouble_kubernetes-0.0.3/src/datadouble_kubernetes/runtime.py +432 -0
- datadouble_kubernetes-0.0.3/tests/test_kubernetes.py +715 -0
- datadouble_kubernetes-0.0.3/tests/test_kubernetes_runtime.py +504 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Copyright (c) 2026- Tight Line LLC
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
__pycache__/
|
|
5
|
+
*.py[cod]
|
|
6
|
+
.venv/
|
|
7
|
+
.env
|
|
8
|
+
.coverage
|
|
9
|
+
.coverage.*
|
|
10
|
+
coverage.xml
|
|
11
|
+
.reports/
|
|
12
|
+
.pytest_cache/
|
|
13
|
+
.mypy_cache/
|
|
14
|
+
.ruff_cache/
|
|
15
|
+
dist/
|
|
16
|
+
site/
|
|
17
|
+
.cache/
|
|
18
|
+
|
|
19
|
+
# The default work directory of `datadouble run`.
|
|
20
|
+
.datadouble/
|
|
21
|
+
node_modules/
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026- Tight Line LLC
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: datadouble-kubernetes
|
|
3
|
+
Version: 0.0.3
|
|
4
|
+
Summary: Kubernetes replicate and announce adapters for Datadouble
|
|
5
|
+
Project-URL: Homepage, https://datadouble.tightlinesoftware.com/
|
|
6
|
+
Project-URL: Source, https://github.com/datadouble/datadouble
|
|
7
|
+
Author: Tight Line LLC
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Development Status :: 2 - Pre-Alpha
|
|
11
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
14
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
15
|
+
Classifier: Topic :: System :: Clustering
|
|
16
|
+
Classifier: Typing :: Typed
|
|
17
|
+
Requires-Python: >=3.13
|
|
18
|
+
Requires-Dist: datadouble
|
|
19
|
+
Requires-Dist: pyyaml>=6.0.3
|
|
20
|
+
Description-Content-Type: text/markdown
|
|
21
|
+
|
|
22
|
+
# datadouble-kubernetes
|
|
23
|
+
|
|
24
|
+
Kubernetes adapters for [Datadouble](https://datadouble.tightlinesoftware.com/):
|
|
25
|
+
|
|
26
|
+
- **`k8s-pv`** (replicate): each copy is a directory and a PersistentVolume
|
|
27
|
+
pointing at it, labelled so consumers select it in a PersistentVolumeClaim.
|
|
28
|
+
A spec with `files` adds a second one, `datadouble-<copy id>-files`,
|
|
29
|
+
labelled `datadouble.dev/engine: files`, for the group's files.
|
|
30
|
+
A bound volume counts as claimed; once its claim is deleted the copy is
|
|
31
|
+
removed and the pool refilled.
|
|
32
|
+
- **`k8s-secret`** (announce): a Secret per copy holding where it is and, for
|
|
33
|
+
instance copies, its credentials.
|
|
34
|
+
- **`kubernetes`** (container runtime): engine software in pods, sharing the
|
|
35
|
+
work directory through a PersistentVolumeClaim (decision 73).
|
|
36
|
+
|
|
37
|
+
```yaml
|
|
38
|
+
replicate:
|
|
39
|
+
using:
|
|
40
|
+
k8s-pv:
|
|
41
|
+
path: /srv/clones # where copies are written
|
|
42
|
+
local: # a local volume on that node, or
|
|
43
|
+
node: worker-1
|
|
44
|
+
# nfs:
|
|
45
|
+
# server: nfs.internal
|
|
46
|
+
# path: /exports/clones
|
|
47
|
+
storage_class: datadouble
|
|
48
|
+
announce:
|
|
49
|
+
- k8s-secret: {} # Secrets in Datadouble's own namespace
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Datadouble writes each copy into a directory under `path`, as the job's own
|
|
53
|
+
machine sees it. With `local`, the volume points at that same directory on
|
|
54
|
+
the node. With `nfs`, `path` must be where the export is mounted on the job's
|
|
55
|
+
machine, and `nfs.path` is the export's own path on the NFS server, which the
|
|
56
|
+
volumes point at. Datadouble never opens `nfs.path`, so `ci init` mounts only
|
|
57
|
+
`path` into the jobs it writes, never `nfs.path`
|
|
58
|
+
([which settings become mounts](../../docs/ci-cd.md#which-settings-become-mounts)).
|
|
59
|
+
On a Kubernetes agent, only `path` has to be under the runtime's `mount`:
|
|
60
|
+
|
|
61
|
+
```yaml
|
|
62
|
+
runtime:
|
|
63
|
+
kubernetes:
|
|
64
|
+
claim: datadouble
|
|
65
|
+
mount: /srv/datadouble
|
|
66
|
+
replicate:
|
|
67
|
+
using:
|
|
68
|
+
k8s-pv:
|
|
69
|
+
path: /srv/datadouble/clones # the export, mounted from the claim
|
|
70
|
+
nfs:
|
|
71
|
+
server: nfs.example.com
|
|
72
|
+
path: /exports/datadouble/clones # the same directory on the server
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
Each volume carries `datadouble.dev/` labels: `spec`, `group`, `engine`,
|
|
76
|
+
`engine-version`, `server-version`, `generation` and `copy`. `engine-version`
|
|
77
|
+
is the engine's compatibility line (`17` for PostgreSQL, `8.4` for MySQL), not
|
|
78
|
+
the exact version: select on it, and serve copies with the newest release of
|
|
79
|
+
that line (`postgres:17`, `mysql:8.4`), which opens every copy of the line
|
|
80
|
+
(Oracle copies need exactly their `server-version`). `server-version` is the
|
|
81
|
+
exact version that wrote the copy, for consumers that must match it; for
|
|
82
|
+
engines without a server (Salesforce, file trees) it is the image layout's
|
|
83
|
+
version. A Helm chart renders its image before any claim
|
|
84
|
+
binds, so it cannot read the bound volume's labels; choose the image from the
|
|
85
|
+
line, or look up an available volume's `server-version` before rendering.
|
|
86
|
+
|
|
87
|
+
All three drive `kubectl` (`DATADOUBLE_KUBECTL` names another binary).
|
|
88
|
+
|
|
89
|
+
## Namespaces
|
|
90
|
+
|
|
91
|
+
```yaml
|
|
92
|
+
runtime:
|
|
93
|
+
kubernetes:
|
|
94
|
+
claim: datadouble # the PersistentVolumeClaim holding the work directory
|
|
95
|
+
mount: /srv/datadouble # where Datadouble's own pod mounts it
|
|
96
|
+
# namespace: shop-staging # optional
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
Leave `namespace` out unless pods must start somewhere else. Then they start
|
|
100
|
+
where `kubectl` would put them unasked: inside a cluster (no `kubeconfig` in
|
|
101
|
+
the settings, no `KUBECONFIG`, and a service account namespace file in
|
|
102
|
+
Datadouble's pod), that pod's own namespace, read from
|
|
103
|
+
`/var/run/secrets/kubernetes.io/serviceaccount/namespace`; otherwise the
|
|
104
|
+
namespace of the kubeconfig's context (the settings' `context`, or its current
|
|
105
|
+
one), or `default` when it names none. So one spec serves CI/CD jobs that run
|
|
106
|
+
as pods in each side's own namespace, which `ci init` requires a set
|
|
107
|
+
namespace to match (decision 133).
|
|
108
|
+
|
|
109
|
+
An empty `KUBECONFIG` counts as unset, as it does for `kubectl`. A context
|
|
110
|
+
`kubectl` cannot read (a bad kubeconfig, an unknown context) fails, naming
|
|
111
|
+
the kubeconfig and context, rather than falling back to `default`.
|
|
112
|
+
|
|
113
|
+
`k8s-secret` follows the same rule, with its own `kubeconfig` and `context`
|
|
114
|
+
(decision 135): left out, its `namespace` is the one `kubectl` would use, so
|
|
115
|
+
copies' Secrets go to the namespace Datadouble's pod runs in, where the Helm
|
|
116
|
+
chart's Role and the Jenkins `instructions` let it write them. `announce`
|
|
117
|
+
reports where each went (`k8s-secret:shop-dev/datadouble-<copy id>`), and
|
|
118
|
+
the copy registry records it, so `release` deletes each Secret from the
|
|
119
|
+
namespace it was written to, even when the releasing process would resolve
|
|
120
|
+
another: a copy claimed from a laptop, whose context names `alice`, gets its
|
|
121
|
+
Secret in `alice`, and the scheduled sweep running in `shop-dev` deletes it
|
|
122
|
+
there. Two things must hold for that:
|
|
123
|
+
|
|
124
|
+
- **One cluster.** Every process that announces or releases with the spec
|
|
125
|
+
reaches the same cluster through the `k8s-secret` entry. The registry
|
|
126
|
+
records namespaces, not clusters.
|
|
127
|
+
- **Delete rights.** The identity that releases (the sweep's service
|
|
128
|
+
account) may `delete` Secrets in every namespace a copy was announced
|
|
129
|
+
into, `alice` here.
|
|
130
|
+
|
|
131
|
+
Release tries every Secret, then fails once, naming each one it could not
|
|
132
|
+
delete (`k8s-secret:alice/datadouble-<copy id>`). The copy is already gone
|
|
133
|
+
from the registry, so delete those by hand. Consumers look for a Secret
|
|
134
|
+
where it went, so run `claim` from where consumers expect it, or set
|
|
135
|
+
`namespace`. Set `namespace` to write Secrets anywhere else, such as the
|
|
136
|
+
namespace consumers run in, and grant Datadouble's service account `get`,
|
|
137
|
+
`create`, `patch` and `delete` on Secrets there.
|
|
138
|
+
|
|
139
|
+
Before decision 135 `k8s-secret` always wrote to `default`, and the
|
|
140
|
+
registry did not record it. Releases now look for those Secrets in the newly
|
|
141
|
+
resolved namespace, so keep `namespace: default` in the spec until copies
|
|
142
|
+
announced before the change are released, or delete their
|
|
143
|
+
`datadouble-<copy id>` Secrets in `default` by hand.
|
|
144
|
+
|
|
145
|
+
## Claims for the CI job's own pod
|
|
146
|
+
|
|
147
|
+
Every pod the runtime starts mounts one claim, the work claim, so every path
|
|
148
|
+
an engine reads or writes is on it. The work claim also holds the work
|
|
149
|
+
directory, where a build keeps the data it extracts from the source.
|
|
150
|
+
|
|
151
|
+
Some directories are never touched by an engine. `promote`'s export directory
|
|
152
|
+
is one: Datadouble's own process copies images into it. Often a web server
|
|
153
|
+
serves the export to the non-production side, through the read-only `http`
|
|
154
|
+
fetch store, so the export has to be on that server's share. If the export
|
|
155
|
+
were on the work claim, the web server could reach the work directory too.
|
|
156
|
+
|
|
157
|
+
`claims` lists more claims for the CI job's own pod, the pod that runs
|
|
158
|
+
Datadouble on Jenkins' Kubernetes agents and in the Argo CD chart:
|
|
159
|
+
|
|
160
|
+
```yaml
|
|
161
|
+
runtime:
|
|
162
|
+
kubernetes:
|
|
163
|
+
claim: datadouble
|
|
164
|
+
mount: /srv/datadouble
|
|
165
|
+
claims:
|
|
166
|
+
- claim: shop-export # a PersistentVolumeClaim in the side's namespace
|
|
167
|
+
mount: /export # where the job's pod mounts it
|
|
168
|
+
promote:
|
|
169
|
+
to:
|
|
170
|
+
- filesystem:
|
|
171
|
+
path: /export/shop
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
- The runtime itself ignores `claims`. Engine pods mount only `claim`.
|
|
175
|
+
- A job's pod mounts only the claims its own paths are on, beside the work
|
|
176
|
+
claim, and `ci init` lists in its `instructions` only the claims the
|
|
177
|
+
side's jobs mount. So one spec can name a claim only one side has: here,
|
|
178
|
+
only `promote` and production's `prune` mount `shop-export`, and the
|
|
179
|
+
non-production side never needs it.
|
|
180
|
+
- A path on one of these claims need not be under the work claim's `mount`.
|
|
181
|
+
Jobs that start engines (`build`, `provision`, `release`) can't name one, so
|
|
182
|
+
the store, staging and the work directory stay on the work claim.
|
|
183
|
+
- The mounts can't overlap each other, the work claim's mount, or a path the
|
|
184
|
+
job's pod already uses: `/etc/datadouble-boundary`, the Jenkins agent's
|
|
185
|
+
`/home/jenkins`, the Argo CD chart's `/workspace`, and a mounted spec
|
|
186
|
+
directory. `claims` can't list the work claim.
|
|
187
|
+
|
|
188
|
+
## Reaching the cluster
|
|
189
|
+
|
|
190
|
+
Without settings, `kubectl` uses the pod's service account when Datadouble
|
|
191
|
+
runs in the cluster, or the ambient configuration (`KUBECONFIG`,
|
|
192
|
+
`~/.kube/config`) otherwise. A job in the cluster it drives, such as the Argo
|
|
193
|
+
CD jobs, needs nothing more.
|
|
194
|
+
|
|
195
|
+
To drive a cluster from outside it, give each adapter that talks to it a
|
|
196
|
+
`kubeconfig`, a secret reference to a kubeconfig's content, and optionally
|
|
197
|
+
the `context` to use:
|
|
198
|
+
|
|
199
|
+
```yaml
|
|
200
|
+
runtime:
|
|
201
|
+
kubernetes:
|
|
202
|
+
claim: datadouble-work
|
|
203
|
+
mount: /work
|
|
204
|
+
kubeconfig:
|
|
205
|
+
env: BUILD_KUBECONFIG
|
|
206
|
+
context: build
|
|
207
|
+
replicate:
|
|
208
|
+
using:
|
|
209
|
+
k8s-pv:
|
|
210
|
+
path: /srv/clones
|
|
211
|
+
local:
|
|
212
|
+
node: worker-1
|
|
213
|
+
kubeconfig:
|
|
214
|
+
env: DEV_KUBECONFIG
|
|
215
|
+
announce:
|
|
216
|
+
- k8s-secret:
|
|
217
|
+
namespace: dev
|
|
218
|
+
kubeconfig:
|
|
219
|
+
env: DEV_KUBECONFIG
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
- **A secret reference to the content, not the runner's kubeconfig file.**
|
|
223
|
+
`{env: NAME}` holds the kubeconfig itself, not a path to one: in CI jobs
|
|
224
|
+
Datadouble runs in its image, which sees only the paths in the spec,
|
|
225
|
+
and as the engine's user (decision 86), who cannot read the runner user's
|
|
226
|
+
`~/.kube/config`. `{file: /path}` is for a secret file mounted for this
|
|
227
|
+
purpose, such as a Kubernetes Secret volume: `ci init` mounts that path
|
|
228
|
+
into the job, so it must exist on the runner and be readable by the
|
|
229
|
+
engine's user (`999:999` for PostgreSQL). On Argo CD it must also be under
|
|
230
|
+
the claim's directory, so prefer `{env: NAME}` there.
|
|
231
|
+
- **Credentials the image can use.** The Datadouble image holds `kubectl`
|
|
232
|
+
and nothing else, so a kubeconfig whose user runs an exec credential
|
|
233
|
+
plugin (`aws eks get-token`, `gke-gcloud-auth-plugin`, `kubelogin`) fails.
|
|
234
|
+
For EKS, GKE or AKS, use a kubeconfig with a service account token or a
|
|
235
|
+
client certificate, embedded in it (`token`, `client-certificate-data`),
|
|
236
|
+
not in files it names (`tokenFile`, `client-certificate`), since those
|
|
237
|
+
paths are not mounted.
|
|
238
|
+
- **`ci init` lists the variable** among the secrets of each job whose part
|
|
239
|
+
of the spec references it, and only those: the runtime's for `build`,
|
|
240
|
+
`provision` and `release`; `k8s-pv`'s for `provision`, `release` and the
|
|
241
|
+
non-production `prune`; `k8s-secret`'s for `provision` and `release`.
|
|
242
|
+
Define it in each system's own secret store, as for any other secret
|
|
243
|
+
(repository secrets, CI/CD variables, Jenkins credentials, a Kubernetes
|
|
244
|
+
Secret, or a Vault-backed secret the CI system injects).
|
|
245
|
+
- **Defining a multi-line secret.** GitHub Actions and Kubernetes Secrets
|
|
246
|
+
take a kubeconfig as it is. In GitLab, make it a CI/CD variable of type
|
|
247
|
+
"Variable", not "File" (a File variable holds a path, which the job's
|
|
248
|
+
container cannot see), protected, with masking off: GitLab masks only
|
|
249
|
+
single-line values. In Jenkins, a Secret text credential holds one line in
|
|
250
|
+
the web form, so create a multi-line one through the API or Configuration
|
|
251
|
+
as Code.
|
|
252
|
+
- **Datadouble writes the kubeconfig to a private temporary file** for each
|
|
253
|
+
`kubectl` call: a file only its user can read (mode 0600), in a directory
|
|
254
|
+
of its own (mode 0700), passed with `--kubeconfig` (and `--context`), both
|
|
255
|
+
removed when the call ends, even after a failure or when the job is
|
|
256
|
+
cancelled (SIGTERM); a `kubernetes` port-forward keeps its file until the
|
|
257
|
+
forward stops. The directory is made in the system's temporary directory
|
|
258
|
+
(`TMPDIR`), or in the home directory when that is under the `kubernetes`
|
|
259
|
+
runtime's `mount`, which pods see; if both are, the call fails, asking for
|
|
260
|
+
`TMPDIR` elsewhere.
|
|
261
|
+
- **What is hidden.** Every string value in the kubeconfig at least 16
|
|
262
|
+
characters long (tokens, keys, certificates, server URLs) is replaced with
|
|
263
|
+
`[redacted]` in everything `kubectl` prints that Datadouble passes on, and
|
|
264
|
+
only those values are handed to the CI system's log masking, so lines such
|
|
265
|
+
as `kind: Config` stay readable. A kubeconfig that cannot be resolved
|
|
266
|
+
fails with `unresolved_reference` before any work, including before a
|
|
267
|
+
`kubernetes` runtime starts a pod.
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
# datadouble-kubernetes
|
|
2
|
+
|
|
3
|
+
Kubernetes adapters for [Datadouble](https://datadouble.tightlinesoftware.com/):
|
|
4
|
+
|
|
5
|
+
- **`k8s-pv`** (replicate): each copy is a directory and a PersistentVolume
|
|
6
|
+
pointing at it, labelled so consumers select it in a PersistentVolumeClaim.
|
|
7
|
+
A spec with `files` adds a second one, `datadouble-<copy id>-files`,
|
|
8
|
+
labelled `datadouble.dev/engine: files`, for the group's files.
|
|
9
|
+
A bound volume counts as claimed; once its claim is deleted the copy is
|
|
10
|
+
removed and the pool refilled.
|
|
11
|
+
- **`k8s-secret`** (announce): a Secret per copy holding where it is and, for
|
|
12
|
+
instance copies, its credentials.
|
|
13
|
+
- **`kubernetes`** (container runtime): engine software in pods, sharing the
|
|
14
|
+
work directory through a PersistentVolumeClaim (decision 73).
|
|
15
|
+
|
|
16
|
+
```yaml
|
|
17
|
+
replicate:
|
|
18
|
+
using:
|
|
19
|
+
k8s-pv:
|
|
20
|
+
path: /srv/clones # where copies are written
|
|
21
|
+
local: # a local volume on that node, or
|
|
22
|
+
node: worker-1
|
|
23
|
+
# nfs:
|
|
24
|
+
# server: nfs.internal
|
|
25
|
+
# path: /exports/clones
|
|
26
|
+
storage_class: datadouble
|
|
27
|
+
announce:
|
|
28
|
+
- k8s-secret: {} # Secrets in Datadouble's own namespace
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
Datadouble writes each copy into a directory under `path`, as the job's own
|
|
32
|
+
machine sees it. With `local`, the volume points at that same directory on
|
|
33
|
+
the node. With `nfs`, `path` must be where the export is mounted on the job's
|
|
34
|
+
machine, and `nfs.path` is the export's own path on the NFS server, which the
|
|
35
|
+
volumes point at. Datadouble never opens `nfs.path`, so `ci init` mounts only
|
|
36
|
+
`path` into the jobs it writes, never `nfs.path`
|
|
37
|
+
([which settings become mounts](../../docs/ci-cd.md#which-settings-become-mounts)).
|
|
38
|
+
On a Kubernetes agent, only `path` has to be under the runtime's `mount`:
|
|
39
|
+
|
|
40
|
+
```yaml
|
|
41
|
+
runtime:
|
|
42
|
+
kubernetes:
|
|
43
|
+
claim: datadouble
|
|
44
|
+
mount: /srv/datadouble
|
|
45
|
+
replicate:
|
|
46
|
+
using:
|
|
47
|
+
k8s-pv:
|
|
48
|
+
path: /srv/datadouble/clones # the export, mounted from the claim
|
|
49
|
+
nfs:
|
|
50
|
+
server: nfs.example.com
|
|
51
|
+
path: /exports/datadouble/clones # the same directory on the server
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Each volume carries `datadouble.dev/` labels: `spec`, `group`, `engine`,
|
|
55
|
+
`engine-version`, `server-version`, `generation` and `copy`. `engine-version`
|
|
56
|
+
is the engine's compatibility line (`17` for PostgreSQL, `8.4` for MySQL), not
|
|
57
|
+
the exact version: select on it, and serve copies with the newest release of
|
|
58
|
+
that line (`postgres:17`, `mysql:8.4`), which opens every copy of the line
|
|
59
|
+
(Oracle copies need exactly their `server-version`). `server-version` is the
|
|
60
|
+
exact version that wrote the copy, for consumers that must match it; for
|
|
61
|
+
engines without a server (Salesforce, file trees) it is the image layout's
|
|
62
|
+
version. A Helm chart renders its image before any claim
|
|
63
|
+
binds, so it cannot read the bound volume's labels; choose the image from the
|
|
64
|
+
line, or look up an available volume's `server-version` before rendering.
|
|
65
|
+
|
|
66
|
+
All three drive `kubectl` (`DATADOUBLE_KUBECTL` names another binary).
|
|
67
|
+
|
|
68
|
+
## Namespaces
|
|
69
|
+
|
|
70
|
+
```yaml
|
|
71
|
+
runtime:
|
|
72
|
+
kubernetes:
|
|
73
|
+
claim: datadouble # the PersistentVolumeClaim holding the work directory
|
|
74
|
+
mount: /srv/datadouble # where Datadouble's own pod mounts it
|
|
75
|
+
# namespace: shop-staging # optional
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Leave `namespace` out unless pods must start somewhere else. Then they start
|
|
79
|
+
where `kubectl` would put them unasked: inside a cluster (no `kubeconfig` in
|
|
80
|
+
the settings, no `KUBECONFIG`, and a service account namespace file in
|
|
81
|
+
Datadouble's pod), that pod's own namespace, read from
|
|
82
|
+
`/var/run/secrets/kubernetes.io/serviceaccount/namespace`; otherwise the
|
|
83
|
+
namespace of the kubeconfig's context (the settings' `context`, or its current
|
|
84
|
+
one), or `default` when it names none. So one spec serves CI/CD jobs that run
|
|
85
|
+
as pods in each side's own namespace, which `ci init` requires a set
|
|
86
|
+
namespace to match (decision 133).
|
|
87
|
+
|
|
88
|
+
An empty `KUBECONFIG` counts as unset, as it does for `kubectl`. A context
|
|
89
|
+
`kubectl` cannot read (a bad kubeconfig, an unknown context) fails, naming
|
|
90
|
+
the kubeconfig and context, rather than falling back to `default`.
|
|
91
|
+
|
|
92
|
+
`k8s-secret` follows the same rule, with its own `kubeconfig` and `context`
|
|
93
|
+
(decision 135): left out, its `namespace` is the one `kubectl` would use, so
|
|
94
|
+
copies' Secrets go to the namespace Datadouble's pod runs in, where the Helm
|
|
95
|
+
chart's Role and the Jenkins `instructions` let it write them. `announce`
|
|
96
|
+
reports where each went (`k8s-secret:shop-dev/datadouble-<copy id>`), and
|
|
97
|
+
the copy registry records it, so `release` deletes each Secret from the
|
|
98
|
+
namespace it was written to, even when the releasing process would resolve
|
|
99
|
+
another: a copy claimed from a laptop, whose context names `alice`, gets its
|
|
100
|
+
Secret in `alice`, and the scheduled sweep running in `shop-dev` deletes it
|
|
101
|
+
there. Two things must hold for that:
|
|
102
|
+
|
|
103
|
+
- **One cluster.** Every process that announces or releases with the spec
|
|
104
|
+
reaches the same cluster through the `k8s-secret` entry. The registry
|
|
105
|
+
records namespaces, not clusters.
|
|
106
|
+
- **Delete rights.** The identity that releases (the sweep's service
|
|
107
|
+
account) may `delete` Secrets in every namespace a copy was announced
|
|
108
|
+
into, `alice` here.
|
|
109
|
+
|
|
110
|
+
Release tries every Secret, then fails once, naming each one it could not
|
|
111
|
+
delete (`k8s-secret:alice/datadouble-<copy id>`). The copy is already gone
|
|
112
|
+
from the registry, so delete those by hand. Consumers look for a Secret
|
|
113
|
+
where it went, so run `claim` from where consumers expect it, or set
|
|
114
|
+
`namespace`. Set `namespace` to write Secrets anywhere else, such as the
|
|
115
|
+
namespace consumers run in, and grant Datadouble's service account `get`,
|
|
116
|
+
`create`, `patch` and `delete` on Secrets there.
|
|
117
|
+
|
|
118
|
+
Before decision 135 `k8s-secret` always wrote to `default`, and the
|
|
119
|
+
registry did not record it. Releases now look for those Secrets in the newly
|
|
120
|
+
resolved namespace, so keep `namespace: default` in the spec until copies
|
|
121
|
+
announced before the change are released, or delete their
|
|
122
|
+
`datadouble-<copy id>` Secrets in `default` by hand.
|
|
123
|
+
|
|
124
|
+
## Claims for the CI job's own pod
|
|
125
|
+
|
|
126
|
+
Every pod the runtime starts mounts one claim, the work claim, so every path
|
|
127
|
+
an engine reads or writes is on it. The work claim also holds the work
|
|
128
|
+
directory, where a build keeps the data it extracts from the source.
|
|
129
|
+
|
|
130
|
+
Some directories are never touched by an engine. `promote`'s export directory
|
|
131
|
+
is one: Datadouble's own process copies images into it. Often a web server
|
|
132
|
+
serves the export to the non-production side, through the read-only `http`
|
|
133
|
+
fetch store, so the export has to be on that server's share. If the export
|
|
134
|
+
were on the work claim, the web server could reach the work directory too.
|
|
135
|
+
|
|
136
|
+
`claims` lists more claims for the CI job's own pod, the pod that runs
|
|
137
|
+
Datadouble on Jenkins' Kubernetes agents and in the Argo CD chart:
|
|
138
|
+
|
|
139
|
+
```yaml
|
|
140
|
+
runtime:
|
|
141
|
+
kubernetes:
|
|
142
|
+
claim: datadouble
|
|
143
|
+
mount: /srv/datadouble
|
|
144
|
+
claims:
|
|
145
|
+
- claim: shop-export # a PersistentVolumeClaim in the side's namespace
|
|
146
|
+
mount: /export # where the job's pod mounts it
|
|
147
|
+
promote:
|
|
148
|
+
to:
|
|
149
|
+
- filesystem:
|
|
150
|
+
path: /export/shop
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
- The runtime itself ignores `claims`. Engine pods mount only `claim`.
|
|
154
|
+
- A job's pod mounts only the claims its own paths are on, beside the work
|
|
155
|
+
claim, and `ci init` lists in its `instructions` only the claims the
|
|
156
|
+
side's jobs mount. So one spec can name a claim only one side has: here,
|
|
157
|
+
only `promote` and production's `prune` mount `shop-export`, and the
|
|
158
|
+
non-production side never needs it.
|
|
159
|
+
- A path on one of these claims need not be under the work claim's `mount`.
|
|
160
|
+
Jobs that start engines (`build`, `provision`, `release`) can't name one, so
|
|
161
|
+
the store, staging and the work directory stay on the work claim.
|
|
162
|
+
- The mounts can't overlap each other, the work claim's mount, or a path the
|
|
163
|
+
job's pod already uses: `/etc/datadouble-boundary`, the Jenkins agent's
|
|
164
|
+
`/home/jenkins`, the Argo CD chart's `/workspace`, and a mounted spec
|
|
165
|
+
directory. `claims` can't list the work claim.
|
|
166
|
+
|
|
167
|
+
## Reaching the cluster
|
|
168
|
+
|
|
169
|
+
Without settings, `kubectl` uses the pod's service account when Datadouble
|
|
170
|
+
runs in the cluster, or the ambient configuration (`KUBECONFIG`,
|
|
171
|
+
`~/.kube/config`) otherwise. A job in the cluster it drives, such as the Argo
|
|
172
|
+
CD jobs, needs nothing more.
|
|
173
|
+
|
|
174
|
+
To drive a cluster from outside it, give each adapter that talks to it a
|
|
175
|
+
`kubeconfig`, a secret reference to a kubeconfig's content, and optionally
|
|
176
|
+
the `context` to use:
|
|
177
|
+
|
|
178
|
+
```yaml
|
|
179
|
+
runtime:
|
|
180
|
+
kubernetes:
|
|
181
|
+
claim: datadouble-work
|
|
182
|
+
mount: /work
|
|
183
|
+
kubeconfig:
|
|
184
|
+
env: BUILD_KUBECONFIG
|
|
185
|
+
context: build
|
|
186
|
+
replicate:
|
|
187
|
+
using:
|
|
188
|
+
k8s-pv:
|
|
189
|
+
path: /srv/clones
|
|
190
|
+
local:
|
|
191
|
+
node: worker-1
|
|
192
|
+
kubeconfig:
|
|
193
|
+
env: DEV_KUBECONFIG
|
|
194
|
+
announce:
|
|
195
|
+
- k8s-secret:
|
|
196
|
+
namespace: dev
|
|
197
|
+
kubeconfig:
|
|
198
|
+
env: DEV_KUBECONFIG
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
- **A secret reference to the content, not the runner's kubeconfig file.**
|
|
202
|
+
`{env: NAME}` holds the kubeconfig itself, not a path to one: in CI jobs
|
|
203
|
+
Datadouble runs in its image, which sees only the paths in the spec,
|
|
204
|
+
and as the engine's user (decision 86), who cannot read the runner user's
|
|
205
|
+
`~/.kube/config`. `{file: /path}` is for a secret file mounted for this
|
|
206
|
+
purpose, such as a Kubernetes Secret volume: `ci init` mounts that path
|
|
207
|
+
into the job, so it must exist on the runner and be readable by the
|
|
208
|
+
engine's user (`999:999` for PostgreSQL). On Argo CD it must also be under
|
|
209
|
+
the claim's directory, so prefer `{env: NAME}` there.
|
|
210
|
+
- **Credentials the image can use.** The Datadouble image holds `kubectl`
|
|
211
|
+
and nothing else, so a kubeconfig whose user runs an exec credential
|
|
212
|
+
plugin (`aws eks get-token`, `gke-gcloud-auth-plugin`, `kubelogin`) fails.
|
|
213
|
+
For EKS, GKE or AKS, use a kubeconfig with a service account token or a
|
|
214
|
+
client certificate, embedded in it (`token`, `client-certificate-data`),
|
|
215
|
+
not in files it names (`tokenFile`, `client-certificate`), since those
|
|
216
|
+
paths are not mounted.
|
|
217
|
+
- **`ci init` lists the variable** among the secrets of each job whose part
|
|
218
|
+
of the spec references it, and only those: the runtime's for `build`,
|
|
219
|
+
`provision` and `release`; `k8s-pv`'s for `provision`, `release` and the
|
|
220
|
+
non-production `prune`; `k8s-secret`'s for `provision` and `release`.
|
|
221
|
+
Define it in each system's own secret store, as for any other secret
|
|
222
|
+
(repository secrets, CI/CD variables, Jenkins credentials, a Kubernetes
|
|
223
|
+
Secret, or a Vault-backed secret the CI system injects).
|
|
224
|
+
- **Defining a multi-line secret.** GitHub Actions and Kubernetes Secrets
|
|
225
|
+
take a kubeconfig as it is. In GitLab, make it a CI/CD variable of type
|
|
226
|
+
"Variable", not "File" (a File variable holds a path, which the job's
|
|
227
|
+
container cannot see), protected, with masking off: GitLab masks only
|
|
228
|
+
single-line values. In Jenkins, a Secret text credential holds one line in
|
|
229
|
+
the web form, so create a multi-line one through the API or Configuration
|
|
230
|
+
as Code.
|
|
231
|
+
- **Datadouble writes the kubeconfig to a private temporary file** for each
|
|
232
|
+
`kubectl` call: a file only its user can read (mode 0600), in a directory
|
|
233
|
+
of its own (mode 0700), passed with `--kubeconfig` (and `--context`), both
|
|
234
|
+
removed when the call ends, even after a failure or when the job is
|
|
235
|
+
cancelled (SIGTERM); a `kubernetes` port-forward keeps its file until the
|
|
236
|
+
forward stops. The directory is made in the system's temporary directory
|
|
237
|
+
(`TMPDIR`), or in the home directory when that is under the `kubernetes`
|
|
238
|
+
runtime's `mount`, which pods see; if both are, the call fails, asking for
|
|
239
|
+
`TMPDIR` elsewhere.
|
|
240
|
+
- **What is hidden.** Every string value in the kubeconfig at least 16
|
|
241
|
+
characters long (tokens, keys, certificates, server URLs) is replaced with
|
|
242
|
+
`[redacted]` in everything `kubectl` prints that Datadouble passes on, and
|
|
243
|
+
only those values are handed to the CI system's log masking, so lines such
|
|
244
|
+
as `kind: Config` stay readable. A kubeconfig that cannot be resolved
|
|
245
|
+
fails with `unresolved_reference` before any work, including before a
|
|
246
|
+
`kubernetes` runtime starts a pod.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Copyright (c) 2026- Tight Line LLC
|
|
2
|
+
# SPDX-License-Identifier: MIT
|
|
3
|
+
|
|
4
|
+
[project]
|
|
5
|
+
name = "datadouble-kubernetes"
|
|
6
|
+
# All packages share one version until 1.0 (decision 38); scripts/make_tag.py
|
|
7
|
+
# sets it at release time.
|
|
8
|
+
version = "0.0.3"
|
|
9
|
+
description = "Kubernetes replicate and announce adapters for Datadouble"
|
|
10
|
+
readme = "README.md"
|
|
11
|
+
license = "MIT"
|
|
12
|
+
license-files = ["LICENSE"]
|
|
13
|
+
authors = [{ name = "Tight Line LLC" }]
|
|
14
|
+
requires-python = ">=3.13"
|
|
15
|
+
dependencies = ["datadouble", "pyyaml>=6.0.3"]
|
|
16
|
+
classifiers = [
|
|
17
|
+
"Development Status :: 2 - Pre-Alpha",
|
|
18
|
+
"Programming Language :: Python :: 3 :: Only",
|
|
19
|
+
"Programming Language :: Python :: 3.13",
|
|
20
|
+
"Programming Language :: Python :: 3.14",
|
|
21
|
+
"Programming Language :: Python :: 3.15",
|
|
22
|
+
"Topic :: System :: Clustering",
|
|
23
|
+
"Typing :: Typed",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
[project.urls]
|
|
27
|
+
Homepage = "https://datadouble.tightlinesoftware.com/"
|
|
28
|
+
Source = "https://github.com/datadouble/datadouble"
|
|
29
|
+
|
|
30
|
+
[project.entry-points."datadouble.replicators"]
|
|
31
|
+
k8s-pv = "datadouble_kubernetes:pv_replicator"
|
|
32
|
+
|
|
33
|
+
[project.entry-points."datadouble.announcers"]
|
|
34
|
+
k8s-secret = "datadouble_kubernetes:secret_announcer"
|
|
35
|
+
|
|
36
|
+
[project.entry-points."datadouble.runtimes"]
|
|
37
|
+
kubernetes = "datadouble_kubernetes.runtime:kubernetes_runtime"
|
|
38
|
+
|
|
39
|
+
[build-system]
|
|
40
|
+
requires = ["hatchling>=1.33.0"]
|
|
41
|
+
build-backend = "hatchling.build"
|
|
42
|
+
|
|
43
|
+
[tool.hatch.build.targets.wheel]
|
|
44
|
+
packages = ["src/datadouble_kubernetes"]
|