crooked-lunch-29479
04/15/2023, 10:13 PMsteep-toddler-94095
04/15/2023, 10:17 PMcrooked-lunch-29479
04/15/2023, 10:20 PMfunc createEKSSecurityGroup(ctx *pulumi.Context, vpc *ec2.LookupVpcResult) (*ec2.SecurityGroup, error) {
// Create a Security Group that we can use to actually connect to our cluster
clusterSg, err := ec2.NewSecurityGroup(ctx, "cluster-sg", &ec2.SecurityGroupArgs{
VpcId: pulumi.String(vpc.Id),
Egress: ec2.SecurityGroupEgressArray{
ec2.SecurityGroupEgressArgs{
Protocol: pulumi.String("-1"),
FromPort: <http://pulumi.Int|pulumi.Int>(0),
ToPort: <http://pulumi.Int|pulumi.Int>(0),
CidrBlocks: pulumi.StringArray{pulumi.String("0.0.0.0/0")},
},
},
Ingress: ec2.SecurityGroupIngressArray{
ec2.SecurityGroupIngressArgs{
Protocol: pulumi.String("tcp"),
FromPort: <http://pulumi.Int|pulumi.Int>(80),
ToPort: <http://pulumi.Int|pulumi.Int>(80),
CidrBlocks: pulumi.StringArray{pulumi.String("0.0.0.0/0")},
},
},
})
if err != nil {
return nil, err
}
return clusterSg, nil
}
Here’s what I’ve got for the EKS cluster creation:
// Create an EKS cluster
eksCluster, err := eks.NewCluster(ctx, "eks-flyte-cluster", &eks.ClusterArgs{
RoleArn: pulumi.StringInput(eksClusterRole.Arn),
VpcConfig: &eks.ClusterVpcConfigArgs{
PublicAccessCidrs: pulumi.StringArray{
pulumi.String("0.0.0.0/0"),
},
SecurityGroupIds: pulumi.StringArray{
securityGroup.ID().ToStringOutput(),
},
SubnetIds: toPulumiStringArray(subnets.Ids),
},
})
if err != nil {
return nil, err
}
// Create the EKS Node Group
// TODO - We need to update the scaling capabilities as a new argument to the function and make it user definable
nodeGroupName := "fyte-eks-nodegroup-primary"
_, err = eks.NewNodeGroup(ctx, nodeGroupName, &eks.NodeGroupArgs{
ClusterName: eksCluster.Name,
NodeGroupName: pulumi.String(nodeGroupName),
NodeRoleArn: pulumi.StringInput(nodeGroupRole.Arn),
SubnetIds: toPulumiStringArray(subnets.Ids),
ScalingConfig: &eks.NodeGroupScalingConfigArgs{
DesiredSize: <http://pulumi.Int|pulumi.Int>(5),
MaxSize: <http://pulumi.Int|pulumi.Int>(5),
MinSize: <http://pulumi.Int|pulumi.Int>(2),
},
// Currently fixing the AMI to the latest Amazon Linux 2 AMI
AmiType: pulumi.String("AL2_x86_64"),
// TODO - Figure out how we need to setup the instance sizes
InstanceTypes: pulumi.StringArray{
pulumi.String("t2.nano"), // Replace with your desired instance type(s)
},
// TODO - Add SSH Key
// RemoteAccess: &eks.NodeGroupRemoteAccessArgs{
// Ec2SshKey: pulumi.String("my-ssh-key"), // Replace with your desired SSH key name
// },
})
if err != nil {
return nil, err
}
ctx.Export("kubeconfig", generateKubeconfig(eksCluster.Endpoint,
eksCluster.CertificateAuthority.Data().Elem(), eksCluster.Name))
return eksCluster, nil
steep-toddler-94095
04/15/2023, 11:18 PM0.0.0.0/0
crooked-lunch-29479
04/15/2023, 11:30 PMsteep-toddler-94095
04/15/2023, 11:37 PM0.0.0.0/0
ingress is generally not recommended for a publicly accessible cluster for security reasons, but it depends on what you're using it for. if it's just a personal test cluster it might be fine.crooked-lunch-29479
04/15/2023, 11:42 PMsteep-toddler-94095
04/16/2023, 12:07 AMcrooked-lunch-29479
04/16/2023, 12:09 AM