Skip to content

Commit e1a2db7

Browse files
Pulumi: Support creating arbitrary CRs via infra stack
Part of #1078 [static] Signed-off-by: Martin Florian <martin.florian@digitalasset.com>
1 parent 8a0005c commit e1a2db7

File tree

5 files changed

+72
-1
lines changed

5 files changed

+72
-1
lines changed

cluster/deployment/mock/config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,19 @@ svs:
117117
kms:
118118
keyRingId: sv-3_participant_mock
119119
locationId: us-central1
120+
extraCustomResources:
121+
sv-1-deny-onboard-prepare-endpoint:
122+
apiVersion: security.istio.io/v1
123+
kind: AuthorizationPolicy
124+
metadata:
125+
name: deny-onboard-prepare-endpoint
126+
namespace: sv-1
127+
spec:
128+
selector:
129+
matchLabels:
130+
app: sv-app
131+
action: DENY
132+
rules:
133+
- to:
134+
- operation:
135+
paths: ["/api/sv/v0/devnet/onboard/validator/prepare"]

cluster/expected/infra/expected.json

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2928,6 +2928,42 @@
29282928
"provider": "",
29292929
"type": "kubernetes:core/v1:Secret"
29302930
},
2931+
{
2932+
"custom": true,
2933+
"id": "",
2934+
"inputs": {
2935+
"apiVersion": "security.istio.io/v1",
2936+
"kind": "AuthorizationPolicy",
2937+
"metadata": {
2938+
"name": "deny-onboard-prepare-endpoint",
2939+
"namespace": "sv-1"
2940+
},
2941+
"spec": {
2942+
"action": "DENY",
2943+
"rules": [
2944+
{
2945+
"to": [
2946+
{
2947+
"operation": {
2948+
"paths": [
2949+
"/api/sv/v0/devnet/onboard/validator/prepare"
2950+
]
2951+
}
2952+
}
2953+
]
2954+
}
2955+
],
2956+
"selector": {
2957+
"matchLabels": {
2958+
"app": "sv-app"
2959+
}
2960+
}
2961+
}
2962+
},
2963+
"name": "sv-1-deny-onboard-prepare-endpoint",
2964+
"provider": "",
2965+
"type": "kubernetes:security.istio.io/v1:AuthorizationPolicy"
2966+
},
29312967
{
29322968
"custom": true,
29332969
"id": "",

cluster/pulumi/infra/src/config.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export const InfraConfigSchema = z.object({
5555
}),
5656
}),
5757
monitoring: MonitoringConfigSchema,
58+
extraCustomResources: z.object({}).catchall(z.any()).default({}),
5859
});
5960

6061
export type Config = z.infer<typeof InfraConfigSchema>;
@@ -72,6 +73,7 @@ console.error(
7273

7374
export const infraConfig = fullConfig.infra;
7475
export const monitoringConfig = fullConfig.monitoring;
76+
export const extraCustomResourcesConfig = fullConfig.extraCustomResources;
7577

7678
type IpRangesDict = { [key: string]: IpRangesDict } | string[];
7779

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import * as k8s from '@pulumi/kubernetes';
2+
3+
export function installExtraCustomResources(
4+
extraCrs: Record<string, k8s.apiextensions.CustomResourceArgs>
5+
): void {
6+
Object.entries(extraCrs).forEach(([name, spec]) => {
7+
new k8s.apiextensions.CustomResource(name, spec);
8+
});
9+
}

cluster/pulumi/infra/src/index.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,13 @@ import { config } from 'splice-pulumi-common';
55

66
import { clusterIsResetPeriodically, enableAlerts } from './alertings';
77
import { configureAuth0 } from './auth0';
8-
import { clusterBaseDomain, clusterBasename, monitoringConfig } from './config';
8+
import {
9+
clusterBaseDomain,
10+
clusterBasename,
11+
extraCustomResourcesConfig,
12+
monitoringConfig,
13+
} from './config';
14+
import { installExtraCustomResources } from './extraCustomResources';
915
import {
1016
getNotificationChannel,
1117
installCloudSQLMaintenanceUpdateAlerts,
@@ -40,6 +46,8 @@ istioMonitoring(network.ingressNs, []);
4046

4147
configureStorage();
4248

49+
installExtraCustomResources(extraCustomResourcesConfig);
50+
4351
let configuredAuth0;
4452
if (config.envFlag('CLUSTER_CONFIGURE_AUTH0', true)) {
4553
configuredAuth0 = configureAuth0(clusterBasename, network.dnsNames);

0 commit comments

Comments
 (0)