@kapeta/local-cluster-service 0.32.1 → 0.33.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/CHANGELOG.md +14 -0
- package/dist/cjs/src/containerManager.d.ts +2 -0
- package/dist/cjs/src/containerManager.js +21 -0
- package/dist/cjs/src/operatorManager.js +1 -2
- package/dist/esm/src/containerManager.d.ts +2 -0
- package/dist/esm/src/containerManager.js +21 -0
- package/dist/esm/src/operatorManager.js +1 -2
- package/package.json +1 -1
- package/src/containerManager.ts +30 -0
- package/src/operatorManager.ts +1 -3
package/CHANGELOG.md
CHANGED
@@ -1,3 +1,17 @@
|
|
1
|
+
# [0.33.0](https://github.com/kapetacom/local-cluster-service/compare/v0.32.2...v0.33.0) (2023-12-30)
|
2
|
+
|
3
|
+
|
4
|
+
### Features
|
5
|
+
|
6
|
+
* Bump codegen to use improved merge capabilities ([2be1b8e](https://github.com/kapetacom/local-cluster-service/commit/2be1b8e94c36d83eff28023c4d8afe7c2e71b575))
|
7
|
+
|
8
|
+
## [0.32.2](https://github.com/kapetacom/local-cluster-service/compare/v0.32.1...v0.32.2) (2023-12-25)
|
9
|
+
|
10
|
+
|
11
|
+
### Bug Fixes
|
12
|
+
|
13
|
+
* Use volumes instead of host mounts for faster speeds ([#108](https://github.com/kapetacom/local-cluster-service/issues/108)) ([eac48ea](https://github.com/kapetacom/local-cluster-service/commit/eac48ea767dfc8773a7d0990106fe1f3f29bfec4))
|
14
|
+
|
1
15
|
## [0.32.1](https://github.com/kapetacom/local-cluster-service/compare/v0.32.0...v0.32.1) (2023-12-23)
|
2
16
|
|
3
17
|
|
@@ -22,6 +22,7 @@ export interface DockerMounts {
|
|
22
22
|
Type: string;
|
23
23
|
ReadOnly: boolean;
|
24
24
|
Consistency: string;
|
25
|
+
Labels?: StringMap;
|
25
26
|
}
|
26
27
|
export type DockerContainerStatus = 'created' | 'running' | 'paused' | 'restarting' | 'removing' | 'exited' | 'dead';
|
27
28
|
export type DockerContainerHealth = 'starting' | 'healthy' | 'unhealthy' | 'none';
|
@@ -48,6 +49,7 @@ declare class ContainerManager {
|
|
48
49
|
isAlive(): boolean;
|
49
50
|
getMountPoint(systemId: string, ref: string, mountName: string): string;
|
50
51
|
createMounts(systemId: string, kind: string, mountOpts: StringMap | null | undefined): Promise<StringMap>;
|
52
|
+
createVolumes(systemId: string, kind: string, mountOpts: StringMap | null | undefined): Promise<DockerMounts[]>;
|
51
53
|
ping(): Promise<void>;
|
52
54
|
docker(): Docker;
|
53
55
|
getContainerByName(containerName: string): Promise<ContainerInfo | undefined>;
|
@@ -165,6 +165,27 @@ class ContainerManager {
|
|
165
165
|
}
|
166
166
|
return mounts;
|
167
167
|
}
|
168
|
+
async createVolumes(systemId, kind, mountOpts) {
|
169
|
+
const Mounts = [];
|
170
|
+
if (mountOpts) {
|
171
|
+
const mountOptList = Object.entries(mountOpts);
|
172
|
+
for (const [mountName, containerPath] of mountOptList) {
|
173
|
+
const volumeName = `${systemId}_${kind}_${mountName}`.replace(/[^a-z0-9]/gi, '_');
|
174
|
+
Mounts.push({
|
175
|
+
Target: containerPath,
|
176
|
+
Source: volumeName,
|
177
|
+
Type: 'volume',
|
178
|
+
ReadOnly: false,
|
179
|
+
Consistency: 'consistent',
|
180
|
+
Labels: {
|
181
|
+
[exports.COMPOSE_LABEL_PROJECT]: systemId.replace(/[^a-z0-9]/gi, '_'),
|
182
|
+
[exports.COMPOSE_LABEL_SERVICE]: kind.replace(/[^a-z0-9]/gi, '_'),
|
183
|
+
},
|
184
|
+
});
|
185
|
+
}
|
186
|
+
}
|
187
|
+
return Mounts;
|
188
|
+
}
|
168
189
|
async ping() {
|
169
190
|
try {
|
170
191
|
const pingResult = await this.docker().ping();
|
@@ -146,7 +146,6 @@ class OperatorManager {
|
|
146
146
|
hostPort,
|
147
147
|
};
|
148
148
|
}
|
149
|
-
const mounts = await containerManager_1.containerManager.createMounts(systemId, resourceType, operatorData.mounts);
|
150
149
|
const nameParts = [systemId, resourceType.toLowerCase(), version];
|
151
150
|
const containerName = `kapeta-resource-${(0, md5_1.default)(nameParts.join('_'))}`;
|
152
151
|
const PortBindings = {};
|
@@ -170,7 +169,7 @@ class OperatorManager {
|
|
170
169
|
];
|
171
170
|
Labels[containerManager_1.CONTAINER_LABEL_PORT_PREFIX + portInfo.hostPort] = portInfo.type;
|
172
171
|
});
|
173
|
-
const Mounts = containerManager_1.containerManager.
|
172
|
+
const Mounts = await containerManager_1.containerManager.createVolumes(systemId, resourceType, operatorData.mounts);
|
174
173
|
lodash_1.default.forEach(operatorData.env, (value, name) => {
|
175
174
|
Env.push(name + '=' + value);
|
176
175
|
});
|
@@ -22,6 +22,7 @@ export interface DockerMounts {
|
|
22
22
|
Type: string;
|
23
23
|
ReadOnly: boolean;
|
24
24
|
Consistency: string;
|
25
|
+
Labels?: StringMap;
|
25
26
|
}
|
26
27
|
export type DockerContainerStatus = 'created' | 'running' | 'paused' | 'restarting' | 'removing' | 'exited' | 'dead';
|
27
28
|
export type DockerContainerHealth = 'starting' | 'healthy' | 'unhealthy' | 'none';
|
@@ -48,6 +49,7 @@ declare class ContainerManager {
|
|
48
49
|
isAlive(): boolean;
|
49
50
|
getMountPoint(systemId: string, ref: string, mountName: string): string;
|
50
51
|
createMounts(systemId: string, kind: string, mountOpts: StringMap | null | undefined): Promise<StringMap>;
|
52
|
+
createVolumes(systemId: string, kind: string, mountOpts: StringMap | null | undefined): Promise<DockerMounts[]>;
|
51
53
|
ping(): Promise<void>;
|
52
54
|
docker(): Docker;
|
53
55
|
getContainerByName(containerName: string): Promise<ContainerInfo | undefined>;
|
@@ -165,6 +165,27 @@ class ContainerManager {
|
|
165
165
|
}
|
166
166
|
return mounts;
|
167
167
|
}
|
168
|
+
async createVolumes(systemId, kind, mountOpts) {
|
169
|
+
const Mounts = [];
|
170
|
+
if (mountOpts) {
|
171
|
+
const mountOptList = Object.entries(mountOpts);
|
172
|
+
for (const [mountName, containerPath] of mountOptList) {
|
173
|
+
const volumeName = `${systemId}_${kind}_${mountName}`.replace(/[^a-z0-9]/gi, '_');
|
174
|
+
Mounts.push({
|
175
|
+
Target: containerPath,
|
176
|
+
Source: volumeName,
|
177
|
+
Type: 'volume',
|
178
|
+
ReadOnly: false,
|
179
|
+
Consistency: 'consistent',
|
180
|
+
Labels: {
|
181
|
+
[exports.COMPOSE_LABEL_PROJECT]: systemId.replace(/[^a-z0-9]/gi, '_'),
|
182
|
+
[exports.COMPOSE_LABEL_SERVICE]: kind.replace(/[^a-z0-9]/gi, '_'),
|
183
|
+
},
|
184
|
+
});
|
185
|
+
}
|
186
|
+
}
|
187
|
+
return Mounts;
|
188
|
+
}
|
168
189
|
async ping() {
|
169
190
|
try {
|
170
191
|
const pingResult = await this.docker().ping();
|
@@ -146,7 +146,6 @@ class OperatorManager {
|
|
146
146
|
hostPort,
|
147
147
|
};
|
148
148
|
}
|
149
|
-
const mounts = await containerManager_1.containerManager.createMounts(systemId, resourceType, operatorData.mounts);
|
150
149
|
const nameParts = [systemId, resourceType.toLowerCase(), version];
|
151
150
|
const containerName = `kapeta-resource-${(0, md5_1.default)(nameParts.join('_'))}`;
|
152
151
|
const PortBindings = {};
|
@@ -170,7 +169,7 @@ class OperatorManager {
|
|
170
169
|
];
|
171
170
|
Labels[containerManager_1.CONTAINER_LABEL_PORT_PREFIX + portInfo.hostPort] = portInfo.type;
|
172
171
|
});
|
173
|
-
const Mounts = containerManager_1.containerManager.
|
172
|
+
const Mounts = await containerManager_1.containerManager.createVolumes(systemId, resourceType, operatorData.mounts);
|
174
173
|
lodash_1.default.forEach(operatorData.env, (value, name) => {
|
175
174
|
Env.push(name + '=' + value);
|
176
175
|
});
|
package/package.json
CHANGED
package/src/containerManager.ts
CHANGED
@@ -37,6 +37,7 @@ export interface DockerMounts {
|
|
37
37
|
Type: string;
|
38
38
|
ReadOnly: boolean;
|
39
39
|
Consistency: string;
|
40
|
+
Labels?: StringMap;
|
40
41
|
}
|
41
42
|
|
42
43
|
interface JSONProgress {
|
@@ -249,6 +250,35 @@ class ContainerManager {
|
|
249
250
|
return mounts;
|
250
251
|
}
|
251
252
|
|
253
|
+
async createVolumes(
|
254
|
+
systemId: string,
|
255
|
+
kind: string,
|
256
|
+
mountOpts: StringMap | null | undefined
|
257
|
+
): Promise<DockerMounts[]> {
|
258
|
+
const Mounts: DockerMounts[] = [];
|
259
|
+
|
260
|
+
if (mountOpts) {
|
261
|
+
const mountOptList = Object.entries(mountOpts);
|
262
|
+
for (const [mountName, containerPath] of mountOptList) {
|
263
|
+
const volumeName = `${systemId}_${kind}_${mountName}`.replace(/[^a-z0-9]/gi, '_');
|
264
|
+
|
265
|
+
Mounts.push({
|
266
|
+
Target: containerPath,
|
267
|
+
Source: volumeName,
|
268
|
+
Type: 'volume',
|
269
|
+
ReadOnly: false,
|
270
|
+
Consistency: 'consistent',
|
271
|
+
Labels: {
|
272
|
+
[COMPOSE_LABEL_PROJECT]: systemId.replace(/[^a-z0-9]/gi, '_'),
|
273
|
+
[COMPOSE_LABEL_SERVICE]: kind.replace(/[^a-z0-9]/gi, '_'),
|
274
|
+
},
|
275
|
+
});
|
276
|
+
}
|
277
|
+
}
|
278
|
+
|
279
|
+
return Mounts;
|
280
|
+
}
|
281
|
+
|
252
282
|
async ping() {
|
253
283
|
try {
|
254
284
|
const pingResult = await this.docker().ping();
|
package/src/operatorManager.ts
CHANGED
@@ -201,8 +201,6 @@ class OperatorManager {
|
|
201
201
|
};
|
202
202
|
}
|
203
203
|
|
204
|
-
const mounts = await containerManager.createMounts(systemId, resourceType, operatorData.mounts);
|
205
|
-
|
206
204
|
const nameParts = [systemId, resourceType.toLowerCase(), version];
|
207
205
|
|
208
206
|
const containerName = `kapeta-resource-${md5(nameParts.join('_'))}`;
|
@@ -236,7 +234,7 @@ class OperatorManager {
|
|
236
234
|
Labels[CONTAINER_LABEL_PORT_PREFIX + portInfo.hostPort] = portInfo.type;
|
237
235
|
});
|
238
236
|
|
239
|
-
const Mounts = containerManager.
|
237
|
+
const Mounts = await containerManager.createVolumes(systemId, resourceType, operatorData.mounts);
|
240
238
|
|
241
239
|
_.forEach(operatorData.env, (value, name) => {
|
242
240
|
Env.push(name + '=' + value);
|