Node.of(construct).uniqueId
is not strictly compatible with the K8s labels
#323
Labels
Node.of(construct).uniqueId
is not strictly compatible with the K8s labels
#323
Description of the feature or enhancement:
I can find some usages of
Node.of(construct).uniqueId
across the codebase and examples. However, it is bound to CloudFormation's resource name rules and it isn't strictly compatable with Kubernetes' name/labels rules.It might be compatible if the resource name is short enough to be within k8s' length limitations, but you still bear the fact that
Node.of(construct).uniqueId
gives you auniqueidbutwithbarelyreadablebecauseitlacksofseparatorcharactorsA8322FCE
when you use a snake-case for resources names.There is already
Names.toDnsLabel
andChart.generateObjectName
using it. However, labels are superset of dns labels.Use Case:
I can find
uniqueId
in 8 files:Potentially invalid
https://github.com/awslabs/cdk8s/blob/d863232e4bf8a6dfcdd11e32b18b03586a4b766d/packages/cdk8s-plus/src/deployment.ts#L208
They are examples, but it should be changed considering the fact that people are blindfoldingly conpy-paste them.
https://github.com/awslabs/cdk8s/blob/85cf6313c20771b718c19ee6085afc23cd787311/examples/typescript/podinfo/lib/deployment.ts#L92-L95
https://github.com/awslabs/cdk8s/blob/85cf6313c20771b718c19ee6085afc23cd787311/examples/typescript/web-service/web-service.ts#L33
https://github.com/awslabs/cdk8s/blob/0f70a4fa0a471b27b3c75e25d0609935060b44ed/docs/getting-started/typescript.md#L285
It would be better to be changed for the readibility
https://github.com/awslabs/cdk8s/blob/2ae890a92cf67be1e1a5478102dd6003e446440f/packages/cdk8s/src/app.ts#L51
https://github.com/awslabs/cdk8s/blob/2ae890a92cf67be1e1a5478102dd6003e446440f/packages/cdk8s/src/dependency.ts#L160
Okay-ish for internal use
https://github.com/awslabs/cdk8s/blob/2ae890a92cf67be1e1a5478102dd6003e446440f/packages/cdk8s/src/dependency.ts#L26-L32
Proposed Solution:
It would be better to have a separate function for the label.
And I think it is cumbersome to use
Overloading them would be helpful?
Other:
Relative issue: aws/constructs#250
Short question: Why
normalizeToDnsName
limits components tomaxLen
? https://github.com/awslabs/cdk8s/blob/473b5ef7f442b932e9c4c4356945b91e8e1bc4e4/packages/cdk8s/src/names.ts#L79This is a 🚀 Feature Request
The text was updated successfully, but these errors were encountered: