cold-car-67614
05/05/2021, 6:55 PMbillowy-army-68599
05/05/2021, 6:56 PMcold-car-67614
05/05/2021, 6:57 PMhelm.Chart(
release_name=f"{resource_name}/consul",
config=helm.ChartOpts(
chart="consul",
namespace=args.ns,
values=get_values_or_promise("consul.yaml", tmpl_vars),
fetch_opts=helm.FetchOpts(
repo="<https://helm.releases.hashicorp.com>",
),
transformations=[_strip_status],
),
opts=k8s_opts,
)
I am building a k8s_opts
for each cluster and calling the helm chart with a different opts to point to the right cluster.+ │ └─ kubernetes:core/v1:Service consul-system/consul-dns create
And that happens for each cluster.fullnameOverride
. This is set to consul
, which is why it looks like this. Same namespace and same name for the k8s metadata.name field. Which is exactly what I want on multiple clusters.cluster = rancher.get_cluster(name=args.name, opts=self.rancher_invoke)
self.k8s_provider = k8s.Provider(
resource_name=f"{resource_name}/k8s",
kubeconfig=cluster.kube_config,
opts=child_opts,
)
self.k8s_opts = pulumi.ResourceOptions(provider=self.k8s_provider)
billowy-army-68599
05/05/2021, 7:27 PMhelm.Chart(
release_name=f"{cluster_name}/{resource_name}/consul",
config=helm.ChartOpts(
chart="consul",
namespace=args.ns,
values=get_values_or_promise("consul.yaml", tmpl_vars),
fetch_opts=helm.FetchOpts(
repo="<https://helm.releases.hashicorp.com>",
),
transformations=[_strip_status],
),
opts=k8s_opts,
)
cold-car-67614
05/05/2021, 7:43 PMresource_name
has the cluster name in it.
The duplicate erroor is not on the helm chart resource. It's on the inner k8s children resources. It seems.resource_name_prefix
argument that gets prepended to all the resource names. That way if we deploy the exact same helm chart twice in 2 clusters we can avoid resource_name collisions?billowy-army-68599
05/05/2021, 8:16 PMcold-car-67614
05/05/2021, 8:17 PMhelm.Chart(
release_name="consul",
config=helm.ChartOpts(
resource_prefix=resource_name,
chart="consul",
namespace=args.ns,
values=get_values_or_promise("consul.yaml", tmpl_vars),
fetch_opts=helm.FetchOpts(
repo="<https://helm.releases.hashicorp.com>",
),
transformations=[_strip_status],
),
opts=k8s_opts,
)
resource_name
being the cluster name in my case it's entsvcs-dev-lab
.
Generated resource is this:
+ │ ├─ <kubernetes:rbac.authorization.k8s.io/v1:ClusterRole> consul-connect-injector-webhook create 1 error
The next iteration throws an error
<kubernetes:rbac.authorization.k8s.io/v1:ClusterRole> (consul-connect-injector-webhook):
error: Duplicate resource URN 'urn:pulumi:lab::net-inf::rei:helm:Consul$<kubernetes:helm.sh/v3:Chart$kubernetes:rbac.authorization.k8s.io/v1:ClusterRole::consul-connect-injector-webhook>'; try giving it a unique name
billowy-army-68599
05/05/2021, 8:25 PMcold-car-67614
05/05/2021, 8:26 PMbillowy-army-68599
05/05/2021, 8:29 PMcold-car-67614
05/05/2021, 8:29 PMbillowy-army-68599
05/05/2021, 11:17 PMrelease_name
cold-car-67614
05/05/2021, 11:19 PMbillowy-army-68599
05/05/2021, 11:19 PMrelease_name
- that's the thing setting the URN to a hardcoded namecold-car-67614
05/05/2021, 11:20 PMbillowy-army-68599
05/05/2021, 11:22 PMcold-car-67614
05/05/2021, 11:23 PM#fullnameOverride: consul
It looks like that is causing it. In your side you could set it like:
values={
"fullnameOverride": "consul",
}
That should reproduce it. I'll try to run it with this and see what happens. I was thinking the resource_prefix would only affect the Pulumi URN's and not the metadata.name
field on the k8s side.