polite-rainbow-37545
11/27/2022, 7:02 AMimport pulumi
import pulumi_aws as aws
import pulumi_eks as eks
# Get some values from the Pulumi configuration (or use defaults)
config = pulumi.Config()
min_cluster_size = config.get_float("minClusterSize", 3)
max_cluster_size = config.get_float("maxClusterSize", 6)
desired_cluster_size = config.get_float("desiredClusterSize", 3)
eks_node_instance_type = config.get("eksNodeInstanceType", "t2.medium")
eks_vpc = aws.ec2.Vpc.get("<mydefaultVPC", "<vpc-ID>") # reusing an existing VPC
public_subnet_ids = aws.ec2.get_subnets([
{
'name': 'vpc-id',
'values': [eks_vpc.id]
},
{
'name': 'subnet-id',
'values': ['subnet-xxxxxxx', 'subnet-xxxxxx']
}
])
private_subnet_ids = aws.ec2.get_subnets([
{
'name': 'vpc-id',
'values': [eks_vpc.id]
},
{
'name': 'subnet-id',
'values': ['subnet-xxxxxxxxxxxxxxxxx', 'subnet-xxxxxxxxxxxxxxx']
}
])
eks_cluster = eks.Cluster("eks-cluster",
# Put the cluster in the new VPC created earlier
vpc_id=eks_vpc.id,
# Public subnets will be used for load balancers
public_subnet_ids=public_subnet_ids.ids,
# Private subnets will be used for cluster nodes
private_subnet_ids=private_subnet_ids.ids,
desired_capacity=desired_cluster_size,
max_size=max_cluster_size,
min_size=min_cluster_size,
)
pulumi.export("kubeconfig", eks_cluster.kubeconfig)
pulumi.export("vpcId", eks_vpc.id)
pulumi.export("aws_provider", eks_cluster.aws_provider)
pulumi.export("name", eks_cluster.eks_cluster.id)
pulumi.export("default_node_group", eks_cluster.default_node_group)
billowy-army-68599
polite-rainbow-37545
11/28/2022, 7:33 AMeksctl create cluster
command, the nodegroups join the cluster without any problem.