https://pulumi.com logo
d

damp-room-71337

08/27/2019, 2:05 PM
has anyone got any pointers on installing Helm charts into non-default/current namespaces? I’ve tried passing a custom provider to Helm as mentioned here, but it gets ignored https://github.com/pulumi/pulumi-kubernetes/issues/217#issuecomment-504160101
c

cool-egg-852

08/27/2019, 2:22 PM
Yes, we use a transformation to handle it.
Copy code
new k8s.helm.v2.Chart(config.project, {
  chart: 'stable/jenkins',
  version: '1.3.3',
  namespace: namespace.metadata.name,
  values: {
    master: {
      serviceType: 'ClusterIP',
    }
  },
  transformations: [
    (resource: any) => {
      resource.metadata.namespace = namespace.metadata.name;

      // This fixes the test failing
      if (resource.kind == 'Pod') {
        resource.metadata.annotations = {
          '<http://sidecar.istio.io/inject|sidecar.istio.io/inject>': 'false'
        };
      }
    }
  ]
});
d

damp-room-71337

08/27/2019, 2:23 PM
I’m a bit wary of that, in case a chart uses non-cluster-scoped resources
c

cool-egg-852

08/27/2019, 2:23 PM
It hasn’t seemed to have broken anything for us, but I get your worry. I think there are some other more complicated transformations that do the same thing, but ignore those types of resources
It’s the only solution that I am aware of.
The proper solution though is to submit a PR against the chart and have them add the namespace explicitly.
Tiller is going away, so they will need it anyways I believe. I’ve seen several charts accept these changes.
d

damp-room-71337

08/27/2019, 2:24 PM
ok, cheers - I don’t get why setting the namespace on the k8s provider doesn’t work though 🤔
g

gorgeous-egg-16927

08/27/2019, 2:25 PM
@damp-room-71337 Would you mind filing an issue with details on the provider namespace not working for you? https://github.com/pulumi/pulumi-kubernetes/issues/new
d

damp-room-71337

08/27/2019, 2:25 PM
sure
🙏 1
g

gorgeous-egg-16927

08/27/2019, 3:00 PM
Updated the ticket with a resolution. This chart was already fixed upstream, so you just have to set the
namespace
parameter on the chart to get the behavior you want
d

damp-room-71337

08/27/2019, 3:01 PM
Yep just saw - that’s a fix for this specific chart, but I’d guess that there’s a general issue with Helm not respecting the k8s provider’s namespace?
g

gorgeous-egg-16927

08/27/2019, 3:01 PM
Right. We don’t use Tiller, so some charts don’t work out of the box. Best thing is to fix the chart upstream, but the other ways can be used to work around in the meantime
To clarify, the provider namespace flag is a default, not an override, so the chart’s value was taking precedence here
d

damp-room-71337

08/27/2019, 3:03 PM
fair enough - I know it’s not Pulumi’s doing, but this is pretty hard to work with at the moment. The workarounds detailed here don’t always work for all Helm charts https://github.com/pulumi/pulumi-kubernetes/issues/217#issuecomment-504160101
g

gorgeous-egg-16927

08/27/2019, 3:05 PM
If you find specific cases that are confusing, please open an issue. We’re trying to make it as easy as possible, but it’s hard given the variety of approaches taken by helm charts
Since Tiller is going away with Helm 3, I’d expect the namespace issue to get better over time