A really really probably simple thing here.. Is th...
# kubernetes
b
A really really probably simple thing here.. Is there any way of making
k8s.yaml.ConfigFile/ConfigGroup
apply the resources to a namespace? I don't want to muck with the files, and they don't have a namespace declared in the yaml, so the transformation I've got seems to fail.. For instance:
Copy code
const keyCloakAccounts = new k8s.yaml.ConfigGroup("keycloak-roles-accounts-bindings", {
                files: [
                    `${pathToKeyCloakOper}/role.yaml`, 
                    `${pathToKeyCloakOper}/role_binding.yaml`,
                    `${pathToKeyCloakOper}/service_account.yaml`
                ],
                transformations: [
                    (obj: any, opts: pulumi.CustomResourceOptions) => {
                        obj.meta.namespace = keyCloakNamespace.metadata.name;
                    }
                ]
            },{
                provider: args.providers.kubernetes,
                parent: this,
                dependsOn: keyCloakNamespace
            })
Which fails with:
Copy code
TypeError: Cannot set property 'namespace' of undefined
        at Foundation.k8s.yaml.ConfigGroup.transformations (<path>\pulumi\baseline-k8s\components\kubernetes-components\foundation.ts:128:44)
        at parseYamlObject (<path>\pulumi\baseline-k8s\node_modules\@pulumi\yaml\yaml.ts:2925:9)
        at <path>\pulumi\baseline-k8s\node_modules\@pulumi\yaml\yaml.ts:2903:25
        at Array.map (<anonymous>)
        at <path>\pulumi\baseline-k8s\node_modules\@pulumi\yaml\yaml.ts:2903:14
        at runMicrotasks (<anonymous>)
        at processTicksAndRejections (internal/process/task_queues.js:93:5)
g
Easiest way is to set the namespace on the Provider. https://www.pulumi.com/docs/reference/pkg/kubernetes/provider/#namespace_nodejs