Provide support for resources with generateName
- Dominant language
- Go
- Stars
- 1.1k
- Forks
- 134
- PR merge metrics
- No merged PRs in 30d
Description
Sometimes there's some tools that take advantage of resources defined with [`genereteName`](https://kubernetes.io/docs/reference/using-api/api-concepts/#generated-values) instead of `name` in the resource definition, mostly so that a new instance is created every time the resource is applied/created to the cluster.
**kubectl** does require you to use **create** instead of **apply** for this type of resources as otherwise it will give an error.
In my use case, I'm deploying programmatically a Tekton PipelineRun, and my expected behavior is that everytime that I use `kapp deploy` a new instance is created but the previous are kept under kapp control.
After discussing with @cppforlife in the K8s slack, he gave me a workaround which works (after applying a manual fix to remove line https://github.com/k14s/kapp/blob/4db982f52b04bebf30d366f3d9d3f914ef383516/pkg/kapp/diff/template_resource.go#L154 in a local fork). The workaround is to:
* use **name** instead of generateName
* use **kapp.k14s.io/versioned: ''** to make kapp create a new version for every resource
* use **kapp.k14s.io/nonce: ''** to allow kapp to inject a unique ID for every generated resource
With this, what you get is the same behavior as when using generateName but requires you to make a change in your resource definition and also makes the generatedName kapp specific.
Although not ideal, it works ok for many (including me).
This issue is to consider whether adding support out of the box to resources defined with generateName make sense and what would be the best implementation.
Contributor guide
Research direction
Start in pkg/kapp/diff/template_resource.go around line 154, which the issue identifies as part of the current workaround, and trace how resources using generateName are handled. Compare the behavior with the documented name, versioned, and nonce workaround; done means agreeing on and implementing out-of-the-box generateName support while preserving previous generated resources under kapp control.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, kubernetes
- Domain
- cli, devops, infrastructure
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100