Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubernetes Resource Naming Convention Needs Rethinking #1689

Closed
Tracked by #1971
gkramer opened this issue Aug 25, 2021 · 5 comments
Closed
Tracked by #1971

Kubernetes Resource Naming Convention Needs Rethinking #1689

gkramer opened this issue Aug 25, 2021 · 5 comments
Assignees
Labels
kind/question Questions about existing features mro2 Monica's list of 2st tier overlay related issues resolution/fixed This issue was fixed

Comments

@gkramer
Copy link

gkramer commented Aug 25, 2021

Attempting to spin up two separate k8s clusters within the same stack, both of which run generic services (external-dns, cert-manager, etc) fails due to URN naming convention. It seems that URN should include the cluster name, so as to facilitate this requirement. This problem becomes more pronounced when deploying CRDs, where its not possible to modify the resource/CRD name.

Steps to reproduce

Deploy two K8S clusters within the same stack, both of which are running cert-manager. Pulumi will fail due to lack of unique URNs.

@gkramer gkramer added the kind/bug Some behavior is incorrect or out of spec label Aug 25, 2021
@mikhailshilkov
Copy link
Member

URNs are defined by the name of the Pulumi resource which doesn't have to match the actual resource name in the provider's target. If you have two K8s clusters in the same stack, you need to give them unique Pulumi names. The same applies to other resource types. Component resources will usually use the parent name to build up the children names.

Do you want to share some code where you think it's problematic?

@mikhailshilkov mikhailshilkov added awaiting-feedback Blocked on input from the author kind/question Questions about existing features and removed kind/bug Some behavior is incorrect or out of spec labels Aug 31, 2021
@travisjeffery
Copy link

travisjeffery commented Feb 3, 2022

The problem is deploying the resources. Pulumi doesn't use the provider name or k8s name in the URN of the resources. So if you deploy the same resources to two different k8s clusters, Pulumi generates the same URN.

As an example, try using NewConfigFile with this CSI AWS provider. And then doing:

_, err = k8syaml.NewConfigFile(ctx, clusterName+"_aws_secrets_store_provider", &k8syaml.ConfigFileArgs{
		File: "aws-provider-installer.yaml",
}, provider)
if err != nil {
	return err
}

On two different clusterNames and providers configured for two different k8s clusters. Pulumi still thinks it's managing the same resources meanwhile they're on different k8s clusters.

@travisjeffery
Copy link

I ended up just writing everything in that yaml in the equivalent resource code by hand, but that api is pretty broken. Should at least use the logical name given to help make things unique.

@TheDome
Copy link

TheDome commented Feb 17, 2022

I have the same problem using the Pulumi TypeScript SDK and Azure-native Kubernetes 👍

@mnlumi mnlumi added the mro2 Monica's list of 2st tier overlay related issues label Mar 28, 2023
@mikhailshilkov mikhailshilkov removed the awaiting-feedback Blocked on input from the author label Aug 2, 2023
@EronWright
Copy link
Contributor

EronWright commented Apr 1, 2024

The solution is to use the resourcePrefix property to make the child resource names be unique. For example:

_, err = k8syaml.NewConfigFile(ctx, "cluster1", &k8syaml.ConfigFileArgs{
	File: "aws-provider-installer.yaml",
	ResourcePrefix: "cluster1",
}, provider)

_, err = k8syaml.NewConfigFile(ctx, "cluster2", &k8syaml.ConfigFileArgs{
	File: "aws-provider-installer.yaml",
	ResourcePrefix: "cluster2",
}, provider)

Note that the "v2" version of the ConfigGroup resource automatically uses its own name as a prefix for the child resource names. Also, the prefix doesn't affect the Kubernetes object name.

@EronWright EronWright self-assigned this Apr 1, 2024
@EronWright EronWright added the resolution/fixed This issue was fixed label Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/question Questions about existing features mro2 Monica's list of 2st tier overlay related issues resolution/fixed This issue was fixed
Projects
None yet
Development

No branches or pull requests

6 participants