@activatedio/cdktf-google
Version:
TypeScript library for CDKTF for google
120 lines • 4.85 kB
JavaScript
;
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.Cluster = void 0;
const constructs_1 = require("constructs");
const google = __importStar(require("@cdktf/provider-google"));
class Cluster extends constructs_1.Construct {
serviceAccount;
cluster;
constructor(scope, id, props) {
super(scope, id);
const subnetwork = new google.dataGoogleComputeSubnetwork.DataGoogleComputeSubnetwork(this, 'subnetwork', {
project: props.networkHostProject,
name: props.subnetwork,
});
this.serviceAccount = new google.serviceAccount.ServiceAccount(this, 'serviceAccount', {
accountId: `cluster-${props.name}`,
displayName: `Cluster ${props.name}`,
});
this.cluster = new google.containerCluster.ContainerCluster(this, 'cluster', {
name: props.name,
removeDefaultNodePool: true,
initialNodeCount: 1,
enableL4IlbSubsetting: true,
nodeLocations: props.defaultNodeLocations,
nodeConfig: {
tags: [`gke-${props.name}-default`],
},
workloadIdentityConfig: {
workloadPool: `${props.project}.svc.id.goog`,
},
gatewayApiConfig: {
channel: 'CHANNEL_STANDARD',
},
privateClusterConfig: {
enablePrivateEndpoint: true,
enablePrivateNodes: true,
masterIpv4CidrBlock: props.masterCidr,
},
ipAllocationPolicy: {
clusterSecondaryRangeName: props.clusterSecondarySubnetName,
servicesSecondaryRangeName: props.servicesSecondarySubnetName,
},
masterAuthorizedNetworksConfig: {
gcpPublicCidrsAccessEnabled: false,
cidrBlocks: props.allowedAccessCidrs.map((c, i) => {
return {
cidrBlock: c,
displayName: `net=${i}`,
};
}),
},
network: subnetwork.network,
subnetwork: subnetwork.selfLink,
lifecycle: {
ignoreChanges: ['node_config'],
},
});
props.nodePools.forEach(np => {
new google.containerNodePool.ContainerNodePool(this, `nodePool_${np.name}`, {
name: np.name,
cluster: this.cluster.name,
nodeLocations: np.nodeLocations,
initialNodeCount: 1,
autoscaling: {
maxNodeCount: np.maxZoneCount,
minNodeCount: np.minZoneCount,
totalMaxNodeCount: np.maxTotalCount,
totalMinNodeCount: np.minTotalCount,
locationPolicy: 'BALANCED',
},
nodeConfig: {
workloadMetadataConfig: {
mode: 'GKE_METADATA',
},
preemptible: np.preemptible,
machineType: np.machineType,
serviceAccount: this.serviceAccount.email,
oauthScopes: ['https://www.googleapis.com/auth/cloud-platform'],
taint: np.taints,
tags: [`gke-${props.name}-${np.name}`],
},
});
});
}
}
exports.Cluster = Cluster;
//# sourceMappingURL=cluster.js.map