Not sure how to make sure the namespace is created...
# general
Not sure how to make sure the namespace is created first and not get this warning
I think the issue is that you are referencing the output of the namespace resource as a value which is required during templating. What about using a variable containing the namespace name and passing that to the namespace resource AND to the helm chart instead of using the output
? This is how it works fine for me. I assume that templating is already done for preview and in that case it is missing the resolved output value.
Like so:
Copy code
const monitoringNamespaceName = "monitoring";
const monitoringNamespace = new k8s.core.v1.Namespace("monitoring", { metadata: { name: monitoringNamespaceName } }, { provider : provider });

const prometheusOperatorChart = new k8s.helm.v2.Chart("po", {
    repo: "stable",
    chart: "prometheus-operator",
    namespace: monitoringNamespaceName,
    values: {
        alertmanager: { persistentVolume: { storageClass: "gp2" } },
        server: { persistentVolume: { storageClass: "gp2" } }
}, { provider: provider });
Maybe I'm confused but I thought referring to the namespace resource output would resolve
Yes, I could refer to the same constant, but say the namespace generated the name (if I didn't specify it explicitly), then I'd need to refer to it like I'm trying to.
I get your point and think this should not be a limitation to take (not using generated names). Maybe it’s just a matter of being in the preview phase when the final name does not exist yet? Is that an error or just a warning during preview? I also ran into some cases where preview was too cautious and assumed a replacement where an in-place-update would have worked but this information was not available during preview.
Not sure but I think it's a warning:
Copy code
root@ebea11107491:/workspaces/workspace/k8s-infra# p up --suppress-outputs 
Previewing update (org/dev):

     Type                          Name           Plan       Info
     pulumi:pulumi:Stack           k8s-infra-dev             
 +   ├─   po             create     1 message
 +   └─ kubernetes:core:Namespace  monitoring     create     
Diagnostics: (po):
    [Can't preview] all chart values must be known ahead of time to generate an accurate preview.
    + 2 to create
    15 unchanged
In other cases, I thought I remember seeing the preview showed a placeholder for any yet to be derived outputs?
The preview is kinda essential when dealing with these big helm templates
Interesting issue that shows an example using
, which is how I expected to be able to refer to the namespace name, with the output being lifted.
For reference (this is the first search result on “helm namespace preview”): The underlying issue is discussed in more detail (with Pulumi devs) here: