@ankhorage/kubernetes 0.1.0 → 0.2.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/README.md +6 -6
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesController.d.ts +13 -0
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesController.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesController.js +130 -0
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesController.js.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesExposure.d.ts +12 -0
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesExposure.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesExposure.js +89 -0
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesExposure.js.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesPrerequisites.d.ts +18 -0
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesPrerequisites.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesPrerequisites.js +98 -0
- package/dist/features/workload-reconciliation/application/use-cases/createKubernetesPrerequisites.js.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.d.ts +5 -0
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.js +33 -0
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.js.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.d.ts +5 -0
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.js +35 -0
- package/dist/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.js.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/materializeKubernetesSecretsAsync.d.ts +6 -0
- package/dist/features/workload-reconciliation/application/use-cases/materializeKubernetesSecretsAsync.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/materializeKubernetesSecretsAsync.js +32 -0
- package/dist/features/workload-reconciliation/application/use-cases/materializeKubernetesSecretsAsync.js.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/planKubernetesResourcesAsync.d.ts +5 -0
- package/dist/features/workload-reconciliation/application/use-cases/planKubernetesResourcesAsync.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/planKubernetesResourcesAsync.js +9 -0
- package/dist/features/workload-reconciliation/application/use-cases/planKubernetesResourcesAsync.js.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/prepareKubernetesChangesAsync.d.ts +6 -0
- package/dist/features/workload-reconciliation/application/use-cases/prepareKubernetesChangesAsync.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/prepareKubernetesChangesAsync.js +84 -0
- package/dist/features/workload-reconciliation/application/use-cases/prepareKubernetesChangesAsync.js.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesResourcesAsync.d.ts +11 -0
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesResourcesAsync.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesResourcesAsync.js +53 -0
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesResourcesAsync.js.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.d.ts +12 -0
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.js +45 -0
- package/dist/features/workload-reconciliation/application/use-cases/projectKubernetesWorkload.js.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/reconcileKubernetesResourcesAsync.d.ts +5 -0
- package/dist/features/workload-reconciliation/application/use-cases/reconcileKubernetesResourcesAsync.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/reconcileKubernetesResourcesAsync.js +51 -0
- package/dist/features/workload-reconciliation/application/use-cases/reconcileKubernetesResourcesAsync.js.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/removeKubernetesResourcesAsync.d.ts +5 -0
- package/dist/features/workload-reconciliation/application/use-cases/removeKubernetesResourcesAsync.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/removeKubernetesResourcesAsync.js +75 -0
- package/dist/features/workload-reconciliation/application/use-cases/removeKubernetesResourcesAsync.js.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/resolveKubernetesWorkloadValues.d.ts +5 -0
- package/dist/features/workload-reconciliation/application/use-cases/resolveKubernetesWorkloadValues.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/resolveKubernetesWorkloadValues.js +45 -0
- package/dist/features/workload-reconciliation/application/use-cases/resolveKubernetesWorkloadValues.js.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/validateKubernetesWorkloads.d.ts +4 -0
- package/dist/features/workload-reconciliation/application/use-cases/validateKubernetesWorkloads.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/validateKubernetesWorkloads.js +26 -0
- package/dist/features/workload-reconciliation/application/use-cases/validateKubernetesWorkloads.js.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/waitForKubernetesReadinessAsync.d.ts +5 -0
- package/dist/features/workload-reconciliation/application/use-cases/waitForKubernetesReadinessAsync.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/application/use-cases/waitForKubernetesReadinessAsync.js +56 -0
- package/dist/features/workload-reconciliation/application/use-cases/waitForKubernetesReadinessAsync.js.map +1 -0
- package/dist/features/workload-reconciliation/composition/createKubernetesDriver.d.ts +4 -4
- package/dist/features/workload-reconciliation/composition/createKubernetesDriver.d.ts.map +1 -1
- package/dist/features/workload-reconciliation/composition/createKubernetesDriver.js +20 -4
- package/dist/features/workload-reconciliation/composition/createKubernetesDriver.js.map +1 -1
- package/dist/features/workload-reconciliation/constants.d.ts +14 -0
- package/dist/features/workload-reconciliation/constants.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/constants.js +14 -0
- package/dist/features/workload-reconciliation/constants.js.map +1 -0
- package/dist/features/workload-reconciliation/utils/areKubernetesResourcesEquivalent.d.ts +4 -0
- package/dist/features/workload-reconciliation/utils/areKubernetesResourcesEquivalent.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/utils/areKubernetesResourcesEquivalent.js +41 -0
- package/dist/features/workload-reconciliation/utils/areKubernetesResourcesEquivalent.js.map +1 -0
- package/dist/features/workload-reconciliation/utils/createKubernetesDesiredResource.d.ts +14 -0
- package/dist/features/workload-reconciliation/utils/createKubernetesDesiredResource.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/utils/createKubernetesDesiredResource.js +45 -0
- package/dist/features/workload-reconciliation/utils/createKubernetesDesiredResource.js.map +1 -0
- package/dist/features/workload-reconciliation/utils/createKubernetesIdentity.d.ts +5 -0
- package/dist/features/workload-reconciliation/utils/createKubernetesIdentity.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/utils/createKubernetesIdentity.js +10 -0
- package/dist/features/workload-reconciliation/utils/createKubernetesIdentity.js.map +1 -0
- package/dist/features/workload-reconciliation/utils/getKubernetesOwnershipQuery.d.ts +5 -0
- package/dist/features/workload-reconciliation/utils/getKubernetesOwnershipQuery.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/utils/getKubernetesOwnershipQuery.js +16 -0
- package/dist/features/workload-reconciliation/utils/getKubernetesOwnershipQuery.js.map +1 -0
- package/dist/features/workload-reconciliation/utils/getKubernetesResourceKey.d.ts +4 -0
- package/dist/features/workload-reconciliation/utils/getKubernetesResourceKey.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/utils/getKubernetesResourceKey.js +5 -0
- package/dist/features/workload-reconciliation/utils/getKubernetesResourceKey.js.map +1 -0
- package/dist/features/workload-reconciliation/utils/getKubernetesResourceReference.d.ts +4 -0
- package/dist/features/workload-reconciliation/utils/getKubernetesResourceReference.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/utils/getKubernetesResourceReference.js +12 -0
- package/dist/features/workload-reconciliation/utils/getKubernetesResourceReference.js.map +1 -0
- package/dist/features/workload-reconciliation/utils/readKubernetesOwnedResource.d.ts +6 -0
- package/dist/features/workload-reconciliation/utils/readKubernetesOwnedResource.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/utils/readKubernetesOwnedResource.js +49 -0
- package/dist/features/workload-reconciliation/utils/readKubernetesOwnedResource.js.map +1 -0
- package/dist/features/workload-reconciliation/utils/sortKubernetesResourcesForRemoval.d.ts +9 -0
- package/dist/features/workload-reconciliation/utils/sortKubernetesResourcesForRemoval.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/utils/sortKubernetesResourcesForRemoval.js +21 -0
- package/dist/features/workload-reconciliation/utils/sortKubernetesResourcesForRemoval.js.map +1 -0
- package/dist/features/workload-reconciliation/utils/toKubernetesName.d.ts +3 -0
- package/dist/features/workload-reconciliation/utils/toKubernetesName.d.ts.map +1 -0
- package/dist/features/workload-reconciliation/utils/toKubernetesName.js +21 -0
- package/dist/features/workload-reconciliation/utils/toKubernetesName.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types/kubernetesDriver.d.ts +21 -1
- package/dist/types/kubernetesDriver.d.ts.map +1 -1
- package/dist/types/kubernetesDriver.js.map +1 -1
- package/dist/types/kubernetesResources.d.ts +87 -0
- package/dist/types/kubernetesResources.d.ts.map +1 -0
- package/dist/types/kubernetesResources.js +2 -0
- package/dist/types/kubernetesResources.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
# @ankhorage/kubernetes
|
|
5
5
|
|
|
6
|
-
         
|
|
7
7
|
|
|
8
8
|
Shared Kubernetes workload driver for provider-neutral Ankhorage infrastructure.
|
|
9
9
|
|
|
@@ -24,17 +24,17 @@ Shared Kubernetes workload driver for provider-neutral Ankhorage infrastructure.
|
|
|
24
24
|
<summary>createKubernetesDriver</summary>
|
|
25
25
|
|
|
26
26
|
```ts
|
|
27
|
-
createKubernetesDriver() => KubernetesDriver
|
|
27
|
+
createKubernetesDriver(options: KubernetesDriverOptions) => KubernetesDriver
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
Create the shared Kubernetes workload driver entrypoint.
|
|
31
31
|
|
|
32
32
|
Kubernetes is an implementation dependency for runtime adapters, not a selectable Infra
|
|
33
|
-
provider.
|
|
34
|
-
|
|
33
|
+
provider. The supplied API port is already authenticated cluster access; the driver adds only
|
|
34
|
+
standard Kubernetes workload projection and lifecycle semantics.
|
|
35
35
|
|
|
36
36
|
Module: `src/features/workload-reconciliation/composition/createKubernetesDriver.ts`
|
|
37
|
-
Source: `src/features/workload-reconciliation/composition/createKubernetesDriver.ts:
|
|
38
|
-
Related symbols: `KubernetesDriver`
|
|
37
|
+
Source: `src/features/workload-reconciliation/composition/createKubernetesDriver.ts:19:1`
|
|
38
|
+
Related symbols: `KubernetesDriver`, `KubernetesDriverOptions`
|
|
39
39
|
|
|
40
40
|
</details>
|
package/dist/features/workload-reconciliation/application/use-cases/createKubernetesController.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { InfraResourceIdentity, InfraWorkloadSpec } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
3
|
+
import type { KubernetesDesiredResource, KubernetesResolvedWorkloadValues } from '../../../../types/kubernetesResources';
|
|
4
|
+
/*** Create the standard Kubernetes workload controller and pod template. */
|
|
5
|
+
export declare function createKubernetesController(request: KubernetesDriverRequest, input: CreateKubernetesControllerInput): KubernetesDesiredResource;
|
|
6
|
+
export interface CreateKubernetesControllerInput {
|
|
7
|
+
readonly namespace: string;
|
|
8
|
+
readonly workloadName: string;
|
|
9
|
+
readonly workload: InfraWorkloadSpec;
|
|
10
|
+
readonly values: KubernetesResolvedWorkloadValues;
|
|
11
|
+
readonly dependsOn: readonly InfraResourceIdentity[];
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=createKubernetesController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createKubernetesController.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/createKubernetesController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EAErB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,KAAK,EACV,yBAAyB,EACzB,gCAAgC,EAEjC,MAAM,uCAAuC,CAAC;AAI/C,4EAA4E;AAC5E,wBAAgB,0BAA0B,CACxC,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,+BAA+B,GACrC,yBAAyB,CA2B3B;AAED,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,gCAAgC,CAAC;IAClD,QAAQ,CAAC,SAAS,EAAE,SAAS,qBAAqB,EAAE,CAAC;CACtD"}
|
package/dist/features/workload-reconciliation/application/use-cases/createKubernetesController.js
ADDED
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { createKubernetesDesiredResource } from '../../utils/createKubernetesDesiredResource';
|
|
2
|
+
import { toKubernetesName } from '../../utils/toKubernetesName';
|
|
3
|
+
/*** Create the standard Kubernetes workload controller and pod template. */
|
|
4
|
+
export function createKubernetesController(request, input) {
|
|
5
|
+
const labels = { 'app.kubernetes.io/name': input.workloadName };
|
|
6
|
+
return createKubernetesDesiredResource(request, {
|
|
7
|
+
resourceId: `workload:${input.workload.id}`,
|
|
8
|
+
dependsOn: input.dependsOn,
|
|
9
|
+
resource: {
|
|
10
|
+
apiVersion: 'apps/v1',
|
|
11
|
+
kind: 'Deployment',
|
|
12
|
+
metadata: {
|
|
13
|
+
name: input.workloadName,
|
|
14
|
+
namespace: input.namespace,
|
|
15
|
+
labels,
|
|
16
|
+
annotations: {},
|
|
17
|
+
},
|
|
18
|
+
spec: {
|
|
19
|
+
replicas: input.workload.replicas ?? 1,
|
|
20
|
+
selector: { matchLabels: labels },
|
|
21
|
+
template: {
|
|
22
|
+
metadata: { labels },
|
|
23
|
+
spec: {
|
|
24
|
+
containers: [createContainer(input.workloadName, input.workload, input.values)],
|
|
25
|
+
volumes: createVolumes(input.workloadName, input.workload, input.values),
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
/*** Create the portable container projection. */
|
|
33
|
+
function createContainer(name, workload, values) {
|
|
34
|
+
const { resources, health } = workload;
|
|
35
|
+
return {
|
|
36
|
+
name,
|
|
37
|
+
image: workload.artifact.image,
|
|
38
|
+
...(workload.command === undefined ? {} : { command: workload.command }),
|
|
39
|
+
...(workload.args === undefined ? {} : { args: workload.args }),
|
|
40
|
+
env: createEnvironment(name, values),
|
|
41
|
+
ports: (workload.ports ?? []).map((port) => ({
|
|
42
|
+
name: toKubernetesName(port.name),
|
|
43
|
+
containerPort: port.port,
|
|
44
|
+
protocol: (port.protocol ?? 'tcp').toUpperCase(),
|
|
45
|
+
})),
|
|
46
|
+
volumeMounts: createVolumeMounts(workload, values),
|
|
47
|
+
...(resources === undefined ? {} : { resources: createResources(resources) }),
|
|
48
|
+
...(health === undefined
|
|
49
|
+
? {}
|
|
50
|
+
: { readinessProbe: createProbe(health), livenessProbe: createProbe(health) }),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/*** Create literal and secret-backed environment entries. */
|
|
54
|
+
function createEnvironment(name, values) {
|
|
55
|
+
return [
|
|
56
|
+
...Object.entries(values.environment).map(([key, value]) => ({ name: key, value })),
|
|
57
|
+
...values.secrets.filter(isEnvironmentSecret).map((secret) => ({
|
|
58
|
+
name: secret.target.name,
|
|
59
|
+
valueFrom: { secretKeyRef: { name: `${name}-secrets`, key: secret.key } },
|
|
60
|
+
})),
|
|
61
|
+
];
|
|
62
|
+
}
|
|
63
|
+
/*** Create Kubernetes request quantities from portable workload resources. */
|
|
64
|
+
function createResources(resources) {
|
|
65
|
+
return {
|
|
66
|
+
requests: {
|
|
67
|
+
...(resources.cpuMillis === undefined ? {} : { cpu: `${resources.cpuMillis}m` }),
|
|
68
|
+
...(resources.memoryMiB === undefined ? {} : { memory: `${resources.memoryMiB}Mi` }),
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
/*** Project portable health intent into Kubernetes probe fields. */
|
|
73
|
+
function createProbe(health) {
|
|
74
|
+
const timing = {
|
|
75
|
+
...(health.intervalSeconds === undefined ? {} : { periodSeconds: health.intervalSeconds }),
|
|
76
|
+
...(health.timeoutSeconds === undefined ? {} : { timeoutSeconds: health.timeoutSeconds }),
|
|
77
|
+
...(health.failureThreshold === undefined ? {} : { failureThreshold: health.failureThreshold }),
|
|
78
|
+
};
|
|
79
|
+
if (health.kind === 'http') {
|
|
80
|
+
return { ...timing, httpGet: { port: health.port, path: health.path } };
|
|
81
|
+
}
|
|
82
|
+
if (health.kind === 'tcp')
|
|
83
|
+
return { ...timing, tcpSocket: { port: health.port } };
|
|
84
|
+
return { ...timing, exec: { command: health.command } };
|
|
85
|
+
}
|
|
86
|
+
/*** Create pod volumes for files and persistence. */
|
|
87
|
+
function createVolumes(name, workload, values) {
|
|
88
|
+
return [
|
|
89
|
+
...(Object.keys(values.files).length === 0
|
|
90
|
+
? []
|
|
91
|
+
: [{ name: 'config-files', configMap: { name: `${name}-config` } }]),
|
|
92
|
+
...(values.secrets.some((secret) => secret.target.kind === 'file')
|
|
93
|
+
? [{ name: 'secret-files', secret: { secretName: `${name}-secrets` } }]
|
|
94
|
+
: []),
|
|
95
|
+
...(workload.persistence ?? []).map((volume) => ({
|
|
96
|
+
name: `volume-${toKubernetesName(volume.id)}`,
|
|
97
|
+
persistentVolumeClaim: { claimName: `${name}-${toKubernetesName(volume.id)}` },
|
|
98
|
+
})),
|
|
99
|
+
];
|
|
100
|
+
}
|
|
101
|
+
/*** Create exact file and persistence mount points. */
|
|
102
|
+
function createVolumeMounts(workload, values) {
|
|
103
|
+
return [
|
|
104
|
+
...Object.keys(values.files).map((path, index) => ({
|
|
105
|
+
name: 'config-files',
|
|
106
|
+
mountPath: path,
|
|
107
|
+
subPath: `file-${index}`,
|
|
108
|
+
readOnly: true,
|
|
109
|
+
})),
|
|
110
|
+
...values.secrets.filter(isFileSecret).map((secret) => ({
|
|
111
|
+
name: 'secret-files',
|
|
112
|
+
mountPath: secret.target.path,
|
|
113
|
+
subPath: secret.key,
|
|
114
|
+
readOnly: true,
|
|
115
|
+
})),
|
|
116
|
+
...(workload.persistence ?? []).map((volume) => ({
|
|
117
|
+
name: `volume-${toKubernetesName(volume.id)}`,
|
|
118
|
+
mountPath: volume.mountPath,
|
|
119
|
+
})),
|
|
120
|
+
];
|
|
121
|
+
}
|
|
122
|
+
/*** Narrow a secret target to an environment entry. */
|
|
123
|
+
function isEnvironmentSecret(secret) {
|
|
124
|
+
return secret.target.kind === 'environment';
|
|
125
|
+
}
|
|
126
|
+
/*** Narrow a secret target to a mounted file. */
|
|
127
|
+
function isFileSecret(secret) {
|
|
128
|
+
return secret.target.kind === 'file';
|
|
129
|
+
}
|
|
130
|
+
//# sourceMappingURL=createKubernetesController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createKubernetesController.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/createKubernetesController.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,+BAA+B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,CAAC;AAED,iDAAiD;AACjD,SAAS,YAAY,CAAC,MAA8B;IAGlD,OAAO,MAAM,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,CAAC;AACvC,CAAC","sourcesContent":["import type {\n InfraResourceIdentity,\n InfraWorkloadHealthSpec,\n InfraWorkloadSpec,\n} from '@ankhorage/contracts/infra';\n\nimport type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver';\nimport type {\n KubernetesDesiredResource,\n KubernetesResolvedWorkloadValues,\n KubernetesSecretTarget,\n} from '../../../../types/kubernetesResources';\nimport { createKubernetesDesiredResource } from '../../utils/createKubernetesDesiredResource';\nimport { toKubernetesName } from '../../utils/toKubernetesName';\n\n/*** Create the standard Kubernetes workload controller and pod template. */\nexport function createKubernetesController(\n request: KubernetesDriverRequest,\n input: CreateKubernetesControllerInput,\n): KubernetesDesiredResource {\n const labels = { 'app.kubernetes.io/name': input.workloadName };\n return createKubernetesDesiredResource(request, {\n resourceId: `workload:${input.workload.id}`,\n dependsOn: input.dependsOn,\n resource: {\n apiVersion: 'apps/v1',\n kind: 'Deployment',\n metadata: {\n name: input.workloadName,\n namespace: input.namespace,\n labels,\n annotations: {},\n },\n spec: {\n replicas: input.workload.replicas ?? 1,\n selector: { matchLabels: labels },\n template: {\n metadata: { labels },\n spec: {\n containers: [createContainer(input.workloadName, input.workload, input.values)],\n volumes: createVolumes(input.workloadName, input.workload, input.values),\n },\n },\n },\n },\n });\n}\n\nexport interface CreateKubernetesControllerInput {\n readonly namespace: string;\n readonly workloadName: string;\n readonly workload: InfraWorkloadSpec;\n readonly values: KubernetesResolvedWorkloadValues;\n readonly dependsOn: readonly InfraResourceIdentity[];\n}\n\n/*** Create the portable container projection. */\nfunction createContainer(\n name: string,\n workload: InfraWorkloadSpec,\n values: KubernetesResolvedWorkloadValues,\n): Readonly<Record<string, unknown>> {\n const { resources, health } = workload;\n return {\n name,\n image: workload.artifact.image,\n ...(workload.command === undefined ? {} : { command: workload.command }),\n ...(workload.args === undefined ? {} : { args: workload.args }),\n env: createEnvironment(name, values),\n ports: (workload.ports ?? []).map((port) => ({\n name: toKubernetesName(port.name),\n containerPort: port.port,\n protocol: (port.protocol ?? 'tcp').toUpperCase(),\n })),\n volumeMounts: createVolumeMounts(workload, values),\n ...(resources === undefined ? {} : { resources: createResources(resources) }),\n ...(health === undefined\n ? {}\n : { readinessProbe: createProbe(health), livenessProbe: createProbe(health) }),\n };\n}\n\n/*** Create literal and secret-backed environment entries. */\nfunction createEnvironment(\n name: string,\n values: KubernetesResolvedWorkloadValues,\n): readonly Readonly<Record<string, unknown>>[] {\n return [\n ...Object.entries(values.environment).map(([key, value]) => ({ name: key, value })),\n ...values.secrets.filter(isEnvironmentSecret).map((secret) => ({\n name: secret.target.name,\n valueFrom: { secretKeyRef: { name: `${name}-secrets`, key: secret.key } },\n })),\n ];\n}\n\n/*** Create Kubernetes request quantities from portable workload resources. */\nfunction createResources(\n resources: NonNullable<InfraWorkloadSpec['resources']>,\n): Readonly<Record<string, unknown>> {\n return {\n requests: {\n ...(resources.cpuMillis === undefined ? {} : { cpu: `${resources.cpuMillis}m` }),\n ...(resources.memoryMiB === undefined ? {} : { memory: `${resources.memoryMiB}Mi` }),\n },\n };\n}\n\n/*** Project portable health intent into Kubernetes probe fields. */\nfunction createProbe(health: InfraWorkloadHealthSpec): Readonly<Record<string, unknown>> {\n const timing = {\n ...(health.intervalSeconds === undefined ? {} : { periodSeconds: health.intervalSeconds }),\n ...(health.timeoutSeconds === undefined ? {} : { timeoutSeconds: health.timeoutSeconds }),\n ...(health.failureThreshold === undefined ? {} : { failureThreshold: health.failureThreshold }),\n };\n if (health.kind === 'http') {\n return { ...timing, httpGet: { port: health.port, path: health.path } };\n }\n if (health.kind === 'tcp') return { ...timing, tcpSocket: { port: health.port } };\n return { ...timing, exec: { command: health.command } };\n}\n\n/*** Create pod volumes for files and persistence. */\nfunction createVolumes(\n name: string,\n workload: InfraWorkloadSpec,\n values: KubernetesResolvedWorkloadValues,\n): readonly Readonly<Record<string, unknown>>[] {\n return [\n ...(Object.keys(values.files).length === 0\n ? []\n : [{ name: 'config-files', configMap: { name: `${name}-config` } }]),\n ...(values.secrets.some((secret) => secret.target.kind === 'file')\n ? [{ name: 'secret-files', secret: { secretName: `${name}-secrets` } }]\n : []),\n ...(workload.persistence ?? []).map((volume) => ({\n name: `volume-${toKubernetesName(volume.id)}`,\n persistentVolumeClaim: { claimName: `${name}-${toKubernetesName(volume.id)}` },\n })),\n ];\n}\n\n/*** Create exact file and persistence mount points. */\nfunction createVolumeMounts(\n workload: InfraWorkloadSpec,\n values: KubernetesResolvedWorkloadValues,\n): readonly Readonly<Record<string, unknown>>[] {\n return [\n ...Object.keys(values.files).map((path, index) => ({\n name: 'config-files',\n mountPath: path,\n subPath: `file-${index}`,\n readOnly: true,\n })),\n ...values.secrets.filter(isFileSecret).map((secret) => ({\n name: 'secret-files',\n mountPath: secret.target.path,\n subPath: secret.key,\n readOnly: true,\n })),\n ...(workload.persistence ?? []).map((volume) => ({\n name: `volume-${toKubernetesName(volume.id)}`,\n mountPath: volume.mountPath,\n })),\n ];\n}\n\n/*** Narrow a secret target to an environment entry. */\nfunction isEnvironmentSecret(secret: KubernetesSecretTarget): secret is KubernetesSecretTarget & {\n readonly target: { readonly kind: 'environment'; readonly name: string };\n} {\n return secret.target.kind === 'environment';\n}\n\n/*** Narrow a secret target to a mounted file. */\nfunction isFileSecret(secret: KubernetesSecretTarget): secret is KubernetesSecretTarget & {\n readonly target: { readonly kind: 'file'; readonly path: string };\n} {\n return secret.target.kind === 'file';\n}\n"]}
|
package/dist/features/workload-reconciliation/application/use-cases/createKubernetesExposure.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { InfraResourceIdentity, InfraWorkloadSpec } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
3
|
+
import type { KubernetesDesiredResource } from '../../../../types/kubernetesResources';
|
|
4
|
+
/*** Create Services and optional Ingress from portable port and exposure intent. */
|
|
5
|
+
export declare function createKubernetesExposure(request: KubernetesDriverRequest, input: CreateKubernetesExposureInput): readonly KubernetesDesiredResource[];
|
|
6
|
+
export interface CreateKubernetesExposureInput {
|
|
7
|
+
readonly namespace: string;
|
|
8
|
+
readonly workloadName: string;
|
|
9
|
+
readonly workload: InfraWorkloadSpec;
|
|
10
|
+
readonly controller: InfraResourceIdentity;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=createKubernetesExposure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createKubernetesExposure.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/createKubernetesExposure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EAErB,iBAAiB,EAClB,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,uCAAuC,CAAC;AAIvF,oFAAoF;AACpF,wBAAgB,wBAAwB,CACtC,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,6BAA6B,GACnC,SAAS,yBAAyB,EAAE,CAKtC;AAED,MAAM,WAAW,6BAA6B;IAC5C,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,UAAU,EAAE,qBAAqB,CAAC;CAC5C"}
|
package/dist/features/workload-reconciliation/application/use-cases/createKubernetesExposure.js
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { createKubernetesDesiredResource } from '../../utils/createKubernetesDesiredResource';
|
|
2
|
+
import { toKubernetesName } from '../../utils/toKubernetesName';
|
|
3
|
+
/*** Create Services and optional Ingress from portable port and exposure intent. */
|
|
4
|
+
export function createKubernetesExposure(request, input) {
|
|
5
|
+
const service = createService(request, input);
|
|
6
|
+
if (service === undefined)
|
|
7
|
+
return [];
|
|
8
|
+
const ingress = createIngress(request, input, service.owner.identity);
|
|
9
|
+
return ingress === undefined ? [service] : [service, ingress];
|
|
10
|
+
}
|
|
11
|
+
/*** Create the stable service boundary for declared workload ports. */
|
|
12
|
+
function createService(request, input) {
|
|
13
|
+
const ports = input.workload.ports ?? [];
|
|
14
|
+
if (ports.length === 0)
|
|
15
|
+
return undefined;
|
|
16
|
+
const hasIngress = input.workload.exposure === 'public' && request.context.desired.networking?.domain;
|
|
17
|
+
return createKubernetesDesiredResource(request, {
|
|
18
|
+
resourceId: `service:${input.workload.id}`,
|
|
19
|
+
dependsOn: [input.controller],
|
|
20
|
+
resource: {
|
|
21
|
+
apiVersion: 'v1',
|
|
22
|
+
kind: 'Service',
|
|
23
|
+
metadata: {
|
|
24
|
+
name: input.workloadName,
|
|
25
|
+
namespace: input.namespace,
|
|
26
|
+
labels: {},
|
|
27
|
+
annotations: {},
|
|
28
|
+
},
|
|
29
|
+
spec: {
|
|
30
|
+
type: input.workload.exposure === 'public' && !hasIngress ? 'LoadBalancer' : 'ClusterIP',
|
|
31
|
+
selector: { 'app.kubernetes.io/name': input.workloadName },
|
|
32
|
+
ports: ports.map(createServicePort),
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
/*** Project one generic port into a Service port. */
|
|
38
|
+
function createServicePort(port) {
|
|
39
|
+
return {
|
|
40
|
+
name: toKubernetesName(port.name),
|
|
41
|
+
port: port.port,
|
|
42
|
+
targetPort: toKubernetesName(port.name),
|
|
43
|
+
protocol: (port.protocol ?? 'tcp').toUpperCase(),
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
/*** Create ingress only when public hostname intent and a TCP port both exist. */
|
|
47
|
+
function createIngress(request, input, service) {
|
|
48
|
+
const domain = request.context.desired.networking?.domain;
|
|
49
|
+
const port = (input.workload.ports ?? []).find((candidate) => (candidate.protocol ?? 'tcp') === 'tcp');
|
|
50
|
+
if (input.workload.exposure !== 'public' || domain === undefined || port === undefined) {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
return createKubernetesDesiredResource(request, {
|
|
54
|
+
resourceId: `ingress:${input.workload.id}`,
|
|
55
|
+
dependsOn: [service],
|
|
56
|
+
resource: {
|
|
57
|
+
apiVersion: 'networking.k8s.io/v1',
|
|
58
|
+
kind: 'Ingress',
|
|
59
|
+
metadata: {
|
|
60
|
+
name: input.workloadName,
|
|
61
|
+
namespace: input.namespace,
|
|
62
|
+
labels: {},
|
|
63
|
+
annotations: {},
|
|
64
|
+
},
|
|
65
|
+
spec: {
|
|
66
|
+
rules: [
|
|
67
|
+
{
|
|
68
|
+
host: domain,
|
|
69
|
+
http: {
|
|
70
|
+
paths: [
|
|
71
|
+
{
|
|
72
|
+
path: '/',
|
|
73
|
+
pathType: 'Prefix',
|
|
74
|
+
backend: {
|
|
75
|
+
service: {
|
|
76
|
+
name: input.workloadName,
|
|
77
|
+
port: { name: toKubernetesName(port.name) },
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
],
|
|
85
|
+
},
|
|
86
|
+
},
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
//# sourceMappingURL=createKubernetesExposure.js.map
|
package/dist/features/workload-reconciliation/application/use-cases/createKubernetesExposure.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createKubernetesExposure.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/createKubernetesExposure.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,oFAAoF;AACpF,MAAM,UAAU,w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K,CAAC,YAAY;gBACxB,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,MAAM,EAAE,EAAE;gBACV,WAAW,EAAE,EAAE;aAChB;YACD,IAAI,EAAE;gBACJ,KAAK,EAAE;oBACL;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE;4BACJ,KAAK,EAAE;gCACL;oCACE,IAAI,EAAE,GAAG;oCACT,QAAQ,EAAE,QAAQ;oCAClB,OAAO,EAAE;wCACP,OAAO,EAAE;4CACP,IAAI,EAAE,KAAK,CAAC,YAAY;4CACxB,IAAI,EAAE,EAAE,IAAI,EAAE,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE;yCAC5C;qCACF;iCACF;6BACF;yBACF;qBACF;iBACF;aACF;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type {\n InfraResourceIdentity,\n InfraWorkloadPort,\n InfraWorkloadSpec,\n} from '@ankhorage/contracts/infra';\n\nimport type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver';\nimport type { KubernetesDesiredResource } from '../../../../types/kubernetesResources';\nimport { createKubernetesDesiredResource } from '../../utils/createKubernetesDesiredResource';\nimport { toKubernetesName } from '../../utils/toKubernetesName';\n\n/*** Create Services and optional Ingress from portable port and exposure intent. */\nexport function createKubernetesExposure(\n request: KubernetesDriverRequest,\n input: CreateKubernetesExposureInput,\n): readonly KubernetesDesiredResource[] {\n const service = createService(request, input);\n if (service === undefined) return [];\n const ingress = createIngress(request, input, service.owner.identity);\n return ingress === undefined ? [service] : [service, ingress];\n}\n\nexport interface CreateKubernetesExposureInput {\n readonly namespace: string;\n readonly workloadName: string;\n readonly workload: InfraWorkloadSpec;\n readonly controller: InfraResourceIdentity;\n}\n\n/*** Create the stable service boundary for declared workload ports. */\nfunction createService(\n request: KubernetesDriverRequest,\n input: CreateKubernetesExposureInput,\n): KubernetesDesiredResource | undefined {\n const ports = input.workload.ports ?? [];\n if (ports.length === 0) return undefined;\n const hasIngress =\n input.workload.exposure === 'public' && request.context.desired.networking?.domain;\n return createKubernetesDesiredResource(request, {\n resourceId: `service:${input.workload.id}`,\n dependsOn: [input.controller],\n resource: {\n apiVersion: 'v1',\n kind: 'Service',\n metadata: {\n name: input.workloadName,\n namespace: input.namespace,\n labels: {},\n annotations: {},\n },\n spec: {\n type: input.workload.exposure === 'public' && !hasIngress ? 'LoadBalancer' : 'ClusterIP',\n selector: { 'app.kubernetes.io/name': input.workloadName },\n ports: ports.map(createServicePort),\n },\n },\n });\n}\n\n/*** Project one generic port into a Service port. */\nfunction createServicePort(port: InfraWorkloadPort): Readonly<Record<string, unknown>> {\n return {\n name: toKubernetesName(port.name),\n port: port.port,\n targetPort: toKubernetesName(port.name),\n protocol: (port.protocol ?? 'tcp').toUpperCase(),\n };\n}\n\n/*** Create ingress only when public hostname intent and a TCP port both exist. */\nfunction createIngress(\n request: KubernetesDriverRequest,\n input: CreateKubernetesExposureInput,\n service: InfraResourceIdentity,\n): KubernetesDesiredResource | undefined {\n const domain = request.context.desired.networking?.domain;\n const port = (input.workload.ports ?? []).find(\n (candidate) => (candidate.protocol ?? 'tcp') === 'tcp',\n );\n if (input.workload.exposure !== 'public' || domain === undefined || port === undefined) {\n return undefined;\n }\n return createKubernetesDesiredResource(request, {\n resourceId: `ingress:${input.workload.id}`,\n dependsOn: [service],\n resource: {\n apiVersion: 'networking.k8s.io/v1',\n kind: 'Ingress',\n metadata: {\n name: input.workloadName,\n namespace: input.namespace,\n labels: {},\n annotations: {},\n },\n spec: {\n rules: [\n {\n host: domain,\n http: {\n paths: [\n {\n path: '/',\n pathType: 'Prefix',\n backend: {\n service: {\n name: input.workloadName,\n port: { name: toKubernetesName(port.name) },\n },\n },\n },\n ],\n },\n },\n ],\n },\n },\n });\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { InfraResourceIdentity, InfraWorkloadSpec } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
3
|
+
import type { KubernetesDesiredResource, KubernetesResolvedWorkloadValues, KubernetesSecretBinding } from '../../../../types/kubernetesResources';
|
|
4
|
+
/*** Create config, secret and persistent-volume prerequisites in dependency order. */
|
|
5
|
+
export declare function createKubernetesPrerequisites(request: KubernetesDriverRequest, input: CreateKubernetesPrerequisitesInput): KubernetesPrerequisites;
|
|
6
|
+
export interface CreateKubernetesPrerequisitesInput {
|
|
7
|
+
readonly namespace: string;
|
|
8
|
+
readonly namespaceOwner: InfraResourceIdentity;
|
|
9
|
+
readonly workloadName: string;
|
|
10
|
+
readonly workload: InfraWorkloadSpec;
|
|
11
|
+
readonly values: KubernetesResolvedWorkloadValues;
|
|
12
|
+
}
|
|
13
|
+
export interface KubernetesPrerequisites {
|
|
14
|
+
readonly resources: readonly KubernetesDesiredResource[];
|
|
15
|
+
readonly owners: readonly InfraResourceIdentity[];
|
|
16
|
+
readonly secretBindings: readonly KubernetesSecretBinding[];
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=createKubernetesPrerequisites.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createKubernetesPrerequisites.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/createKubernetesPrerequisites.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE3F,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,KAAK,EACV,yBAAyB,EACzB,gCAAgC,EAChC,uBAAuB,EACxB,MAAM,uCAAuC,CAAC;AAK/C,sFAAsF;AACtF,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,uBAAuB,EAChC,KAAK,EAAE,kCAAkC,GACxC,uBAAuB,CAmBzB;AAED,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,cAAc,EAAE,qBAAqB,CAAC;IAC/C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,gCAAgC,CAAC;CACnD;AAED,MAAM,WAAW,uBAAuB;IACtC,QAAQ,CAAC,SAAS,EAAE,SAAS,yBAAyB,EAAE,CAAC;IACzD,QAAQ,CAAC,MAAM,EAAE,SAAS,qBAAqB,EAAE,CAAC;IAClD,QAAQ,CAAC,cAAc,EAAE,SAAS,uBAAuB,EAAE,CAAC;CAC7D"}
|
package/dist/features/workload-reconciliation/application/use-cases/createKubernetesPrerequisites.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { createKubernetesDesiredResource } from '../../utils/createKubernetesDesiredResource';
|
|
2
|
+
import { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference';
|
|
3
|
+
import { toKubernetesName } from '../../utils/toKubernetesName';
|
|
4
|
+
/*** Create config, secret and persistent-volume prerequisites in dependency order. */
|
|
5
|
+
export function createKubernetesPrerequisites(request, input) {
|
|
6
|
+
const resources = [];
|
|
7
|
+
const owners = [input.namespaceOwner];
|
|
8
|
+
const configMap = createConfigMap(request, input);
|
|
9
|
+
if (configMap !== undefined) {
|
|
10
|
+
resources.push(configMap);
|
|
11
|
+
owners.push(configMap.owner.identity);
|
|
12
|
+
}
|
|
13
|
+
const secret = createSecret(request, input);
|
|
14
|
+
if (secret !== undefined) {
|
|
15
|
+
resources.push(secret.resource);
|
|
16
|
+
owners.push(secret.resource.owner.identity);
|
|
17
|
+
}
|
|
18
|
+
for (const volume of input.workload.persistence ?? []) {
|
|
19
|
+
const claim = createPersistentVolumeClaim(request, input, volume);
|
|
20
|
+
resources.push(claim);
|
|
21
|
+
owners.push(claim.owner.identity);
|
|
22
|
+
}
|
|
23
|
+
return { resources, owners, secretBindings: secret?.bindings ?? [] };
|
|
24
|
+
}
|
|
25
|
+
/*** Create portable file configuration without secret content. */
|
|
26
|
+
function createConfigMap(request, input) {
|
|
27
|
+
if (Object.keys(input.values.files).length === 0)
|
|
28
|
+
return undefined;
|
|
29
|
+
const data = Object.fromEntries(Object.values(input.values.files).map((value, index) => [`file-${index}`, value]));
|
|
30
|
+
return createKubernetesDesiredResource(request, {
|
|
31
|
+
resourceId: `config:${input.workloadName}`,
|
|
32
|
+
dependsOn: [input.namespaceOwner],
|
|
33
|
+
resource: {
|
|
34
|
+
apiVersion: 'v1',
|
|
35
|
+
kind: 'ConfigMap',
|
|
36
|
+
metadata: {
|
|
37
|
+
name: `${input.workloadName}-config`,
|
|
38
|
+
namespace: input.namespace,
|
|
39
|
+
labels: {},
|
|
40
|
+
annotations: {},
|
|
41
|
+
},
|
|
42
|
+
data,
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/*** Create a value-free Secret skeleton plus runtime-only materialization bindings. */
|
|
47
|
+
function createSecret(request, input) {
|
|
48
|
+
if (input.values.secrets.length === 0)
|
|
49
|
+
return undefined;
|
|
50
|
+
const resource = createKubernetesDesiredResource(request, {
|
|
51
|
+
resourceId: `secret:${input.workloadName}`,
|
|
52
|
+
dependsOn: [input.namespaceOwner],
|
|
53
|
+
resource: {
|
|
54
|
+
apiVersion: 'v1',
|
|
55
|
+
kind: 'Secret',
|
|
56
|
+
metadata: {
|
|
57
|
+
name: `${input.workloadName}-secrets`,
|
|
58
|
+
namespace: input.namespace,
|
|
59
|
+
labels: {},
|
|
60
|
+
annotations: {},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
const reference = getKubernetesResourceReference(resource.resource);
|
|
65
|
+
return {
|
|
66
|
+
resource,
|
|
67
|
+
bindings: input.values.secrets.map((secret) => ({
|
|
68
|
+
resource: reference,
|
|
69
|
+
key: secret.key,
|
|
70
|
+
reference: secret.reference,
|
|
71
|
+
})),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/*** Create one persistent volume claim from portable capacity and retention intent. */
|
|
75
|
+
function createPersistentVolumeClaim(request, input, volume) {
|
|
76
|
+
const volumeName = toKubernetesName(volume.id);
|
|
77
|
+
return createKubernetesDesiredResource(request, {
|
|
78
|
+
resourceId: `volume:${input.workloadName}:${volume.id}`,
|
|
79
|
+
persistent: true,
|
|
80
|
+
retention: volume.retention,
|
|
81
|
+
dependsOn: [input.namespaceOwner],
|
|
82
|
+
resource: {
|
|
83
|
+
apiVersion: 'v1',
|
|
84
|
+
kind: 'PersistentVolumeClaim',
|
|
85
|
+
metadata: {
|
|
86
|
+
name: `${input.workloadName}-${volumeName}`,
|
|
87
|
+
namespace: input.namespace,
|
|
88
|
+
labels: {},
|
|
89
|
+
annotations: {},
|
|
90
|
+
},
|
|
91
|
+
spec: {
|
|
92
|
+
accessModes: ['ReadWriteOnce'],
|
|
93
|
+
resources: { requests: { storage: `${volume.sizeGiB}Gi` } },
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=createKubernetesPrerequisites.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createKubernetesPrerequisites.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/createKubernetesPrerequisites.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,+BAA+B,EAAE,MAAM,6CAA6C,CAAC;AAC9F,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAC5F,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,sFAAsF;AACtF,MAAM,UAAU,6BAA6B,CAC3C,OAAgC,EAChC,KAAyC;IAEzC,MAAM,SAAS,GAAgC,EAAE,CAAC;IAClD,MAAM,MAAM,GAA4B,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,eAAe,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC;IAClD,IAAI,SA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;YACf,SAAS,EAAE,MAAM,CAAC,SAAS;SAC5B,CAAC,CAAC;KACJ,CAAC;AACJ,CAAC;AAED,uFAAuF;AACvF,SAAS,2BAA2B,CAClC,OAAgC,EAChC,KAAyC,EACzC,MAA6D;IAE7D,MAAM,UAAU,GAAG,gBAAgB,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC/C,OAAO,+BAA+B,CAAC,OAAO,EAAE;QAC9C,UAAU,EAAE,UAAU,KAAK,CAAC,YAAY,IAAI,MAAM,CAAC,EAAE,EAAE;QACvD,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,SAAS,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC;QACjC,QAAQ,EAAE;YACR,UAAU,EAAE,IAAI;YAChB,IAAI,EAAE,uBAAuB;YAC7B,QAAQ,EAAE;gBACR,IAAI,EAAE,GAAG,KAAK,CAAC,YAAY,IAAI,UAAU,EAAE;gBAC3C,SAAS,EAAE,KAAK,CAAC,SAAS;gBAC1B,MAAM,EAAE,EAAE;gBACV,WAAW,EAAE,EAAE;aAChB;YACD,IAAI,EAAE;gBACJ,WAAW,EAAE,CAAC,eAAe,CAAC;gBAC9B,SAAS,EAAE,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,EAAE;aAC5D;SACF;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import type { InfraResourceIdentity, InfraWorkloadSpec } from '@ankhorage/contracts/infra';\n\nimport type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver';\nimport type {\n KubernetesDesiredResource,\n KubernetesResolvedWorkloadValues,\n KubernetesSecretBinding,\n} from '../../../../types/kubernetesResources';\nimport { createKubernetesDesiredResource } from '../../utils/createKubernetesDesiredResource';\nimport { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference';\nimport { toKubernetesName } from '../../utils/toKubernetesName';\n\n/*** Create config, secret and persistent-volume prerequisites in dependency order. */\nexport function createKubernetesPrerequisites(\n request: KubernetesDriverRequest,\n input: CreateKubernetesPrerequisitesInput,\n): KubernetesPrerequisites {\n const resources: KubernetesDesiredResource[] = [];\n const owners: InfraResourceIdentity[] = [input.namespaceOwner];\n const configMap = createConfigMap(request, input);\n if (configMap !== undefined) {\n resources.push(configMap);\n owners.push(configMap.owner.identity);\n }\n const secret = createSecret(request, input);\n if (secret !== undefined) {\n resources.push(secret.resource);\n owners.push(secret.resource.owner.identity);\n }\n for (const volume of input.workload.persistence ?? []) {\n const claim = createPersistentVolumeClaim(request, input, volume);\n resources.push(claim);\n owners.push(claim.owner.identity);\n }\n return { resources, owners, secretBindings: secret?.bindings ?? [] };\n}\n\nexport interface CreateKubernetesPrerequisitesInput {\n readonly namespace: string;\n readonly namespaceOwner: InfraResourceIdentity;\n readonly workloadName: string;\n readonly workload: InfraWorkloadSpec;\n readonly values: KubernetesResolvedWorkloadValues;\n}\n\nexport interface KubernetesPrerequisites {\n readonly resources: readonly KubernetesDesiredResource[];\n readonly owners: readonly InfraResourceIdentity[];\n readonly secretBindings: readonly KubernetesSecretBinding[];\n}\n\n/*** Create portable file configuration without secret content. */\nfunction createConfigMap(\n request: KubernetesDriverRequest,\n input: CreateKubernetesPrerequisitesInput,\n): KubernetesDesiredResource | undefined {\n if (Object.keys(input.values.files).length === 0) return undefined;\n const data = Object.fromEntries(\n Object.values(input.values.files).map((value, index) => [`file-${index}`, value]),\n );\n return createKubernetesDesiredResource(request, {\n resourceId: `config:${input.workloadName}`,\n dependsOn: [input.namespaceOwner],\n resource: {\n apiVersion: 'v1',\n kind: 'ConfigMap',\n metadata: {\n name: `${input.workloadName}-config`,\n namespace: input.namespace,\n labels: {},\n annotations: {},\n },\n data,\n },\n });\n}\n\n/*** Create a value-free Secret skeleton plus runtime-only materialization bindings. */\nfunction createSecret(\n request: KubernetesDriverRequest,\n input: CreateKubernetesPrerequisitesInput,\n):\n | {\n readonly resource: KubernetesDesiredResource;\n readonly bindings: readonly KubernetesSecretBinding[];\n }\n | undefined {\n if (input.values.secrets.length === 0) return undefined;\n const resource = createKubernetesDesiredResource(request, {\n resourceId: `secret:${input.workloadName}`,\n dependsOn: [input.namespaceOwner],\n resource: {\n apiVersion: 'v1',\n kind: 'Secret',\n metadata: {\n name: `${input.workloadName}-secrets`,\n namespace: input.namespace,\n labels: {},\n annotations: {},\n },\n },\n });\n const reference = getKubernetesResourceReference(resource.resource);\n return {\n resource,\n bindings: input.values.secrets.map((secret) => ({\n resource: reference,\n key: secret.key,\n reference: secret.reference,\n })),\n };\n}\n\n/*** Create one persistent volume claim from portable capacity and retention intent. */\nfunction createPersistentVolumeClaim(\n request: KubernetesDriverRequest,\n input: CreateKubernetesPrerequisitesInput,\n volume: NonNullable<InfraWorkloadSpec['persistence']>[number],\n): KubernetesDesiredResource {\n const volumeName = toKubernetesName(volume.id);\n return createKubernetesDesiredResource(request, {\n resourceId: `volume:${input.workloadName}:${volume.id}`,\n persistent: true,\n retention: volume.retention,\n dependsOn: [input.namespaceOwner],\n resource: {\n apiVersion: 'v1',\n kind: 'PersistentVolumeClaim',\n metadata: {\n name: `${input.workloadName}-${volumeName}`,\n namespace: input.namespace,\n labels: {},\n annotations: {},\n },\n spec: {\n accessModes: ['ReadWriteOnce'],\n resources: { requests: { storage: `${volume.sizeGiB}Gi` } },\n },\n },\n });\n}\n"]}
|
package/dist/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InfraOutput, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { KubernetesDriverOptions, KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
3
|
+
/*** Read safe public outputs exposed by Infra-owned Kubernetes resources. */
|
|
4
|
+
export declare function getKubernetesOutputsAsync(options: KubernetesDriverOptions, request: KubernetesDriverRequest): Promise<InfraResult<readonly InfraOutput[]>>;
|
|
5
|
+
//# sourceMappingURL=getKubernetesOutputsAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getKubernetesOutputsAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE3E,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,oCAAoC,CAAC;AAK5C,6EAA6E;AAC7E,wBAAsB,yBAAyB,CAC7C,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,WAAW,CAAC,SAAS,WAAW,EAAE,CAAC,CAAC,CA8B9C"}
|
package/dist/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery';
|
|
2
|
+
import { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference';
|
|
3
|
+
import { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource';
|
|
4
|
+
/*** Read safe public outputs exposed by Infra-owned Kubernetes resources. */
|
|
5
|
+
export async function getKubernetesOutputsAsync(options, request) {
|
|
6
|
+
try {
|
|
7
|
+
const resources = await options.api.listOwnedAsync(getKubernetesOwnershipQuery(request));
|
|
8
|
+
const outputs = [];
|
|
9
|
+
for (const resource of resources) {
|
|
10
|
+
const owner = readKubernetesOwnedResource(resource, request);
|
|
11
|
+
if (owner === undefined)
|
|
12
|
+
continue;
|
|
13
|
+
const observation = await options.api.observeAsync(getKubernetesResourceReference(resource), request.context.signal);
|
|
14
|
+
for (const [name, value] of Object.entries(observation.publicOutputs ?? {}).sort(([a], [b]) => a.localeCompare(b))) {
|
|
15
|
+
outputs.push({ owner: owner.identity, name, visibility: 'public', value });
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
return { ok: true, value: outputs, diagnostics: [] };
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return {
|
|
22
|
+
ok: false,
|
|
23
|
+
diagnostics: [
|
|
24
|
+
{
|
|
25
|
+
severity: 'error',
|
|
26
|
+
code: 'kubernetes-outputs-failed',
|
|
27
|
+
message: 'Kubernetes public outputs could not be read.',
|
|
28
|
+
},
|
|
29
|
+
],
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=getKubernetesOutputsAsync.js.map
|
package/dist/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getKubernetesOutputsAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/getKubernetesOutputsAsync.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AACtF,OAAO,EAAE,8BAA8B,EAAE,MAAM,4CAA4C,CAAC;AAC5F,OAAO,EAAE,2BAA2B,EAAE,MAAM,yCAAyC,CAAC;AAEtF,6EAA6E;AAC7E,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,OAAgC,EAChC,OAAgC;IAEhC,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,2BAA2B,CAAC,OAAO,CAAC,CAAC,CAAC;QACzF,MAAM,OAAO,GAAkB,EAAE,CAAC;QAClC,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;YACjC,MAAM,KAAK,GAAG,2BAA2B,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC7D,IAAI,KAAK,KAAK,SAAS;gBAAE,SAAS;YAClC,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,YAAY,CAChD,8BAA8B,CAAC,QAAQ,CAAC,EACxC,OAAO,CAAC,OAAO,CAAC,MAAM,CACvB,CAAC;YACF,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAC5F,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CACnB,EAAE,CAAC;gBACF,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,CAAC;YAC7E,CAAC;QACH,CAAC;QACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,EAAE,EAAE,CAAC;IACvD,CAAC;IAAC,MAAM,CAAC;QACP,OAAO;YACL,EAAE,EAAE,KAAK;YACT,WAAW,EAAE;gBACX;oBACE,QAAQ,EAAE,OAAO;oBACjB,IAAI,EAAE,2BAA2B;oBACjC,OAAO,EAAE,8CAA8C;iBACxD;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { InfraOutput, InfraResult } from '@ankhorage/contracts/infra';\n\nimport type {\n KubernetesDriverOptions,\n KubernetesDriverRequest,\n} from '../../../../types/kubernetesDriver';\nimport { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery';\nimport { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference';\nimport { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource';\n\n/*** Read safe public outputs exposed by Infra-owned Kubernetes resources. */\nexport async function getKubernetesOutputsAsync(\n options: KubernetesDriverOptions,\n request: KubernetesDriverRequest,\n): Promise<InfraResult<readonly InfraOutput[]>> {\n try {\n const resources = await options.api.listOwnedAsync(getKubernetesOwnershipQuery(request));\n const outputs: InfraOutput[] = [];\n for (const resource of resources) {\n const owner = readKubernetesOwnedResource(resource, request);\n if (owner === undefined) continue;\n const observation = await options.api.observeAsync(\n getKubernetesResourceReference(resource),\n request.context.signal,\n );\n for (const [name, value] of Object.entries(observation.publicOutputs ?? {}).sort(([a], [b]) =>\n a.localeCompare(b),\n )) {\n outputs.push({ owner: owner.identity, name, visibility: 'public', value });\n }\n }\n return { ok: true, value: outputs, diagnostics: [] };\n } catch {\n return {\n ok: false,\n diagnostics: [\n {\n severity: 'error',\n code: 'kubernetes-outputs-failed',\n message: 'Kubernetes public outputs could not be read.',\n },\n ],\n };\n }\n}\n"]}
|
package/dist/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { InfraResourceStatus, InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { KubernetesDriverOptions, KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
3
|
+
/*** Read provider-neutral status for every safely identified Infra-owned resource. */
|
|
4
|
+
export declare function getKubernetesStatusAsync(options: KubernetesDriverOptions, request: KubernetesDriverRequest): Promise<InfraResult<readonly InfraResourceStatus[]>>;
|
|
5
|
+
//# sourceMappingURL=getKubernetesStatusAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getKubernetesStatusAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAEnF,OAAO,KAAK,EACV,uBAAuB,EACvB,uBAAuB,EACxB,MAAM,oCAAoC,CAAC;AAK5C,sFAAsF;AACtF,wBAAsB,wBAAwB,CAC5C,OAAO,EAAE,uBAAuB,EAChC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,WAAW,CAAC,SAAS,mBAAmB,EAAE,CAAC,CAAC,CA8BtD"}
|
package/dist/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.js
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery';
|
|
2
|
+
import { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference';
|
|
3
|
+
import { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource';
|
|
4
|
+
/*** Read provider-neutral status for every safely identified Infra-owned resource. */
|
|
5
|
+
export async function getKubernetesStatusAsync(options, request) {
|
|
6
|
+
try {
|
|
7
|
+
const resources = await options.api.listOwnedAsync(getKubernetesOwnershipQuery(request));
|
|
8
|
+
const statuses = [];
|
|
9
|
+
for (const resource of resources) {
|
|
10
|
+
const owner = readKubernetesOwnedResource(resource, request);
|
|
11
|
+
if (owner === undefined)
|
|
12
|
+
continue;
|
|
13
|
+
const observation = await options.api.observeAsync(getKubernetesResourceReference(resource), request.context.signal);
|
|
14
|
+
statuses.push({
|
|
15
|
+
owner: owner.identity,
|
|
16
|
+
state: observation.state,
|
|
17
|
+
...(observation.detail === undefined ? {} : { detail: observation.detail }),
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return { ok: true, value: statuses, diagnostics: [] };
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return {
|
|
24
|
+
ok: false,
|
|
25
|
+
diagnostics: [
|
|
26
|
+
{
|
|
27
|
+
severity: 'error',
|
|
28
|
+
code: 'kubernetes-status-failed',
|
|
29
|
+
message: 'Kubernetes resource status could not be read.',
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=getKubernetesStatusAsync.js.map
|
package/dist/features/workload-reconciliation/application/use-cases/getKubernetesStatusAsync.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getKubernetesStatusAsync.js","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/getKubernetes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,EAAE,0BAA0B;oBAChC,OAAO,EAAE,+CAA+C;iBACzD;aACF;SACF,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["import type { InfraResourceStatus, InfraResult } from '@ankhorage/contracts/infra';\n\nimport type {\n KubernetesDriverOptions,\n KubernetesDriverRequest,\n} from '../../../../types/kubernetesDriver';\nimport { getKubernetesOwnershipQuery } from '../../utils/getKubernetesOwnershipQuery';\nimport { getKubernetesResourceReference } from '../../utils/getKubernetesResourceReference';\nimport { readKubernetesOwnedResource } from '../../utils/readKubernetesOwnedResource';\n\n/*** Read provider-neutral status for every safely identified Infra-owned resource. */\nexport async function getKubernetesStatusAsync(\n options: KubernetesDriverOptions,\n request: KubernetesDriverRequest,\n): Promise<InfraResult<readonly InfraResourceStatus[]>> {\n try {\n const resources = await options.api.listOwnedAsync(getKubernetesOwnershipQuery(request));\n const statuses: InfraResourceStatus[] = [];\n for (const resource of resources) {\n const owner = readKubernetesOwnedResource(resource, request);\n if (owner === undefined) continue;\n const observation = await options.api.observeAsync(\n getKubernetesResourceReference(resource),\n request.context.signal,\n );\n statuses.push({\n owner: owner.identity,\n state: observation.state,\n ...(observation.detail === undefined ? {} : { detail: observation.detail }),\n });\n }\n return { ok: true, value: statuses, diagnostics: [] };\n } catch {\n return {\n ok: false,\n diagnostics: [\n {\n severity: 'error',\n code: 'kubernetes-status-failed',\n message: 'Kubernetes resource status could not be read.',\n },\n ],\n };\n }\n}\n"]}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { InfraResult } from '@ankhorage/contracts/infra';
|
|
2
|
+
import type { KubernetesDriverRequest } from '../../../../types/kubernetesDriver';
|
|
3
|
+
import type { KubernetesDesiredResource, KubernetesProjection } from '../../../../types/kubernetesResources';
|
|
4
|
+
/*** Resolve referenced secrets into ephemeral Kubernetes apply resources. */
|
|
5
|
+
export declare function materializeKubernetesSecretsAsync(request: KubernetesDriverRequest, projection: KubernetesProjection): Promise<InfraResult<readonly KubernetesDesiredResource[]>>;
|
|
6
|
+
//# sourceMappingURL=materializeKubernetesSecretsAsync.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"materializeKubernetesSecretsAsync.d.ts","sourceRoot":"","sources":["../../../../../src/features/workload-reconciliation/application/use-cases/materializeKubernetesSecretsAsync.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAmB,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE/E,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAClF,OAAO,KAAK,EACV,yBAAyB,EACzB,oBAAoB,EACrB,MAAM,uCAAuC,CAAC;AAG/C,6EAA6E;AAC7E,wBAAsB,iCAAiC,CACrD,OAAO,EAAE,uBAAuB,EAChC,UAAU,EAAE,oBAAoB,GAC/B,OAAO,CAAC,WAAW,CAAC,SAAS,yBAAyB,EAAE,CAAC,CAAC,CA6B5D"}
|