@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.
Files changed (48) hide show
  1. package/dist/integrity.json +6 -3
  2. package/dist/manifest.json +1 -1
  3. package/dist/rules/wk8204.ts +33 -1
  4. package/dist/rules/wk8304.ts +70 -0
  5. package/dist/rules/wk8305.ts +115 -0
  6. package/dist/rules/wk8306.ts +50 -0
  7. package/package.json +27 -24
  8. package/src/codegen/docs.ts +1 -1
  9. package/src/composites/adot-collector.ts +8 -2
  10. package/src/composites/agic-ingress.ts +149 -0
  11. package/src/composites/alb-ingress.ts +2 -1
  12. package/src/composites/autoscaled-service.ts +25 -7
  13. package/src/composites/azure-disk-storage-class.ts +82 -0
  14. package/src/composites/azure-file-storage-class.ts +77 -0
  15. package/src/composites/azure-monitor-collector.ts +232 -0
  16. package/src/composites/batch-job.ts +36 -3
  17. package/src/composites/composites.test.ts +701 -0
  18. package/src/composites/config-connector-context.ts +62 -0
  19. package/src/composites/configured-app.ts +6 -0
  20. package/src/composites/cron-workload.ts +6 -0
  21. package/src/composites/ebs-storage-class.ts +4 -4
  22. package/src/composites/external-dns-agent.ts +6 -0
  23. package/src/composites/filestore-storage-class.ts +79 -0
  24. package/src/composites/fluent-bit-agent.ts +5 -0
  25. package/src/composites/gce-pd-storage-class.ts +85 -0
  26. package/src/composites/gke-gateway.ts +143 -0
  27. package/src/composites/index.ts +19 -0
  28. package/src/composites/metrics-server.ts +1 -1
  29. package/src/composites/monitored-service.ts +6 -0
  30. package/src/composites/network-isolated-app.ts +6 -0
  31. package/src/composites/node-agent.ts +6 -0
  32. package/src/composites/security-context.ts +10 -0
  33. package/src/composites/sidecar-app.ts +6 -0
  34. package/src/composites/stateful-app.ts +4 -7
  35. package/src/composites/web-app.ts +4 -7
  36. package/src/composites/worker-pool.ts +4 -7
  37. package/src/composites/workload-identity-sa.ts +118 -0
  38. package/src/composites/workload-identity-service-account.ts +116 -0
  39. package/src/index.ts +6 -1
  40. package/src/lint/post-synth/post-synth.test.ts +362 -1
  41. package/src/lint/post-synth/wk8204.ts +33 -1
  42. package/src/lint/post-synth/wk8304.ts +70 -0
  43. package/src/lint/post-synth/wk8305.ts +115 -0
  44. package/src/lint/post-synth/wk8306.ts +50 -0
  45. package/src/plugin.test.ts +2 -2
  46. package/src/plugin.ts +4 -1
  47. package/src/serializer.test.ts +120 -0
  48. package/src/serializer.ts +16 -4
@@ -0,0 +1,62 @@
1
+ /**
2
+ * ConfigConnectorContext composite — bootstrap Config Connector per-namespace context.
3
+ *
4
+ * @gke Creates a ConfigConnectorContext resource that configures
5
+ * Config Connector to manage GCP resources in a specific namespace.
6
+ */
7
+
8
+ export interface ConfigConnectorContextProps {
9
+ /** Context name (default: "configconnectorcontext.core.cnrm.cloud.google.com"). */
10
+ name?: string;
11
+ /** Google service account email for Config Connector to use. */
12
+ googleServiceAccountEmail: string;
13
+ /** Namespace for the context (default: "default"). */
14
+ namespace?: string;
15
+ /** Whether to sync status into spec (default: "absent"). */
16
+ stateIntoSpec?: "absent" | "merge";
17
+ }
18
+
19
+ export interface ConfigConnectorContextResult {
20
+ context: Record<string, unknown>;
21
+ }
22
+
23
+ /**
24
+ * Create a ConfigConnectorContext composite — returns prop objects for
25
+ * a ConfigConnectorContext resource.
26
+ *
27
+ * @gke
28
+ * @example
29
+ * ```ts
30
+ * import { ConfigConnectorContext } from "@intentius/chant-lexicon-k8s";
31
+ *
32
+ * const { context } = ConfigConnectorContext({
33
+ * googleServiceAccountEmail: "cnrm@my-project.iam.gserviceaccount.com",
34
+ * namespace: "config-connector",
35
+ * });
36
+ * ```
37
+ */
38
+ export function ConfigConnectorContext(
39
+ props: ConfigConnectorContextProps,
40
+ ): ConfigConnectorContextResult {
41
+ const {
42
+ name = "configconnectorcontext.core.cnrm.cloud.google.com",
43
+ googleServiceAccountEmail,
44
+ namespace = "default",
45
+ stateIntoSpec = "absent",
46
+ } = props;
47
+
48
+ const contextProps: Record<string, unknown> = {
49
+ apiVersion: "core.cnrm.cloud.google.com/v1beta1",
50
+ kind: "ConfigConnectorContext",
51
+ metadata: {
52
+ name,
53
+ namespace,
54
+ },
55
+ spec: {
56
+ googleServiceAccount: googleServiceAccountEmail,
57
+ stateIntoSpec,
58
+ },
59
+ };
60
+
61
+ return { context: contextProps };
62
+ }
@@ -6,6 +6,8 @@
6
6
  * Volume.fromSecret(), and container.mount() patterns.
7
7
  */
8
8
 
9
+ import type { ContainerSecurityContext } from "./security-context";
10
+
9
11
  export interface ConfiguredAppProps {
10
12
  /** Application name — used in metadata and labels. */
11
13
  name: string;
@@ -49,6 +51,8 @@ export interface ConfiguredAppProps {
49
51
  namespace?: string;
50
52
  /** Environment variables for the container. */
51
53
  env?: Array<{ name: string; value: string }>;
54
+ /** Container security context (supports PSS restricted fields). */
55
+ securityContext?: ContainerSecurityContext;
52
56
  }
53
57
 
54
58
  export interface ConfiguredAppResult {
@@ -96,6 +100,7 @@ export function ConfiguredApp(props: ConfiguredAppProps): ConfiguredAppResult {
96
100
  memoryRequest = "128Mi",
97
101
  namespace,
98
102
  env,
103
+ securityContext,
99
104
  } = props;
100
105
 
101
106
  const configMapName = `${name}-config`;
@@ -154,6 +159,7 @@ export function ConfiguredApp(props: ConfiguredAppProps): ConfiguredAppResult {
154
159
  ...(env && { env }),
155
160
  ...(envFromList.length > 0 && { envFrom: envFromList }),
156
161
  ...(volumeMounts.length > 0 && { volumeMounts }),
162
+ ...(securityContext && { securityContext }),
157
163
  };
158
164
 
159
165
  const podSpec: Record<string, unknown> = {
@@ -5,6 +5,8 @@
5
5
  * proper RBAC permissions.
6
6
  */
7
7
 
8
+ import type { ContainerSecurityContext } from "./security-context";
9
+
8
10
  export interface CronWorkloadProps {
9
11
  /** Workload name — used in metadata and labels. */
10
12
  name: string;
@@ -33,6 +35,8 @@ export interface CronWorkloadProps {
33
35
  namespace?: string;
34
36
  /** Environment variables. */
35
37
  env?: Array<{ name: string; value: string }>;
38
+ /** Container security context (supports PSS restricted fields). */
39
+ securityContext?: ContainerSecurityContext;
36
40
  }
37
41
 
38
42
  export interface CronWorkloadResult {
@@ -75,6 +79,7 @@ export function CronWorkload(props: CronWorkloadProps): CronWorkloadResult {
75
79
  labels: extraLabels = {},
76
80
  namespace,
77
81
  env,
82
+ securityContext,
78
83
  } = props;
79
84
 
80
85
  const saName = `${name}-sa`;
@@ -110,6 +115,7 @@ export function CronWorkload(props: CronWorkloadProps): CronWorkloadResult {
110
115
  ...(command && { command }),
111
116
  ...(args && { args }),
112
117
  ...(env && { env }),
118
+ ...(securityContext && { securityContext }),
113
119
  },
114
120
  ],
115
121
  },
@@ -10,9 +10,9 @@ export interface EbsStorageClassProps {
10
10
  /** EBS volume type (default: "gp3"). */
11
11
  type?: string;
12
12
  /** IOPS for io1/io2/gp3 volumes. */
13
- iops?: string;
13
+ iops?: string | number;
14
14
  /** Throughput for gp3 volumes (MiB/s). */
15
- throughput?: string;
15
+ throughput?: string | number;
16
16
  /** Enable encryption (default: true). */
17
17
  encrypted?: boolean;
18
18
  /** KMS key ID for encryption. */
@@ -76,8 +76,8 @@ export function EbsStorageClass(props: EbsStorageClassProps): EbsStorageClassRes
76
76
  encrypted: String(encrypted),
77
77
  };
78
78
 
79
- if (iops) parameters.iops = iops;
80
- if (throughput) parameters.throughput = throughput;
79
+ if (iops !== undefined) parameters.iops = String(iops);
80
+ if (throughput !== undefined) parameters.throughput = String(throughput);
81
81
  if (kmsKeyId) parameters.kmsKeyId = kmsKeyId;
82
82
 
83
83
  const storageClassProps: Record<string, unknown> = {
@@ -110,6 +110,12 @@ export function ExternalDnsAgent(props: ExternalDnsAgentProps): ExternalDnsAgent
110
110
  requests: { cpu: "50m", memory: "64Mi" },
111
111
  limits: { cpu: "100m", memory: "128Mi" },
112
112
  },
113
+ securityContext: {
114
+ runAsNonRoot: true,
115
+ runAsUser: 65534,
116
+ readOnlyRootFilesystem: true,
117
+ allowPrivilegeEscalation: false,
118
+ },
113
119
  },
114
120
  ],
115
121
  },
@@ -0,0 +1,79 @@
1
+ /**
2
+ * FilestoreStorageClass composite — StorageClass for GCP Filestore CSI driver.
3
+ *
4
+ * @gke Creates a StorageClass with the `filestore.csi.storage.gke.io` provisioner.
5
+ * Filestore provides ReadWriteMany access mode (shared across pods/nodes).
6
+ */
7
+
8
+ export interface FilestoreStorageClassProps {
9
+ /** StorageClass name. */
10
+ name: string;
11
+ /** Filestore tier (default: "standard"). */
12
+ tier?: "standard" | "premium" | "enterprise";
13
+ /** VPC network for the Filestore instance. */
14
+ network?: string;
15
+ /** Reclaim policy (default: "Delete"). */
16
+ reclaimPolicy?: string;
17
+ /** Volume binding mode (default: "WaitForFirstConsumer"). */
18
+ volumeBindingMode?: string;
19
+ /** Additional labels. */
20
+ labels?: Record<string, string>;
21
+ }
22
+
23
+ export interface FilestoreStorageClassResult {
24
+ storageClass: Record<string, unknown>;
25
+ }
26
+
27
+ /**
28
+ * Create a FilestoreStorageClass composite — returns prop objects for
29
+ * a StorageClass with the GCP Filestore CSI provisioner.
30
+ *
31
+ * @gke
32
+ * @example
33
+ * ```ts
34
+ * import { FilestoreStorageClass } from "@intentius/chant-lexicon-k8s";
35
+ *
36
+ * const { storageClass } = FilestoreStorageClass({
37
+ * name: "filestore-standard",
38
+ * tier: "standard",
39
+ * network: "default",
40
+ * });
41
+ * ```
42
+ */
43
+ export function FilestoreStorageClass(props: FilestoreStorageClassProps): FilestoreStorageClassResult {
44
+ const {
45
+ name,
46
+ tier = "standard",
47
+ network,
48
+ reclaimPolicy = "Delete",
49
+ volumeBindingMode = "WaitForFirstConsumer",
50
+ labels: extraLabels = {},
51
+ } = props;
52
+
53
+ const commonLabels: Record<string, string> = {
54
+ "app.kubernetes.io/name": name,
55
+ "app.kubernetes.io/managed-by": "chant",
56
+ ...extraLabels,
57
+ };
58
+
59
+ const parameters: Record<string, string> = {
60
+ tier,
61
+ };
62
+
63
+ if (network) {
64
+ parameters.network = network;
65
+ }
66
+
67
+ const storageClassProps: Record<string, unknown> = {
68
+ metadata: {
69
+ name,
70
+ labels: { ...commonLabels, "app.kubernetes.io/component": "storage" },
71
+ },
72
+ provisioner: "filestore.csi.storage.gke.io",
73
+ parameters,
74
+ reclaimPolicy,
75
+ volumeBindingMode,
76
+ };
77
+
78
+ return { storageClass: storageClassProps };
79
+ }
@@ -130,6 +130,11 @@ export function FluentBitAgent(props: FluentBitAgentProps): FluentBitAgentResult
130
130
  { name: "config", mountPath: `/etc/${name}`, readOnly: true },
131
131
  { name: "state", mountPath: "/var/fluent-bit/state" },
132
132
  ],
133
+ securityContext: {
134
+ runAsUser: 0,
135
+ readOnlyRootFilesystem: true,
136
+ allowPrivilegeEscalation: false,
137
+ },
133
138
  };
134
139
 
135
140
  const daemonSetProps: Record<string, unknown> = {
@@ -0,0 +1,85 @@
1
+ /**
2
+ * GcePdStorageClass composite — StorageClass for GCE Persistent Disk CSI driver.
3
+ *
4
+ * @gke Creates a StorageClass with the `pd.csi.storage.gke.io` provisioner.
5
+ */
6
+
7
+ export interface GcePdStorageClassProps {
8
+ /** StorageClass name. */
9
+ name: string;
10
+ /** PD type (default: "pd-balanced"). */
11
+ type?: "pd-standard" | "pd-ssd" | "pd-balanced" | "pd-extreme";
12
+ /** Replication type (default: "none"). */
13
+ replicationType?: "none" | "regional-pd";
14
+ /** Filesystem type (default: "ext4"). */
15
+ fsType?: string;
16
+ /** Reclaim policy (default: "Delete"). */
17
+ reclaimPolicy?: string;
18
+ /** Volume binding mode (default: "WaitForFirstConsumer"). */
19
+ volumeBindingMode?: string;
20
+ /** Allow volume expansion (default: true). */
21
+ allowVolumeExpansion?: boolean;
22
+ /** Additional labels. */
23
+ labels?: Record<string, string>;
24
+ }
25
+
26
+ export interface GcePdStorageClassResult {
27
+ storageClass: Record<string, unknown>;
28
+ }
29
+
30
+ /**
31
+ * Create a GcePdStorageClass composite — returns prop objects for
32
+ * a StorageClass with the GCE Persistent Disk CSI provisioner.
33
+ *
34
+ * @gke
35
+ * @example
36
+ * ```ts
37
+ * import { GcePdStorageClass } from "@intentius/chant-lexicon-k8s";
38
+ *
39
+ * const { storageClass } = GcePdStorageClass({
40
+ * name: "pd-ssd",
41
+ * type: "pd-ssd",
42
+ * });
43
+ * ```
44
+ */
45
+ export function GcePdStorageClass(props: GcePdStorageClassProps): GcePdStorageClassResult {
46
+ const {
47
+ name,
48
+ type = "pd-balanced",
49
+ replicationType = "none",
50
+ fsType = "ext4",
51
+ reclaimPolicy = "Delete",
52
+ volumeBindingMode = "WaitForFirstConsumer",
53
+ allowVolumeExpansion = true,
54
+ labels: extraLabels = {},
55
+ } = props;
56
+
57
+ const commonLabels: Record<string, string> = {
58
+ "app.kubernetes.io/name": name,
59
+ "app.kubernetes.io/managed-by": "chant",
60
+ ...extraLabels,
61
+ };
62
+
63
+ const parameters: Record<string, string> = {
64
+ type,
65
+ "csi.storage.k8s.io/fstype": fsType,
66
+ };
67
+
68
+ if (replicationType !== "none") {
69
+ parameters["replication-type"] = replicationType;
70
+ }
71
+
72
+ const storageClassProps: Record<string, unknown> = {
73
+ metadata: {
74
+ name,
75
+ labels: { ...commonLabels, "app.kubernetes.io/component": "storage" },
76
+ },
77
+ provisioner: "pd.csi.storage.gke.io",
78
+ parameters,
79
+ reclaimPolicy,
80
+ volumeBindingMode,
81
+ allowVolumeExpansion,
82
+ };
83
+
84
+ return { storageClass: storageClassProps };
85
+ }
@@ -0,0 +1,143 @@
1
+ /**
2
+ * GkeGateway composite — Gateway + HTTPRoute for GKE Gateway API.
3
+ *
4
+ * @gke Creates a Gateway with a GKE-specific `gatewayClassName` and
5
+ * HTTPRoute resources for traffic routing.
6
+ */
7
+
8
+ export interface GkeGatewayHost {
9
+ /** Hostname (e.g., "api.example.com"). */
10
+ hostname: string;
11
+ /** Path rules for this host. */
12
+ paths: Array<{
13
+ path: string;
14
+ serviceName: string;
15
+ servicePort: number;
16
+ }>;
17
+ }
18
+
19
+ export interface GkeGatewayProps {
20
+ /** Gateway name — used in metadata and labels. */
21
+ name: string;
22
+ /** GKE gateway class (default: "gke-l7-global-external-managed"). */
23
+ gatewayClassName?:
24
+ | "gke-l7-global-external-managed"
25
+ | "gke-l7-regional-external-managed"
26
+ | "gke-l7-rilb";
27
+ /** Host definitions with paths. */
28
+ hosts: GkeGatewayHost[];
29
+ /** Google-managed certificate name for TLS. */
30
+ certificateName?: string;
31
+ /** Additional labels to apply to all resources. */
32
+ labels?: Record<string, string>;
33
+ /** Namespace for all resources. */
34
+ namespace?: string;
35
+ }
36
+
37
+ export interface GkeGatewayResult {
38
+ gateway: Record<string, unknown>;
39
+ httpRoute: Record<string, unknown>;
40
+ }
41
+
42
+ /**
43
+ * Create a GkeGateway composite — returns prop objects for
44
+ * a Gateway and HTTPRoute with GKE-specific gateway class.
45
+ *
46
+ * @gke
47
+ * @example
48
+ * ```ts
49
+ * import { GkeGateway } from "@intentius/chant-lexicon-k8s";
50
+ *
51
+ * const { gateway, httpRoute } = GkeGateway({
52
+ * name: "api-gateway",
53
+ * hosts: [
54
+ * {
55
+ * hostname: "api.example.com",
56
+ * paths: [{ path: "/", serviceName: "api", servicePort: 80 }],
57
+ * },
58
+ * ],
59
+ * certificateName: "api-cert",
60
+ * });
61
+ * ```
62
+ */
63
+ export function GkeGateway(props: GkeGatewayProps): GkeGatewayResult {
64
+ const {
65
+ name,
66
+ gatewayClassName = "gke-l7-global-external-managed",
67
+ hosts,
68
+ certificateName,
69
+ labels: extraLabels = {},
70
+ namespace,
71
+ } = props;
72
+
73
+ const routeName = `${name}-route`;
74
+
75
+ const commonLabels: Record<string, string> = {
76
+ "app.kubernetes.io/name": name,
77
+ "app.kubernetes.io/managed-by": "chant",
78
+ ...extraLabels,
79
+ };
80
+
81
+ // Build Gateway listeners
82
+ const listeners: Array<Record<string, unknown>> = [];
83
+
84
+ if (certificateName) {
85
+ listeners.push({
86
+ name: "https",
87
+ protocol: "HTTPS",
88
+ port: 443,
89
+ tls: {
90
+ mode: "Terminate",
91
+ certificateRefs: [{ kind: "ManagedCertificate", name: certificateName }],
92
+ },
93
+ });
94
+ } else {
95
+ listeners.push({
96
+ name: "http",
97
+ protocol: "HTTP",
98
+ port: 80,
99
+ });
100
+ }
101
+
102
+ const gatewayProps: Record<string, unknown> = {
103
+ metadata: {
104
+ name,
105
+ ...(namespace && { namespace }),
106
+ labels: { ...commonLabels, "app.kubernetes.io/component": "gateway" },
107
+ },
108
+ spec: {
109
+ gatewayClassName,
110
+ listeners,
111
+ },
112
+ };
113
+
114
+ // Build HTTPRoute rules
115
+ const hostnames = hosts.map((h) => h.hostname);
116
+
117
+ const rules = hosts.flatMap((host) =>
118
+ host.paths.map((p) => ({
119
+ matches: [{ path: { type: "PathPrefix", value: p.path } }],
120
+ backendRefs: [
121
+ { name: p.serviceName, port: p.servicePort },
122
+ ],
123
+ })),
124
+ );
125
+
126
+ const httpRouteProps: Record<string, unknown> = {
127
+ metadata: {
128
+ name: routeName,
129
+ ...(namespace && { namespace }),
130
+ labels: { ...commonLabels, "app.kubernetes.io/component": "route" },
131
+ },
132
+ spec: {
133
+ parentRefs: [{ name }],
134
+ hostnames,
135
+ rules,
136
+ },
137
+ };
138
+
139
+ return {
140
+ gateway: gatewayProps,
141
+ httpRoute: httpRouteProps,
142
+ };
143
+ }
@@ -1,3 +1,4 @@
1
+ export type { ContainerSecurityContext } from "./security-context";
1
2
  export { WebApp } from "./web-app";
2
3
  export type { WebAppProps, WebAppResult } from "./web-app";
3
4
  export { StatefulApp } from "./stateful-app";
@@ -40,3 +41,21 @@ export { AdotCollector } from "./adot-collector";
40
41
  export type { AdotCollectorProps, AdotCollectorResult } from "./adot-collector";
41
42
  export { MetricsServer } from "./metrics-server";
42
43
  export type { MetricsServerProps, MetricsServerResult } from "./metrics-server";
44
+ export { WorkloadIdentityServiceAccount } from "./workload-identity-service-account";
45
+ export type { WorkloadIdentityServiceAccountProps, WorkloadIdentityServiceAccountResult } from "./workload-identity-service-account";
46
+ export { GcePdStorageClass } from "./gce-pd-storage-class";
47
+ export type { GcePdStorageClassProps, GcePdStorageClassResult } from "./gce-pd-storage-class";
48
+ export { FilestoreStorageClass } from "./filestore-storage-class";
49
+ export type { FilestoreStorageClassProps, FilestoreStorageClassResult } from "./filestore-storage-class";
50
+ export { GkeGateway } from "./gke-gateway";
51
+ export type { GkeGatewayProps, GkeGatewayResult } from "./gke-gateway";
52
+ export { ConfigConnectorContext } from "./config-connector-context";
53
+ export type { ConfigConnectorContextProps, ConfigConnectorContextResult } from "./config-connector-context";
54
+ export { AgicIngress } from "./agic-ingress";
55
+ export type { AgicIngressProps, AgicIngressResult } from "./agic-ingress";
56
+ export { AzureDiskStorageClass } from "./azure-disk-storage-class";
57
+ export type { AzureDiskStorageClassProps, AzureDiskStorageClassResult } from "./azure-disk-storage-class";
58
+ export { AzureFileStorageClass } from "./azure-file-storage-class";
59
+ export type { AzureFileStorageClassProps, AzureFileStorageClassResult } from "./azure-file-storage-class";
60
+ export { AzureMonitorCollector } from "./azure-monitor-collector";
61
+ export type { AzureMonitorCollectorProps, AzureMonitorCollectorResult } from "./azure-monitor-collector";
@@ -147,7 +147,7 @@ export function MetricsServer(props: MetricsServerProps): MetricsServerResult {
147
147
  labels: { ...commonLabels, "app.kubernetes.io/component": "rbac" },
148
148
  },
149
149
  rules: [
150
- { apiGroups: [""], resources: ["pods", "nodes", "namespaces"], verbs: ["get", "list", "watch"] },
150
+ { apiGroups: [""], resources: ["pods", "nodes", "namespaces", "configmaps"], verbs: ["get", "list", "watch"] },
151
151
  { apiGroups: [""], resources: ["nodes/metrics", "nodes/stats"], verbs: ["get"] },
152
152
  ],
153
153
  };
@@ -6,6 +6,8 @@
6
6
  * as raw objects that can be serialized alongside native K8s resources.
7
7
  */
8
8
 
9
+ import type { ContainerSecurityContext } from "./security-context";
10
+
9
11
  export interface AlertRule {
10
12
  /** Alert name. */
11
13
  name: string;
@@ -50,6 +52,8 @@ export interface MonitoredServiceProps {
50
52
  namespace?: string;
51
53
  /** Environment variables for the container. */
52
54
  env?: Array<{ name: string; value: string }>;
55
+ /** Container security context (supports PSS restricted fields). */
56
+ securityContext?: ContainerSecurityContext;
53
57
  }
54
58
 
55
59
  export interface MonitoredServiceResult {
@@ -95,6 +99,7 @@ export function MonitoredService(props: MonitoredServiceProps): MonitoredService
95
99
  memoryRequest = "128Mi",
96
100
  namespace,
97
101
  env,
102
+ securityContext,
98
103
  } = props;
99
104
 
100
105
  const commonLabels: Record<string, string> = {
@@ -132,6 +137,7 @@ export function MonitoredService(props: MonitoredServiceProps): MonitoredService
132
137
  requests: { cpu: cpuRequest, memory: memoryRequest },
133
138
  },
134
139
  ...(env && { env }),
140
+ ...(securityContext && { securityContext }),
135
141
  },
136
142
  ],
137
143
  },
@@ -5,6 +5,8 @@
5
5
  * Creates fine-grained ingress/egress policies for a single application.
6
6
  */
7
7
 
8
+ import type { ContainerSecurityContext } from "./security-context";
9
+
8
10
  export interface NetworkPolicyPeer {
9
11
  /** Pod selector for the peer. */
10
12
  podSelector?: Record<string, string>;
@@ -44,6 +46,8 @@ export interface NetworkIsolatedAppProps {
44
46
  namespace?: string;
45
47
  /** Environment variables for the container. */
46
48
  env?: Array<{ name: string; value: string }>;
49
+ /** Container security context (supports PSS restricted fields). */
50
+ securityContext?: ContainerSecurityContext;
47
51
  }
48
52
 
49
53
  export interface NetworkIsolatedAppResult {
@@ -88,6 +92,7 @@ export function NetworkIsolatedApp(props: NetworkIsolatedAppProps): NetworkIsola
88
92
  memoryRequest = "128Mi",
89
93
  namespace,
90
94
  env,
95
+ securityContext,
91
96
  } = props;
92
97
 
93
98
  const commonLabels: Record<string, string> = {
@@ -118,6 +123,7 @@ export function NetworkIsolatedApp(props: NetworkIsolatedAppProps): NetworkIsola
118
123
  requests: { cpu: cpuRequest, memory: memoryRequest },
119
124
  },
120
125
  ...(env && { env }),
126
+ ...(securityContext && { securityContext }),
121
127
  },
122
128
  ],
123
129
  },
@@ -5,6 +5,8 @@
5
5
  * security scanners) that need cluster-wide RBAC and tolerations.
6
6
  */
7
7
 
8
+ import type { ContainerSecurityContext } from "./security-context";
9
+
8
10
  export interface NodeAgentProps {
9
11
  /** Agent name — used in metadata and labels. */
10
12
  name: string;
@@ -43,6 +45,8 @@ export interface NodeAgentProps {
43
45
  memoryLimit?: string;
44
46
  /** Environment variables for the container. */
45
47
  env?: Array<{ name: string; value: string }>;
48
+ /** Container security context (supports PSS restricted fields). */
49
+ securityContext?: ContainerSecurityContext;
46
50
  }
47
51
 
48
52
  export interface NodeAgentResult {
@@ -87,6 +91,7 @@ export function NodeAgent(props: NodeAgentProps): NodeAgentResult {
87
91
  memoryLimit = "128Mi",
88
92
  labels: extraLabels = {},
89
93
  env,
94
+ securityContext,
90
95
  } = props;
91
96
 
92
97
  const saName = `${name}-sa`;
@@ -139,6 +144,7 @@ export function NodeAgent(props: NodeAgentProps): NodeAgentResult {
139
144
  },
140
145
  ...(env && { env }),
141
146
  ...(volumeMounts.length > 0 && { volumeMounts }),
147
+ ...(securityContext && { securityContext }),
142
148
  };
143
149
 
144
150
  const podSpec: Record<string, unknown> = {
@@ -0,0 +1,10 @@
1
+ /** Container-level security context — covers PSS restricted requirements. */
2
+ export interface ContainerSecurityContext {
3
+ runAsNonRoot?: boolean;
4
+ readOnlyRootFilesystem?: boolean;
5
+ runAsUser?: number;
6
+ runAsGroup?: number;
7
+ allowPrivilegeEscalation?: boolean;
8
+ capabilities?: { add?: string[]; drop?: string[] };
9
+ seccompProfile?: { type: string; localhostProfile?: string };
10
+ }
@@ -5,6 +5,8 @@
5
5
  * DB migration init). Supports shared volumes between containers.
6
6
  */
7
7
 
8
+ import type { ContainerSecurityContext } from "./security-context";
9
+
8
10
  export interface SidecarContainer {
9
11
  /** Sidecar container name. */
10
12
  name: string;
@@ -70,6 +72,8 @@ export interface SidecarAppProps {
70
72
  namespace?: string;
71
73
  /** Environment variables for the primary container. */
72
74
  env?: Array<{ name: string; value: string }>;
75
+ /** Container security context for the primary container (supports PSS restricted fields). */
76
+ securityContext?: ContainerSecurityContext;
73
77
  }
74
78
 
75
79
  export interface SidecarAppResult {
@@ -115,6 +119,7 @@ export function SidecarApp(props: SidecarAppProps): SidecarAppResult {
115
119
  memoryRequest = "128Mi",
116
120
  namespace,
117
121
  env,
122
+ securityContext,
118
123
  } = props;
119
124
 
120
125
  const commonLabels: Record<string, string> = {
@@ -133,6 +138,7 @@ export function SidecarApp(props: SidecarAppProps): SidecarAppResult {
133
138
  requests: { cpu: cpuRequest, memory: memoryRequest },
134
139
  },
135
140
  ...(env && { env }),
141
+ ...(securityContext && { securityContext }),
136
142
  };
137
143
 
138
144
  // Sidecar containers