File tree Expand file tree Collapse file tree 5 files changed +149
-0
lines changed
Expand file tree Collapse file tree 5 files changed +149
-0
lines changed Original file line number Diff line number Diff line change @@ -117,3 +117,30 @@ svs:
117117 kms :
118118 keyRingId : sv-3_participant_mock
119119 locationId : us-central1
120+ infra :
121+ extraCustomResources :
122+ deny-onboard-prepare-endpoint :
123+ apiVersion : security.istio.io/v1
124+ kind : AuthorizationPolicy
125+ metadata :
126+ name : deny-onboard-prepare-endpoint
127+ # if we pass a list here, pulumi will multiply the CR for us
128+ namespace : [ sv-1, sv-2 ]
129+ spec :
130+ selector :
131+ matchLabels :
132+ app : sv-app
133+ action : DENY
134+ rules :
135+ - to :
136+ - operation :
137+ paths : ["/api/sv/v0/devnet/onboard/validator/prepare"]
138+ mock-cr :
139+ apiVersion : mock.example.com/v1
140+ kind : MockResource
141+ metadata :
142+ name : mock-resource
143+ namespace : validator1
144+ spec :
145+ key : value
146+ anotherKey : anotherValue
Original file line number Diff line number Diff line change 20472047 "provider": "",
20482048 "type": "command:local:Command"
20492049 },
2050+ {
2051+ "custom": true,
2052+ "id": "",
2053+ "inputs": {
2054+ "apiVersion": "mock.example.com/v1",
2055+ "kind": "MockResource",
2056+ "metadata": {
2057+ "name": "mock-resource",
2058+ "namespace": "validator1"
2059+ },
2060+ "spec": {
2061+ "anotherKey": "anotherValue",
2062+ "key": "value"
2063+ }
2064+ },
2065+ "name": "mock-cr",
2066+ "provider": "",
2067+ "type": "kubernetes:mock.example.com/v1:MockResource"
2068+ },
20502069 {
20512070 "custom": true,
20522071 "id": "",
29282947 "provider": "",
29292948 "type": "kubernetes:core/v1:Secret"
29302949 },
2950+ {
2951+ "custom": true,
2952+ "id": "",
2953+ "inputs": {
2954+ "apiVersion": "security.istio.io/v1",
2955+ "kind": "AuthorizationPolicy",
2956+ "metadata": {
2957+ "name": "deny-onboard-prepare-endpoint",
2958+ "namespace": "sv-1"
2959+ },
2960+ "spec": {
2961+ "action": "DENY",
2962+ "rules": [
2963+ {
2964+ "to": [
2965+ {
2966+ "operation": {
2967+ "paths": [
2968+ "/api/sv/v0/devnet/onboard/validator/prepare"
2969+ ]
2970+ }
2971+ }
2972+ ]
2973+ }
2974+ ],
2975+ "selector": {
2976+ "matchLabels": {
2977+ "app": "sv-app"
2978+ }
2979+ }
2980+ }
2981+ },
2982+ "name": "sv-1-deny-onboard-prepare-endpoint",
2983+ "provider": "",
2984+ "type": "kubernetes:security.istio.io/v1:AuthorizationPolicy"
2985+ },
2986+ {
2987+ "custom": true,
2988+ "id": "",
2989+ "inputs": {
2990+ "apiVersion": "security.istio.io/v1",
2991+ "kind": "AuthorizationPolicy",
2992+ "metadata": {
2993+ "name": "deny-onboard-prepare-endpoint",
2994+ "namespace": "sv-2"
2995+ },
2996+ "spec": {
2997+ "action": "DENY",
2998+ "rules": [
2999+ {
3000+ "to": [
3001+ {
3002+ "operation": {
3003+ "paths": [
3004+ "/api/sv/v0/devnet/onboard/validator/prepare"
3005+ ]
3006+ }
3007+ }
3008+ ]
3009+ }
3010+ ],
3011+ "selector": {
3012+ "matchLabels": {
3013+ "app": "sv-app"
3014+ }
3015+ }
3016+ }
3017+ },
3018+ "name": "sv-2-deny-onboard-prepare-endpoint",
3019+ "provider": "",
3020+ "type": "kubernetes:security.istio.io/v1:AuthorizationPolicy"
3021+ },
29313022 {
29323023 "custom": true,
29333024 "id": "",
Original file line number Diff line number Diff line change @@ -53,6 +53,7 @@ export const InfraConfigSchema = z.object({
5353 istio : z . object ( {
5454 enableIngressAccessLogging : z . boolean ( ) ,
5555 } ) ,
56+ extraCustomResources : z . object ( { } ) . catchall ( z . any ( ) ) . default ( { } ) ,
5657 } ) ,
5758 monitoring : MonitoringConfigSchema ,
5859} ) ;
Original file line number Diff line number Diff line change 1+ // Copyright (c) 2024 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2+ // SPDX-License-Identifier: Apache-2.0
3+ import * as k8s from '@pulumi/kubernetes' ;
4+
5+ import { infraConfig } from './config' ;
6+
7+ // Automatically duplicates CRs if multiple namespaces given
8+ export function installExtraCustomResources ( ) : void {
9+ const extraCrs = infraConfig . extraCustomResources ;
10+ Object . entries ( extraCrs ) . forEach ( ( [ name , spec ] ) => {
11+ if ( Array . isArray ( spec . metadata ?. namespace ) ) {
12+ spec . metadata . namespace . forEach ( ( ns : string ) => {
13+ const patchedName = `${ ns } -${ name } ` ;
14+ const patchedSpec = {
15+ ...spec ,
16+ metadata : {
17+ ...spec . metadata ,
18+ namespace : ns ,
19+ } ,
20+ } ;
21+ new k8s . apiextensions . CustomResource ( patchedName , patchedSpec ) ;
22+ } ) ;
23+ } else {
24+ new k8s . apiextensions . CustomResource ( name , spec ) ;
25+ }
26+ } ) ;
27+ }
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import { config } from 'splice-pulumi-common';
66import { clusterIsResetPeriodically , enableAlerts } from './alertings' ;
77import { configureAuth0 } from './auth0' ;
88import { clusterBaseDomain , clusterBasename , monitoringConfig } from './config' ;
9+ import { installExtraCustomResources } from './extraCustomResources' ;
910import {
1011 getNotificationChannel ,
1112 installCloudSQLMaintenanceUpdateAlerts ,
@@ -40,6 +41,8 @@ istioMonitoring(network.ingressNs, []);
4041
4142configureStorage ( ) ;
4243
44+ installExtraCustomResources ( ) ;
45+
4346let configuredAuth0 ;
4447if ( config . envFlag ( 'CLUSTER_CONFIGURE_AUTH0' , true ) ) {
4548 configuredAuth0 = configureAuth0 ( clusterBasename , network . dnsNames ) ;
You can’t perform that action at this time.
0 commit comments