pulumi-eks
pulumi-eks copied to clipboard
eks namespace with provider in python not working, but eks namespace with provider in typescript works.
Hello!
- Vote on this issue by adding a 👍 reaction
- To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already)
Issue details
EKS with typescript and having a namespace works.
EKS with python and having a namespace configured almost the exact same way, doesn't pass pulumi preview. The following error message is thrown in python:
raise ValueError(
ValueError: Attempted to register resource kubernetes:core/v1:Namespace with a provider for '<pulumi.output.Output object at 0x10c216700>'
Steps to reproduce
- Validate the eks stack works in typescript
git clone [email protected]:tusharshahrs/pulumi-home.gitcd aws-classic-ts-eks pulumi aboutin typescript stack
pulumi about
CLI
Version 3.24.1
Go Version go1.17.6
Go Compiler gc
Plugins
NAME VERSION
aws 4.37.2
eks 0.37.0
kubernetes 3.15.1
nodejs unknown
Host
OS darwin
Version 11.6.3
Arch x86_64
..
..
Backend
Name pulumi.com
URL https://app.pulumi.com/myuser
User myuser
NAME VERSION
@pulumi/eks 0.37.0
@pulumi/kubernetes 3.15.1
@pulumi/pulumi 3.24.1
@types/node 14.18.10
This project is written in nodejs (/usr/local/bin/node v17.4.0)
- Stand up the stack in
typescriptpulumi stack init devnpm installpulumi config set aws:region us-east-2pulumi up -yWait ~12 minutes and thenamespacewill get created. The output will show it - Everything works in
typescript. - Try to stand up the eks stack in python
git clone [email protected]:tusharshahrs/pulumi-home.gitcd aws-classic-py-eks pulumi aboutin python stack
CLI
Version 3.24.1
Go Version go1.17.6
Go Compiler gc
Plugins
NAME VERSION
aws 4.37.2
eks 0.37.0
kubernetes 3.15.2
python unknown
Host
OS darwin
Version 11.6.3
Arch x86_64
This project is written in python (/usr/local/bin/python3 v3.9.10)
Current Stack: dev
Backend
Name pulumi.com
URL https://app.pulumi.com/myuser
User myuser
NAME VERSION
pip 22.0.3
pulumi-eks 0.37.0
setuptools 60.8.2
wheel 0.37.1
- Stand up the stack in
pythonpulumi stack init devpython3 -m venv venvsource venv/bin/activatepip3 install -r requirements.txtpulumi config set aws:region us-east-2 - Uncomment aws_ns_broken
- Run
pulumi upand thepreviewwill fail with:raise ValueError( ValueError: Attempted to register resource kubernetes:core/v1:Namespace with a provider for '<pulumi.output.Output object at 0x10c216700>' - We have a workaround, meaning we can comment OUT the last line.
- Question. Should a user expect the
pythoncode for namespace to work similar as typescript or this expected behavior in python?
Expected: Eks with namespace in python works the same as eks with namespace in typescript.
Actual: Python throws this error on preview:
raise ValueError(
ValueError: Attempted to register resource kubernetes:core/v1:Namespace with a provider for '<pulumi.output.Output object at
0x10c216700>'
The main problem is that the ResourceOptions' provider arg doesn't yet accept Output[ProviderResource], which is tracked by https://github.com/pulumi/pulumi/issues/7012.
In the meantime, this can be worked around by creating a new instance of the pulumi_kubernetes.Provider using the Cluster's kubeconfig output:
import json
from pulumi import ResourceOptions
from pulumi_eks import Cluster
from pulumi_kubernetes import Provider
from pulumi_kubernetes.core.v1 import Namespace
cluster = Cluster("test")
provider = Provider("eks-k8s", kubeconfig=cluster.kubeconfig.apply(lambda k: json.dumps(k)))
namespace = Namespace("test", opts=ResourceOptions(provider=provider))
Since the Cluster.provider output isn't really usable currently given https://github.com/pulumi/pulumi/issues/7012, we're considering removing it: https://github.com/pulumi/pulumi-eks/issues/602.
Linking to this ticket or stating the workaround in the docs for the Cluster.provider attribute (and ideally the Namespace too) would be a great help, as long as this issue remains.
The provider output property was removed in https://github.com/pulumi/pulumi-eks/pull/746
Closing this issue as complete but have created a new issue to capture adding a helpful example to the docs: https://github.com/pulumi/pulumi-eks/issues/812