diff --git a/examples/cluster-py/__main__.py b/examples/cluster-py/__main__.py index a3c822f6d..4a28993ae 100644 --- a/examples/cluster-py/__main__.py +++ b/examples/cluster-py/__main__.py @@ -13,34 +13,51 @@ # TODO specify tags: { "Name": f"{project_name}-2" } vpc = Vpc(f"{project_name}-2") -cluster2 = eks.Cluster('eks-cluster', - vpc_id=vpc.vpc_id, - public_subnet_ids=vpc.public_subnet_ids, - public_access_cidrs=['0.0.0.0/0'], - desired_capacity=2, - min_size=2, - max_size=2, - instance_type='t3.micro', - # set storage class. - storage_classes={"gp2": eks.StorageClassArgs( - type='gp2', allow_volume_expansion=True, default=True, encrypted=True,)}, - enabled_cluster_log_types=[ - "api", - "audit", - "authenticator", - ],) - -cluster3 = eks.Cluster(f"{project_name}-3", - vpc_id=vpc.vpc_id, - public_subnet_ids=vpc.public_subnet_ids, - node_group_options=eks.ClusterNodeGroupOptionsArgs( - desired_capacity=1, - min_size=1, - max_size=1, - instance_type="t3.small" - ) +cluster2 = eks.Cluster( + "eks-cluster", + vpc_id=vpc.vpc_id, + public_subnet_ids=vpc.public_subnet_ids, + public_access_cidrs=["0.0.0.0/0"], + desired_capacity=2, + min_size=2, + max_size=2, + instance_type="t3.micro", + # set storage class. + storage_classes={ + "gp2": eks.StorageClassArgs( + type="gp2", + allow_volume_expansion=True, + default=True, + encrypted=True, + ) + }, + enabled_cluster_log_types=[ + "api", + "audit", + "authenticator", + ], ) +cluster3 = eks.Cluster( + f"{project_name}-3", + vpc_id=vpc.vpc_id, + public_subnet_ids=vpc.public_subnet_ids, + node_group_options=eks.ClusterNodeGroupOptionsArgs( + desired_capacity=1, min_size=1, max_size=1, instance_type="t3.small" + ), +) + +########################## +### EKS Addons ### +########################## + +coredns = eks.Addon( + f"{project_name}-cluster3-coredns", + cluster=cluster3, + addon_name="coredns", + addon_version="v1.11.1-eksbuild.9", + resolve_conflicts_on_update="PRESERVE", +) # Export the clusters' kubeconfig. diff --git a/examples/cluster/index.ts b/examples/cluster/index.ts index 4a0dacc19..7fa64fb02 100644 --- a/examples/cluster/index.ts +++ b/examples/cluster/index.ts @@ -4,50 +4,62 @@ import * as eks from "@pulumi/eks"; const projectName = pulumi.getProject(); -// Create an EKS cluster with the default configuration. -const cluster1 = new eks.Cluster(`${projectName}-1`); - // Create an EKS cluster with a non-default configuration. const vpc = new awsx.ec2.Vpc(`${projectName}-2`, { - tags: {"Name": `${projectName}-2`}, + tags: { Name: `${projectName}-2` }, }); +//////////////////////////// +/// EKS Clusters /// +//////////////////////////// + +// Create an EKS cluster with the default configuration. +const cluster1 = new eks.Cluster(`${projectName}-1`); + const cluster2 = new eks.Cluster(`${projectName}-2`, { - vpcId: vpc.vpcId, - publicSubnetIds: vpc.publicSubnetIds, - desiredCapacity: 2, - minSize: 2, - maxSize: 2, - deployDashboard: false, - enabledClusterLogTypes: [ - "api", - "audit", - "authenticator", - ], - vpcCniOptions: { - disableTcpEarlyDemux: true, - }, + vpcId: vpc.vpcId, + publicSubnetIds: vpc.publicSubnetIds, + desiredCapacity: 2, + minSize: 2, + maxSize: 2, + deployDashboard: false, + enabledClusterLogTypes: ["api", "audit", "authenticator"], + vpcCniOptions: { + disableTcpEarlyDemux: true, + }, }); const cluster3 = new eks.Cluster(`${projectName}-3`, { - vpcId: vpc.vpcId, - publicSubnetIds: vpc.publicSubnetIds, - nodeGroupOptions: { - desiredCapacity: 1, - minSize: 1, - maxSize: 1, - instanceType: "t3.small", - enableDetailedMonitoring: false, - } -}) + vpcId: vpc.vpcId, + publicSubnetIds: vpc.publicSubnetIds, + nodeGroupOptions: { + desiredCapacity: 1, + minSize: 1, + maxSize: 1, + instanceType: "t3.small", + enableDetailedMonitoring: false, + }, +}); // cluster4 is a graviton cluster to test the ARM64 architecture // can be successfully provisioned. const cluster4 = new eks.Cluster(`${projectName}-4`, { - vpcId: vpc.vpcId, - publicSubnetIds: vpc.publicSubnetIds, - instanceType: "t4g.small", -}) + vpcId: vpc.vpcId, + publicSubnetIds: vpc.publicSubnetIds, + instanceType: "t4g.small", +}); + +////////////////////////// +/// EKS Addons /// +////////////////////////// + +// Test that we can create a coredns addon within cluster3. +const coredns = new eks.Addon("coredns", { + cluster: cluster3, + addonName: "coredns", + addonVersion: "v1.11.1-eksbuild.9", + resolveConflictsOnUpdate: "PRESERVE", +}); // Export the clusters' kubeconfig. export const kubeconfig1 = cluster1.kubeconfig; @@ -56,4 +68,4 @@ export const kubeconfig3 = cluster3.kubeconfig; export const kubeconfig4 = cluster4.kubeconfig; // export the IAM Role ARN of the cluster -export const iamRoleArn = cluster1.core.clusterIamRole.arn; +export const iamRoleArn = cluster1.core.clusterIamRole.arn; \ No newline at end of file