gorgeous-fountain-6076
05/02/2024, 6:39 PMself.eks_cluster = eks.Cluster()
pulumi.export('eks_cluster', self.eks_cluster)
From a different stack I am trying to get the cluster object to create ManagedNodeGroups
eks_cluster: eks.Cluster = infrastructure.get_output("eks_cluster")
It gives me this error. It only returns a dict object.
AttributeError: 'dict' object has no attribute 'urn'
Is is possible to get the exported values as Objects and can be casted? any thoughts?modern-zebra-45309
05/03/2024, 3:49 PMeks.Cluster()
component resource. You can only export values. There is also no equivalent to aws.eks.getCluster()
(docs) for the pulumi_eks module, see this issue.
What you can do, however, is using aws.eks.NodeGroup
(docs) to add node groups to your cluster. This only requires the cluster's name and will also create what EKS calls a managed node group.
You can see in the source code that eks.ManagedNodeGroup
wraps aws.eks.NodeGroup
and doesn't do a whole lot more, aside from reading some details from the eks.Cluster
resource rather than you having to pass them explicitly.gorgeous-fountain-6076
05/03/2024, 5:48 PMmodern-zebra-45309
05/03/2024, 5:56 PMaws.eks.NodeGroup
, both ami_type
and release_version
are optional parameters. This is exactly the same as for eks.ManagedNodeGroup
, which simply passes these parameters down to the underlying aws.eks.NodeGroup
resource (here). The naming is unfortunately really misleading, you'll get the exact same kind of managed node group in both cases.gorgeous-fountain-6076
05/03/2024, 6:14 PMmodern-zebra-45309
05/03/2024, 6:17 PMgorgeous-fountain-6076
05/04/2024, 8:09 PMpulumi.export('kubeconfig', self.eks_cluster.kubeconfig)
and then while deploying the helm chart on a different stack using the Stack reference to get this value and add a new provider:
StackReference( stack_name = f"organization/core/{get_stack()}"
)
eks_kubeconfig = _sync_await(infrastructure.get_output_details("kubeconfig")).value
eks_cluster_provider = Provider(
cluster = f"{get_stack()}-{subsystem_name}-core-{name}-cluster",
kubeconfig = eks_kubeconfig
)
In the helm chart Release I am passing the following option:
opts = pulumi.ResourceOptions(
provider = eks_cluster_provider
)
gorgeous-fountain-6076
05/04/2024, 8:13 PMcan't create Helm Release with unreachable cluster: unable to load Kubernetes client configuration from kubeconfig file. Make sure you have:
• set up the provider as per <https://www.pulumi.com/registry/packages/kubernetes/installation-configuration/>
gorgeous-fountain-6076
05/04/2024, 8:13 PMmodern-zebra-45309
05/05/2024, 10:12 AMimport pulumi
import pulumi_eks as eks
import pulumi_kubernetes as k8s
# first program
cluster = eks.Cluster(...)
pulumi.export("kubeconfig", cluster.kubeconfig)
# second program
first_stack = pulumi.StackReference(...)
k8s_provider = k8s.Provider("k8s-provider", kubeconfig=first_stack.get_output("kubeconfig"))
Hope that helps!