1. Get an existing EKS cluster's kubeconfig and create a pulumi_kubernetes Provider from it

    Python

    In order to fetch the kubeconfig from an existing EKS cluster, we can utilize the eks.Cluster class with the get method. This will allow us to reference the EKS cluster within our Pulumi program. From there, we can retrieve the kubeconfig using getKubeconfig.

    After we have fetched kubeconfig, we provide it to pulumi_kubernetes.Provider to generate a kubernetes provider.

    Here's a starting point for your Pulumi program:

    import pulumi from pulumi_aws import eks from pulumi_kubernetes import Provider # Get an existing EKS Cluster by its cluster name. # Replace cluster_name with the real name. cluster = eks.Cluster.get("existing_cluster", "cluster_name") # Get kubeconfig of the existing cluster cluster_kubeconfig = cluster.get_kubeconfig() # Create a Kubernetes provider instance using the kubeconfig obtained from the EKS cluster k8s_provider = Provider("k8s-provider", kubeconfig=cluster_kubeconfig) # export the kubeconfig pulumi.export("kubeconfig", cluster_kubeconfig)

    The first part of the script retrieves an existing EKS Cluster given its name, and the second part generates a kubeconfig. The kubeconfig is then used to create a new Kubernetes provider instance.

    For more information, refer to the following resources in the Pulumi Registry: