Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eks namespace with provider in python not working, but eks namespace with provider in typescript works. #662

Closed
tusharshahrs opened this issue Feb 10, 2022 · 3 comments
Labels
kind/bug Some behavior is incorrect or out of spec resolution/wont-fix This issue won't be fixed

Comments

@tusharshahrs
Copy link

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

  1. Validate the eks stack works in typescript
    git clone [email protected]:tusharshahrs/pulumi-home.git
    cd aws-classic-ts-eks
  2. pulumi about in 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)
  1. Stand up the stack in typescript
    pulumi stack init dev
    npm install
    pulumi config set aws:region us-east-2
    pulumi up -y
    Wait ~12 minutes and the namespace will get created. The output will show it
  2. Everything works in typescript.
  3. Try to stand up the eks stack in python
    git clone [email protected]:tusharshahrs/pulumi-home.git
    cd aws-classic-py-eks
  4. pulumi about in 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
  1. Stand up the stack in python
    pulumi stack init dev
    python3 -m venv venv
    source venv/bin/activate
    pip3 install -r requirements.txt
    pulumi config set aws:region us-east-2
  2. Uncomment aws_ns_broken
  3. Run pulumi up and the preview will fail with:
    raise ValueError(
       ValueError: Attempted to register resource kubernetes:core/v1:Namespace with a provider for '<pulumi.output.Output object at 
    0x10c216700>'
    
  4. We have a workaround, meaning we can comment OUT the last line.
  5. Question. Should a user expect the python code 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>'
@tusharshahrs tusharshahrs added the kind/bug Some behavior is incorrect or out of spec label Feb 10, 2022
@justinvp
Copy link
Member

The main problem is that the ResourceOptions' provider arg doesn't yet accept Output[ProviderResource], which is tracked by pulumi/pulumi#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 pulumi/pulumi#7012, we're considering removing it: #602.

@markfickett
Copy link

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.

@danielrbradley
Copy link
Member

The provider output property was removed in #746

Closing this issue as complete but have created a new issue to capture adding a helpful example to the docs: #812

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug Some behavior is incorrect or out of spec resolution/wont-fix This issue won't be fixed
Projects
None yet
Development

No branches or pull requests

4 participants