https://pulumi.com logo
Title
v

victorious-exabyte-70545

10/29/2021, 6:26 PM
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

billowy-army-68599

10/29/2021, 6:31 PM
which language?
here's a typescript example:
const ns = new k8s.core.v1.Namespace(name, {}, { provider: cluster.provider });
v

victorious-exabyte-70545

10/29/2021, 6:34 PM
that looks really straight forward. Thanks!
Anyone have a python example?
b

billowy-army-68599

10/29/2021, 6:41 PM
ns = Namespace("ns", metadata={
    "name": "example-namespace",
    },
    opts=pulumi.ResourceOptions(provider=provider),

)
v

victorious-exabyte-70545

10/29/2021, 6:46 PM
Thanks works in my preview. Thanks!!!
@billowy-army-68599 and this is how I would add the spec?
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

billowy-army-68599

10/29/2021, 7:00 PM
yep, that looks correct. you might want to use the strong typing though
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

victorious-exabyte-70545

10/29/2021, 7:17 PM
So the spec will be ignored?
b

billowy-army-68599

10/29/2021, 7:18 PM
depends on you kubernetes version, but it's not the "right" way to do it
v

victorious-exabyte-70545

10/29/2021, 7:19 PM
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

billowy-army-68599

10/30/2021, 3:24 PM
@victorious-exabyte-70545 define a resource and apply it with Pulumi?