Does anyone have a working python example of how t...
# kubernetes
v
Does anyone have a working python example of how to create a namespace in kubernetes? I do not know where to put the provider info based on the documentation:
b
which language?
here's a typescript example:
Copy code
const ns = new k8s.core.v1.Namespace(name, {}, { provider: cluster.provider });
v
that looks really straight forward. Thanks!
Anyone have a python example?
b
Copy code
ns = Namespace("ns", metadata={
    "name": "example-namespace",
    },
    opts=pulumi.ResourceOptions(provider=provider),

)
v
Thanks works in my preview. Thanks!!!
@billowy-army-68599 and this is how I would add the spec?
Copy code
namespace = Namespace(
    "nifi",
    spec={
        "hard": {"requests.cpu": "1"},
        "requests.memory": "1Gi",
        "limits.cpu": "2",
        "limits.memory": "2Gi"
    },
    metadata={"name": "nifi"},
    opts=ResourceOptions(provider=k8s_provider),
)
b
yep, that looks correct. you might want to use the strong typing though
Copy code
ns = k8s.core.v1.Namespace("example", k8s.core.v1.NamespaceArgs(
    metadata=k8s.meta.v1.ObjectMetaArgs(
        name="foo"
    )
))
It looks like kubernetes has moved limits from the spec and onto a ResourceQuota type which you can spot by using the strong typing
v
So the spec will be ignored?
b
depends on you kubernetes version, but it's not the "right" way to do it
v
Got it. Thanks!
And the ResourceQuota type is configured in the namespace? Thanks for your help on this. I am new to kubernetes.
Oh, I see it.
So it is applied to the namespace.
Hmm. How do I use pulumi to apply the resource quota to the namespace?
b
@victorious-exabyte-70545 define a resource and apply it with Pulumi?