https://pulumi.com logo
#kubernetes
Title
# kubernetes
k

kind-mechanic-53546

04/28/2021, 7:00 AM
That would be
... { metadata: { name: yournamehere,...
☝️ 1
p

purple-plumber-90981

04/28/2021, 7:05 AM
im in python in case this was not obvious . . . and i tried what i thought you meant but it does not work
Copy code
my_namespace = k8s.core.v1.Namespace("mynamespace", { metadata: { name: 'mynamespace'}} )
k

kind-mechanic-53546

04/28/2021, 7:06 AM
ah, sorry
half a sec
hmm, from my limited knowledge of python, that looks right
what's the error?
p

purple-plumber-90981

04/28/2021, 7:12 AM
Copy code
File "./__main__.py", line 216, in <module>
        my_namespace = k8s.core.v1.Namespace("mynamespace", {'name': 'mynamespace'}, opts=eks_opts)
      File "/Users/bmeehan/repos/itplat-pulumi-infrastructure/.venv/lib/python3.8/site-packages/pulumi_kubernetes/core/v1/Namespace.py", line 127, in __init__
        __self__._internal_init(resource_name, *args, **kwargs)
    TypeError: _internal_init() got multiple values for argument 'opts'
    error: an unhandled error occurred: Program exited with non-zero exit code: 1
so im having this problem all over the place in pul;umi, i know what i need to pass, but i cant figure out how to pass it
i got further with :-
Copy code
my_namespace = k8s.core.v1.Namespace("mynamespace", opts=eks_opts, **{ 'metadata': { 'name': 'mynamespace'}} )
k

kind-mechanic-53546

04/28/2021, 7:14 AM
should it be my_namespace = k8s.core.v1.Namespace("mynamespace", metadata: { name: 'mynamespace'} ) https://www.pulumi.com/docs/reference/pkg/kubernetes/core/v1/namespace/#objectmeta
p

purple-plumber-90981

04/28/2021, 7:14 AM
Copy code
Diagnostics:
  kubernetes:core/v1:Namespace (atlassian):
    error: unrecognized resource type (Check): kubernetes:core/v1:Namespace
would you believe `
Copy code
metadata=k8s.meta.v1.ObjectMetaArgs(name="mynamespace")
k

kind-mechanic-53546

04/28/2021, 7:21 AM
that makes sense Same syntax as scaling_config in https://github.com/pulumi/examples/blob/master/aws-py-eks/__main__.py
til some python 🙂
p

purple-plumber-90981

04/28/2021, 7:21 AM
figuring this stuff out is not easy
there arent examples to follow
k

kind-mechanic-53546

04/28/2021, 7:21 AM
no, theres definitely a learning curve
but it is powerful so that's a tradeoff
p

purple-plumber-90981

04/28/2021, 7:22 AM
bah that failed on implementation
Copy code
Diagnostics:
  kubernetes:core/v1:Namespace (mynamespace):
    error: unrecognized resource type (Check): kubernetes:core/v1:Namespace
k

kind-mechanic-53546

04/28/2021, 7:23 AM
hmm
p

purple-plumber-90981

04/28/2021, 7:23 AM
killmenow
ok it works if i dont pass in opts
k

kind-mechanic-53546

04/28/2021, 7:26 AM
ouch
p

purple-plumber-90981

04/28/2021, 7:28 AM
colour me even more confused now
time to take a break… thanks for the help, got me a properly named namespace
k

kind-mechanic-53546

04/28/2021, 7:30 AM
haha, baby steps and eventually we'll get there 🙂
any time
l

loud-helicopter-75345

04/28/2021, 3:01 PM
To be honest I tried the Python route and ended up thinking it might be easier to learn some Typescript. It was and the data structures seem like a much better fit for Pulumi: Python: https://github.com/pulumi/examples/blob/master/kubernetes-py-guestbook/simple/__main__.py#L142vs Typescript: https://github.com/pulumi/examples/blob/master/kubernetes-ts-guestbook/simple/index.ts#L87 The autocomplete in vscode is also very good, making filling in parts of those kubernetes structures dead simple. Just a heads up before you head further down that path.
3 Views