@intentius/chant-lexicon-k8s 0.0.14 → 0.0.15
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/dist/integrity.json +6 -3
- package/dist/manifest.json +1 -1
- package/dist/rules/wk8204.ts +33 -1
- package/dist/rules/wk8304.ts +70 -0
- package/dist/rules/wk8305.ts +115 -0
- package/dist/rules/wk8306.ts +50 -0
- package/package.json +27 -24
- package/src/codegen/docs.ts +1 -1
- package/src/composites/adot-collector.ts +8 -2
- package/src/composites/agic-ingress.ts +149 -0
- package/src/composites/alb-ingress.ts +2 -1
- package/src/composites/autoscaled-service.ts +25 -7
- package/src/composites/azure-disk-storage-class.ts +82 -0
- package/src/composites/azure-file-storage-class.ts +77 -0
- package/src/composites/azure-monitor-collector.ts +232 -0
- package/src/composites/batch-job.ts +36 -3
- package/src/composites/composites.test.ts +701 -0
- package/src/composites/config-connector-context.ts +62 -0
- package/src/composites/configured-app.ts +6 -0
- package/src/composites/cron-workload.ts +6 -0
- package/src/composites/ebs-storage-class.ts +4 -4
- package/src/composites/external-dns-agent.ts +6 -0
- package/src/composites/filestore-storage-class.ts +79 -0
- package/src/composites/fluent-bit-agent.ts +5 -0
- package/src/composites/gce-pd-storage-class.ts +85 -0
- package/src/composites/gke-gateway.ts +143 -0
- package/src/composites/index.ts +19 -0
- package/src/composites/metrics-server.ts +1 -1
- package/src/composites/monitored-service.ts +6 -0
- package/src/composites/network-isolated-app.ts +6 -0
- package/src/composites/node-agent.ts +6 -0
- package/src/composites/security-context.ts +10 -0
- package/src/composites/sidecar-app.ts +6 -0
- package/src/composites/stateful-app.ts +4 -7
- package/src/composites/web-app.ts +4 -7
- package/src/composites/worker-pool.ts +4 -7
- package/src/composites/workload-identity-sa.ts +118 -0
- package/src/composites/workload-identity-service-account.ts +116 -0
- package/src/index.ts +6 -1
- package/src/lint/post-synth/post-synth.test.ts +362 -1
- package/src/lint/post-synth/wk8204.ts +33 -1
- package/src/lint/post-synth/wk8304.ts +70 -0
- package/src/lint/post-synth/wk8305.ts +115 -0
- package/src/lint/post-synth/wk8306.ts +50 -0
- package/src/plugin.test.ts +2 -2
- package/src/plugin.ts +4 -1
- package/src/serializer.test.ts +120 -0
- package/src/serializer.ts +16 -4
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* like databases, caches, and message queues.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import type { ContainerSecurityContext } from "./security-context";
|
|
9
|
+
|
|
8
10
|
export interface StatefulAppProps {
|
|
9
11
|
/** Application name — used in metadata and labels. */
|
|
10
12
|
name: string;
|
|
@@ -29,13 +31,8 @@ export interface StatefulAppProps {
|
|
|
29
31
|
command?: string[];
|
|
30
32
|
args?: string[];
|
|
31
33
|
}>;
|
|
32
|
-
/**
|
|
33
|
-
securityContext?:
|
|
34
|
-
runAsNonRoot?: boolean;
|
|
35
|
-
readOnlyRootFilesystem?: boolean;
|
|
36
|
-
runAsUser?: number;
|
|
37
|
-
runAsGroup?: number;
|
|
38
|
-
};
|
|
34
|
+
/** Container security context (supports PSS restricted fields). */
|
|
35
|
+
securityContext?: ContainerSecurityContext;
|
|
39
36
|
/** Termination grace period in seconds. */
|
|
40
37
|
terminationGracePeriodSeconds?: number;
|
|
41
38
|
/** Priority class name for pod scheduling. */
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* with common defaults (health probes, resource limits, labels).
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import type { ContainerSecurityContext } from "./security-context";
|
|
9
|
+
|
|
8
10
|
export interface WebAppProps {
|
|
9
11
|
/** Application name — used in metadata and labels. */
|
|
10
12
|
name: string;
|
|
@@ -34,13 +36,8 @@ export interface WebAppProps {
|
|
|
34
36
|
command?: string[];
|
|
35
37
|
args?: string[];
|
|
36
38
|
}>;
|
|
37
|
-
/**
|
|
38
|
-
securityContext?:
|
|
39
|
-
runAsNonRoot?: boolean;
|
|
40
|
-
readOnlyRootFilesystem?: boolean;
|
|
41
|
-
runAsUser?: number;
|
|
42
|
-
runAsGroup?: number;
|
|
43
|
-
};
|
|
39
|
+
/** Container security context (supports PSS restricted fields). */
|
|
40
|
+
securityContext?: ContainerSecurityContext;
|
|
44
41
|
/** Termination grace period in seconds. */
|
|
45
42
|
terminationGracePeriodSeconds?: number;
|
|
46
43
|
/** Priority class name for pod scheduling. */
|
|
@@ -5,6 +5,8 @@
|
|
|
5
5
|
* that need RBAC for secrets/configmaps and optional autoscaling, but no Service.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
+
import type { ContainerSecurityContext } from "./security-context";
|
|
9
|
+
|
|
8
10
|
export interface WorkerPoolProps {
|
|
9
11
|
/** Worker name — used in metadata and labels. */
|
|
10
12
|
name: string;
|
|
@@ -32,13 +34,8 @@ export interface WorkerPoolProps {
|
|
|
32
34
|
};
|
|
33
35
|
/** PodDisruptionBudget minAvailable — if set, creates a PDB. */
|
|
34
36
|
minAvailable?: number | string;
|
|
35
|
-
/**
|
|
36
|
-
securityContext?:
|
|
37
|
-
runAsNonRoot?: boolean;
|
|
38
|
-
readOnlyRootFilesystem?: boolean;
|
|
39
|
-
runAsUser?: number;
|
|
40
|
-
runAsGroup?: number;
|
|
41
|
-
};
|
|
37
|
+
/** Container security context (supports PSS restricted fields). */
|
|
38
|
+
securityContext?: ContainerSecurityContext;
|
|
42
39
|
/** Termination grace period in seconds. */
|
|
43
40
|
terminationGracePeriodSeconds?: number;
|
|
44
41
|
/** Priority class name for pod scheduling. */
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkloadIdentityServiceAccount composite — ServiceAccount + Workload Identity annotation + optional RBAC.
|
|
3
|
+
*
|
|
4
|
+
* @aks Creates a ServiceAccount with the `azure.workload.identity/client-id`
|
|
5
|
+
* annotation and `azure.workload.identity/use: "true"` label for AKS Workload Identity.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface WorkloadIdentityServiceAccountProps {
|
|
9
|
+
/** ServiceAccount name — used in metadata and labels. */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Azure AD application client ID for Workload Identity. */
|
|
12
|
+
clientId: string;
|
|
13
|
+
/** Optional RBAC rules — if provided, creates Role + RoleBinding. */
|
|
14
|
+
rbacRules?: Array<{
|
|
15
|
+
apiGroups: string[];
|
|
16
|
+
resources: string[];
|
|
17
|
+
verbs: string[];
|
|
18
|
+
}>;
|
|
19
|
+
/** Additional labels to apply to all resources. */
|
|
20
|
+
labels?: Record<string, string>;
|
|
21
|
+
/** Namespace for all resources. */
|
|
22
|
+
namespace?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface WorkloadIdentityServiceAccountResult {
|
|
26
|
+
serviceAccount: Record<string, unknown>;
|
|
27
|
+
role?: Record<string, unknown>;
|
|
28
|
+
roleBinding?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Create a WorkloadIdentityServiceAccount composite — returns prop objects for
|
|
33
|
+
* a ServiceAccount with AKS Workload Identity annotation, and optional Role + RoleBinding.
|
|
34
|
+
*
|
|
35
|
+
* @aks
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { WorkloadIdentityServiceAccount } from "@intentius/chant-lexicon-k8s";
|
|
39
|
+
*
|
|
40
|
+
* const { serviceAccount, role, roleBinding } = WorkloadIdentityServiceAccount({
|
|
41
|
+
* name: "app-sa",
|
|
42
|
+
* clientId: "00000000-0000-0000-0000-000000000000",
|
|
43
|
+
* rbacRules: [
|
|
44
|
+
* { apiGroups: [""], resources: ["secrets"], verbs: ["get"] },
|
|
45
|
+
* ],
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export function WorkloadIdentityServiceAccount(props: WorkloadIdentityServiceAccountProps): WorkloadIdentityServiceAccountResult {
|
|
50
|
+
const {
|
|
51
|
+
name,
|
|
52
|
+
clientId,
|
|
53
|
+
rbacRules,
|
|
54
|
+
labels: extraLabels = {},
|
|
55
|
+
namespace,
|
|
56
|
+
} = props;
|
|
57
|
+
|
|
58
|
+
const roleName = `${name}-role`;
|
|
59
|
+
const bindingName = `${name}-binding`;
|
|
60
|
+
|
|
61
|
+
const commonLabels: Record<string, string> = {
|
|
62
|
+
"app.kubernetes.io/name": name,
|
|
63
|
+
"app.kubernetes.io/managed-by": "chant",
|
|
64
|
+
...extraLabels,
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
const serviceAccountProps: Record<string, unknown> = {
|
|
68
|
+
metadata: {
|
|
69
|
+
name,
|
|
70
|
+
...(namespace && { namespace }),
|
|
71
|
+
labels: {
|
|
72
|
+
...commonLabels,
|
|
73
|
+
"app.kubernetes.io/component": "service-account",
|
|
74
|
+
"azure.workload.identity/use": "true",
|
|
75
|
+
},
|
|
76
|
+
annotations: {
|
|
77
|
+
"azure.workload.identity/client-id": clientId,
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
const result: WorkloadIdentityServiceAccountResult = {
|
|
83
|
+
serviceAccount: serviceAccountProps,
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
if (rbacRules && rbacRules.length > 0) {
|
|
87
|
+
result.role = {
|
|
88
|
+
metadata: {
|
|
89
|
+
name: roleName,
|
|
90
|
+
...(namespace && { namespace }),
|
|
91
|
+
labels: { ...commonLabels, "app.kubernetes.io/component": "rbac" },
|
|
92
|
+
},
|
|
93
|
+
rules: rbacRules,
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
result.roleBinding = {
|
|
97
|
+
metadata: {
|
|
98
|
+
name: bindingName,
|
|
99
|
+
...(namespace && { namespace }),
|
|
100
|
+
labels: { ...commonLabels, "app.kubernetes.io/component": "rbac" },
|
|
101
|
+
},
|
|
102
|
+
roleRef: {
|
|
103
|
+
apiGroup: "rbac.authorization.k8s.io",
|
|
104
|
+
kind: "Role",
|
|
105
|
+
name: roleName,
|
|
106
|
+
},
|
|
107
|
+
subjects: [
|
|
108
|
+
{
|
|
109
|
+
kind: "ServiceAccount",
|
|
110
|
+
name,
|
|
111
|
+
...(namespace && { namespace }),
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
return result;
|
|
118
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WorkloadIdentityServiceAccount composite — ServiceAccount + GKE Workload Identity annotation + optional RBAC.
|
|
3
|
+
*
|
|
4
|
+
* @gke Creates a ServiceAccount with the `iam.gke.io/gcp-service-account`
|
|
5
|
+
* annotation for GKE Workload Identity Federation.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export interface WorkloadIdentityServiceAccountProps {
|
|
9
|
+
/** ServiceAccount name — used in metadata and labels. */
|
|
10
|
+
name: string;
|
|
11
|
+
/** GCP service account email for Workload Identity annotation. */
|
|
12
|
+
gcpServiceAccountEmail: string;
|
|
13
|
+
/** Optional RBAC rules — if provided, creates Role + RoleBinding. */
|
|
14
|
+
rbacRules?: Array<{
|
|
15
|
+
apiGroups: string[];
|
|
16
|
+
resources: string[];
|
|
17
|
+
verbs: string[];
|
|
18
|
+
}>;
|
|
19
|
+
/** Additional labels to apply to all resources. */
|
|
20
|
+
labels?: Record<string, string>;
|
|
21
|
+
/** Namespace for all resources. */
|
|
22
|
+
namespace?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface WorkloadIdentityServiceAccountResult {
|
|
26
|
+
serviceAccount: Record<string, unknown>;
|
|
27
|
+
role?: Record<string, unknown>;
|
|
28
|
+
roleBinding?: Record<string, unknown>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Create a WorkloadIdentityServiceAccount composite — returns prop objects for
|
|
33
|
+
* a ServiceAccount with GKE Workload Identity annotation, and optional Role + RoleBinding.
|
|
34
|
+
*
|
|
35
|
+
* @gke
|
|
36
|
+
* @example
|
|
37
|
+
* ```ts
|
|
38
|
+
* import { WorkloadIdentityServiceAccount } from "@intentius/chant-lexicon-k8s";
|
|
39
|
+
*
|
|
40
|
+
* const { serviceAccount, role, roleBinding } = WorkloadIdentityServiceAccount({
|
|
41
|
+
* name: "app-sa",
|
|
42
|
+
* gcpServiceAccountEmail: "sa@my-project.iam.gserviceaccount.com",
|
|
43
|
+
* rbacRules: [
|
|
44
|
+
* { apiGroups: [""], resources: ["secrets"], verbs: ["get"] },
|
|
45
|
+
* ],
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export function WorkloadIdentityServiceAccount(
|
|
50
|
+
props: WorkloadIdentityServiceAccountProps,
|
|
51
|
+
): WorkloadIdentityServiceAccountResult {
|
|
52
|
+
const {
|
|
53
|
+
name,
|
|
54
|
+
gcpServiceAccountEmail,
|
|
55
|
+
rbacRules,
|
|
56
|
+
labels: extraLabels = {},
|
|
57
|
+
namespace,
|
|
58
|
+
} = props;
|
|
59
|
+
|
|
60
|
+
const roleName = `${name}-role`;
|
|
61
|
+
const bindingName = `${name}-binding`;
|
|
62
|
+
|
|
63
|
+
const commonLabels: Record<string, string> = {
|
|
64
|
+
"app.kubernetes.io/name": name,
|
|
65
|
+
"app.kubernetes.io/managed-by": "chant",
|
|
66
|
+
...extraLabels,
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const serviceAccountProps: Record<string, unknown> = {
|
|
70
|
+
metadata: {
|
|
71
|
+
name,
|
|
72
|
+
...(namespace && { namespace }),
|
|
73
|
+
labels: { ...commonLabels, "app.kubernetes.io/component": "service-account" },
|
|
74
|
+
annotations: {
|
|
75
|
+
"iam.gke.io/gcp-service-account": gcpServiceAccountEmail,
|
|
76
|
+
},
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const result: WorkloadIdentityServiceAccountResult = {
|
|
81
|
+
serviceAccount: serviceAccountProps,
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
if (rbacRules && rbacRules.length > 0) {
|
|
85
|
+
result.role = {
|
|
86
|
+
metadata: {
|
|
87
|
+
name: roleName,
|
|
88
|
+
...(namespace && { namespace }),
|
|
89
|
+
labels: { ...commonLabels, "app.kubernetes.io/component": "rbac" },
|
|
90
|
+
},
|
|
91
|
+
rules: rbacRules,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
result.roleBinding = {
|
|
95
|
+
metadata: {
|
|
96
|
+
name: bindingName,
|
|
97
|
+
...(namespace && { namespace }),
|
|
98
|
+
labels: { ...commonLabels, "app.kubernetes.io/component": "rbac" },
|
|
99
|
+
},
|
|
100
|
+
roleRef: {
|
|
101
|
+
apiGroup: "rbac.authorization.k8s.io",
|
|
102
|
+
kind: "Role",
|
|
103
|
+
name: roleName,
|
|
104
|
+
},
|
|
105
|
+
subjects: [
|
|
106
|
+
{
|
|
107
|
+
kind: "ServiceAccount",
|
|
108
|
+
name,
|
|
109
|
+
...(namespace && { namespace }),
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
return result;
|
|
116
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -20,7 +20,7 @@ export {
|
|
|
20
20
|
WebApp, StatefulApp, CronWorkload, AutoscaledService, WorkerPool, NamespaceEnv, NodeAgent,
|
|
21
21
|
BatchJob, SecureIngress, ConfiguredApp, SidecarApp, MonitoredService, NetworkIsolatedApp,
|
|
22
22
|
IrsaServiceAccount, AlbIngress, EbsStorageClass, EfsStorageClass, FluentBitAgent, ExternalDnsAgent, AdotCollector,
|
|
23
|
-
MetricsServer,
|
|
23
|
+
MetricsServer, WorkloadIdentityServiceAccount, GcePdStorageClass, FilestoreStorageClass, GkeGateway, ConfigConnectorContext,
|
|
24
24
|
} from "./composites/index";
|
|
25
25
|
export type {
|
|
26
26
|
WebAppProps, WebAppResult, StatefulAppProps, StatefulAppResult, CronWorkloadProps, CronWorkloadResult,
|
|
@@ -34,6 +34,11 @@ export type {
|
|
|
34
34
|
FluentBitAgentProps, FluentBitAgentResult, ExternalDnsAgentProps, ExternalDnsAgentResult,
|
|
35
35
|
AdotCollectorProps, AdotCollectorResult,
|
|
36
36
|
MetricsServerProps, MetricsServerResult,
|
|
37
|
+
WorkloadIdentityServiceAccountProps, WorkloadIdentityServiceAccountResult,
|
|
38
|
+
GcePdStorageClassProps, GcePdStorageClassResult,
|
|
39
|
+
FilestoreStorageClassProps, FilestoreStorageClassResult,
|
|
40
|
+
GkeGatewayProps, GkeGatewayResult,
|
|
41
|
+
ConfigConnectorContextProps, ConfigConnectorContextResult,
|
|
37
42
|
} from "./composites/index";
|
|
38
43
|
|
|
39
44
|
// RBAC verb constants
|