kustomize: Kustomize doesn't support metadata.generateName
I am trying to use kustomize with https://github.com/argoproj/argo.
Example spec:
apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
generateName: hello-world-
spec:
entrypoint: whalesay
templates:
- name: whalesay
container:
image: docker/whalesay:latest
command: [cowsay]
args: ["hello world"]
Argo Workflow CRDs don’t require or use metadata.name, but I am getting the following error when I try to run kustomize build on an Argo Workflow resource:
Error: loadResMapFromBasesAndResources: rawResources failed to read Resources: Missing metadata.name in object {map[args:[hello world] kind:Workflow metadata:map[generateName:hello-world-] spec:map[entrypoint:whalesay templates:[map[container:map[command:[cowsay] image:docker/whalesay:latest] name:whalesay]]] apiVersion:argoproj.io/v1alpha1]}
Is there a way for me to override where kustomize looks for a name to metadata.generateName?
About this issue
- Original URL
- State: open
- Created 6 years ago
- Reactions: 64
- Comments: 75 (12 by maintainers)
Commits related to this issue
- fix: issue seems to relate to kustomize https://github.com/kubernetes-sigs/kustomize/issues/641 — committed to Sijoma/home-k8s-infra by deleted user 3 years ago
- workaround - fix cert-manager kustomization related to the issue https://github.com/kubernetes-sigs/kustomize/issues/641 — committed to timtorChen/homelab by timtorChen 3 years ago
The workaround I’ve used for Argo specifically is to define my workflow with a
name:And then tell Kustomize to move that to
generateNameas the last patch:This is obviously not very good, but it does let us use Kustomize with Argo (and without writing a Kustomize plugin).
I wanted to use generateName with kustomize too.
It appears that the vast majority of us are just trying to generate random names for our jobs. If kustomize just generated the name using generateName as the prefix, most of us will be perfectly happy with it.
The workaround above does not work. I am using Kustomize v4.2.0. The following error is thrown. My files are shown below.
cron-workflow.yaml:kustomization.yaml:patch.yaml:/remove-lifecycle rotten
I wanted to use generateName with kustomize but I can’t 😦
And 5 years later we have no solution.
/triage accepted /kind bug We will take a closer look to see if we can fix this.
/remove-lifecycle stale
#627 is about names, but currently i see it as a feature request.
This bug and #586 are noting that kustomize doesn’t recognize the kubernetes API directive
generateName, which is indeed a bug.This directive is a kustomize-like feature introduced before kustomize… (complicating our life).
We might try to allow it and work with it - or disallow it and provide an alternative mechanism.
/remove-lifecycle stale
Agreed, let’s re-open and solve the issue.
Just ran into this as well when working with Jobs.
That’s definitely an interesting idea. A few complications come to mind:
Please provide a solution or how we can support the kustomize team closing this issue - it is blocking our pipeline development in Argo Workflow at this moment as we want to kustomize pipelines.
I’m working on a project where Kustomize was selected for ArgoCD. We were hoping to extend its use to our Argo Workflows but this is a significant impediment. Deleting previous workflow instances as was suggested in one comment does not align with our operational requirements. I’m sure there are plenty of usecases outside of Argo Workflow that are also affected by this issue.
Is there a progress update on this? It seems like a pretty big limitation. Not being able to us Kustomize with CRDs such as those in Argo Workflows is a huge drawback.
Is there any progress?
/reopen
I’ve just stumbled across this issue as well, and would appreciate a fix or an alternative mechanism (as mentioned by monopole above).
Oh. No, it just ok for
kubectl kustomize, but failed with argocd. And, i run withkustomize buildwould be failed too. kustomize version: v4.4.0We also just ran into this. All related PR’s got closed so what’s the plan now? What exactly can we do to bring this forward?
I also have just run into this issue while attempting to use
generateNameon Jobs. Would be nice to see some fix or official workaround communicated.I don’t want to get anyone’s hopes up, but here’s a PR that works in local testing: https://github.com/kubernetes-sigs/kustomize/pull/4981.
I don’t understand
kustomizeenough to know if this is really sufficient, but I look forward to comments pointing me in the right direction.Still no work around yet for this. I find myself moving from kustomize to helm charts just because of this 🤦🏿
We worked around the Job name problem by setting
ttlSecondsAfterFinished: 0[1] so the Job is removed automatically after completion. The next time the Job is created, the previous one is already deleted.[1] https://kubernetes.io/docs/concepts/workloads/controllers/job/#clean-up-finished-jobs-automatically
Perhaps a good way for kustomize to deal with
generateNameseemlessly would be to:generateNameand assign the object a random name with the givengenerateNameprefix, but note that it did (for example, it could save some special annotation on the object).This could probably be implemented fairly quickly in code too since it doesn’t break kustomize’s assumption of identifying objects by apiversion/kind/name/namespace.
I’am also fighting against this issue. it’s useful to run a job every time we deploy a new version and we need to generate job names randomly
this is open a long time ago… Any deadline?
I’d like to see this too, the implications of not having this is pretty big.
For example Argo CD will delete the old job + create a new job, but without a unique name tools like Datadog will override the old job with the new job so you lose being able to see the history of the job’s runs and how long each one took. With the same name job the best you can do is get container stats like logs which doesn’t contain details about the job itself.
Having
generateNamesupported would allow each job to be individually tracked and persisted since they would each have their own name.This issue should be reopened unless it has been solved and the docs don’t show it.
Similar issues #627, #586