https://pulumi.com logo
#aws
Title
# aws
f

fierce-terabyte-6114

01/09/2024, 6:25 PM
anyone using pulumi-eks to deploy a cluster? it seems like pulumi just hangs forever during the preview stage whenever
SkipDefaultNodeGroup: true
, but when i let it create the default node group, the nodes never join the cluster
s

salmon-account-74572

01/09/2024, 11:26 PM
I've used
pulumi-eks
fairly extensively, but I don't generally skip the default node group. Which language are you using? And what version of
pulumi-eks
? Also, are you able to share the relevant portions of your code?
f

fierce-terabyte-6114

01/10/2024, 12:26 AM
im doing this in go, latest version of pulumi-eks. i believe i may have found the issues, although pulumi was not very helpful in that regard
looks like using
pulumi.Parent(eksCluster)
makes pulumi hang
so when i was trying to create my own nodegroup, it would just hang
essentially like this:
Copy code
eksCluster, err := eks.NewCluster(ctx, "eks-cluster", &eks.ClusterArgs{
	VpcId:                        eksVpc.VpcId,
	PublicSubnetIds:              eksVpc.PublicSubnetIds,
	PrivateSubnetIds:             eksVpc.PrivateSubnetIds,
	NodeAssociatePublicIpAddress: pulumi.BoolRef(false),
	EndpointPrivateAccess:        pulumi.Bool(false),
	EndpointPublicAccess:         pulumi.Bool(true),
	CreateOidcProvider:           pulumi.Bool(true),
	SkipDefaultNodeGroup:         pulumi.BoolRef(true),
	Tags: pulumi.StringMap{
		"Owner": pulumi.String("pulumi"),
	},
})
if err != nil {
	return err
}

_, err = eks.NewNodeGroupV2(ctx, "initial-node-group", &eks.NodeGroupV2Args{
	Cluster:                      eksCluster.Core,
	Version:                      pulumi.String("1.28"),
	InstanceType:                 pulumi.String(eksNodeInstanceType),
	DesiredCapacity:              <http://pulumi.Int|pulumi.Int>(desiredClusterSize),
	MinSize:                      <http://pulumi.Int|pulumi.Int>(minClusterSize),
	MaxSize:                      <http://pulumi.Int|pulumi.Int>(maxClusterSize),
	NodeSubnetIds:                eksCluster.Core.PrivateSubnetIds(),
	NodeRootVolumeSize:           <http://pulumi.Int|pulumi.Int>(30),
	NodeAssociatePublicIpAddress: pulumi.BoolRef(false),
	//Taints: map[string]eks.TaintArgs{
	//	"@TODO PLACEHOLDER": {Effect: "NoSchedule"},
	//},
	CloudFormationTags: pulumi.StringMap{
		"Owner": pulumi.String("pulumi"),
	},
}, pulumi.Parent(eksCluster))
if err != nil {
	return err
}
s

salmon-account-74572

01/10/2024, 4:09 PM
Ah, gotcha. And removing
pulumi.Parent(eksCluster))
fixes the hang, is that right?
f

fierce-terabyte-6114

01/10/2024, 4:10 PM
yeah thats right
by the way, is there anyway to convert a
pulumi.StringOutput
to be a regular string that i can use elsewhere? I know
ApplyT
exists, but it seems like i cant access the string outside of that
s

salmon-account-74572

01/10/2024, 4:12 PM
No, unfortunately. You have to use it in an
ApplyT
. What are you trying to accomplish?
f

fierce-terabyte-6114

01/10/2024, 4:15 PM
i am trying to deploy the cilium helm chart, but i have a few optional values that need to be passed in. I'd like to do something like this:
Copy code
b, err := os.ReadFile("k8s/values/ciliumValues.yaml.tmpl")
	if err != nil {
		return err
	}
	ciliumValuesTemplate := string(b)

	ciliumValues, err := renderValues(ciliumValuesTemplate, ciliumArgs)
	if err != nil {
		return err
	}
where
ciliumValues
is returned as a
pulumi.Map
, but if
ciliumArgs
isn't just strings, that seems hard to accomplish. inside
renderValues
it is using go templating on a yaml file
s

salmon-account-74572

01/10/2024, 4:34 PM
Sorry if this is a dumb question, but where is
ciliumArgs
coming from? Where or how it is defined?
f

fierce-terabyte-6114

01/10/2024, 4:37 PM
its a
map[string]interface{}
. it is defined near the top with a value that is static right now, and then i want to add two things from pulumi outputs - my eks apiserver endpoint and the arn for an iam role i created
its essentially like this:
Copy code
ciliumArgs := map[string]interface{}{
		"isEks": isEks,
}
if isEks {
... create iam role, get eks api server
ciliumArgs["apiServer"] = apiServer
ciliumArgs["roleArn"] = roleArn
}
... deploy cilium using the values template + ciliumArgs
its like that because if i am deploying this into something that is NOT eks, i dont need the iam role, and i would be getting the api server endpoint a different way
s

salmon-account-74572

01/10/2024, 5:13 PM
You could try using
pulumi.Sprintf
to get the resolved string values added to
ciliumArgs
. Frankly, I can’t say for sure if that will work, but that’s the next step I’d try.
f

fierce-terabyte-6114

01/10/2024, 5:15 PM
looks like that also just returns
StringOutput
s

salmon-account-74572

01/10/2024, 5:16 PM
😕
f

fierce-terabyte-6114

01/10/2024, 5:37 PM
this seems incredibly over-complicated 😕 even doing something like terraform's
templatefile()
is very difficult
s

salmon-account-74572

01/10/2024, 6:48 PM
In the spirit of transparency/honesty, Go's strict type system makes things a tad more complicated (it's quite likely this would be easier in TypeScript).
f

fierce-terabyte-6114

01/10/2024, 7:49 PM
that does not make me feel better haha
i think i have it working using a combination of
All
and
ApplyT
s

salmon-account-74572

01/10/2024, 9:14 PM
Excellent, that's good to hear! I'd love to see your final code, if you're able to share (the relevant portions, of course).
f

fierce-terabyte-6114

01/10/2024, 9:18 PM
its very remedial, but this works:
Copy code
pulumi.All(role.Arn, cluster.Core.Endpoint()).ApplyT(func(args []interface{}) error {
	ciliumArgs["roleArn"] = args[0].(string)
	ciliumArgs["apiEndpoint"] = strings.TrimPrefix(args[1].(string), "https://")

	b, err := os.ReadFile("k8s/values/ciliumValues.yaml.tmpl")
	if err != nil {
		return err
	}
	ciliumValuesTemplate := string(b)

	ciliumValues, err := renderValues(ciliumValuesTemplate, ciliumArgs)
	if err != nil {
		return err
	}

	_, err = helmv3.NewRelease(ctx, "cilium", &helmv3.ReleaseArgs{
		Name:      pulumi.String("cilium"),
		Chart:     pulumi.String("cilium"),
		Namespace: pulumi.String("kube-system"),
		Version:   pulumi.String("1.14.5"),
		RepositoryOpts: &helmv3.RepositoryOptsArgs{
			Repo: pulumi.String("<https://helm.cilium.io/>"),
		},
		Values: ciliumValues,
	}, pulumi.Provider(k8sProvider))
	if err != nil {
		return err
	}
	return err
})
s

salmon-account-74572

01/10/2024, 9:27 PM
Thanks for sharing your solution!