https://pulumi.com logo
#dotnet
Title
# dotnet
c

curved-doctor-83600

02/16/2021, 11:01 AM
Hi, I am currently stuck trying to set the values for a helm chart in c#. I am using ingress-nginx helm chart (to deploy it to aks) and want to set a static ip to the loadbalancer. There is a value controller.service.loadBalancerIP available to set for the chart, but it seems that I can't set that to an output (the staticIP is an output). I am using a Dictionary here, because trying to use an InputMap results in this (https://github.com/pulumi/pulumi/issues/5961). Any hints on how to do that?
Copy code
Values =
            {
                { "controller", new Dictionary<string,object>
                    {
                        { "replicaCount", NodeCount },
                        { "service", new Dictionary<string, object>
                            {
                                { "externalTrafficPolicy", "local" },
                                { "loadBalancerIP", staticIp }
                            }
                        }
                    }
                }
            }
t

tall-librarian-49374

02/16/2021, 11:10 AM
Try
Apply
?
Copy code
{ "controller", staticIp.Apply(ip => new Dictionary<string, object>
  {
   ...
     { "loadBalancerIP", ip },
...
c

curved-doctor-83600

02/16/2021, 1:05 PM
Tried that, but doesn't work unfortunately. What I also don't understand: if I change any of those values (let's say hardcode the ip instead of using the output or changing NodeCount to a different integer), calling "pulumi preview --diff" does not indicate any change. I am sure I am missing sth. here.
m

miniature-leather-70472

02/16/2021, 1:27 PM
I did this with a transform on the Helm chart, mainly to avoid having to wrap the whole values section an an apply.
ImmutableDictionary<string, object> SetLbIp(ImmutableDictionary<string, object> obj,
CustomResourceOptions opts) { if ((string) obj["kind"] == "Service" && ((string) ((ImmutableDictionary<string, object>) obj["metadata"])["name"]).EndsWith( "ingress-nginx-controller", StringComparison.InvariantCultureIgnoreCase)) { var spec = (ImmutableDictionary<string, object>) obj["spec"]; var metadata = (ImmutableDictionary<string, object>) obj["metadata"]; if (spec != null && (string) spec["type"] == "LoadBalancer") { obj = obj.SetItem("spec", spec.SetItem("loadBalancerIP", args.LoadBalancerIp.Apply(x => x))); } } }
c

curved-doctor-83600

02/16/2021, 1:48 PM
Thanks @miniature-leather-70472, that sounds reasonable. Just to be sure, the args.LoadBalancerIp in your snippet is an output, probably Output<string>? With the hint from @tall-librarian-49374 I finally understood that I can wrap the whole values section in an apply (as you mentoined as well). WIll try your suggestion as well and see what appeals more to me. Thanks for your help, I really appreciate that.
m

miniature-leather-70472

02/16/2021, 2:41 PM
yep. args.LoadBalancerIp is an Output<string> that is created earlier in the process. You can certainly wrap the values in an apply and that should work too. There is a bug open somewhere about the fact that the helm chart should work with Outputs directly
t

tall-librarian-49374

02/16/2021, 3:57 PM
Ah, thank you both for the feedback!
3 Views