kustomize icon indicating copy to clipboard operation
kustomize copied to clipboard

Kustomize doesn't support metadata.generateName

Open shimmerjs opened this issue 6 years ago • 81 comments

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?

shimmerjs avatar Dec 17 '18 22:12 shimmerjs

Similar issues #627, #586

Liujingfang1 avatar Dec 18 '18 00:12 Liujingfang1

#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.

monopole avatar Dec 30 '18 01:12 monopole

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Apr 27 '19 22:04 fejta-bot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

fejta-bot avatar May 27 '19 22:05 fejta-bot

/remove-lifecycle rotten

I wanted to use generateName with kustomize but I can't :(

confiq avatar Jun 21 '19 12:06 confiq

I wanted to use generateName with kustomize too.

anarcher avatar Jul 04 '19 01:07 anarcher

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Oct 02 '19 01:10 fejta-bot

Stale issues rot after 30d of inactivity. Mark the issue as fresh with /remove-lifecycle rotten. Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle rotten

fejta-bot avatar Nov 01 '19 02:11 fejta-bot

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

fejta-bot avatar Dec 01 '19 03:12 fejta-bot

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity. Reopen the issue with /reopen. Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Dec 01 '19 03:12 k8s-ci-robot

This issue should be reopened unless it has been solved and the docs don't show it.

wpbeckwith avatar Jan 09 '20 08:01 wpbeckwith

Agreed, let's re-open and solve the issue.

jarednielsen avatar Feb 08 '20 01:02 jarednielsen

anybody can open with @k8s-ci-robot robot command. I've already opened, I don't want to flood it :)

confiq avatar Feb 08 '20 18:02 confiq

/reopen

I've just stumbled across this issue as well, and would appreciate a fix or an alternative mechanism (as mentioned by monopole above).

haimberger avatar Mar 03 '20 13:03 haimberger

@haimberger: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

I've just stumbled across this issue as well, and would appreciate a fix or an alternative mechanism (as mentioned by monopole above).

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Mar 03 '20 13:03 k8s-ci-robot

/reopen

sigh.

Datamance avatar Mar 12 '20 18:03 Datamance

@Datamance: You can't reopen an issue/PR unless you authored it or you are a collaborator.

In response to this:

/reopen

sigh.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

k8s-ci-robot avatar Mar 12 '20 18:03 k8s-ci-robot

Can someone with The Power reopen this? Still outstanding AFAICT.

stpierre avatar Apr 22 '20 15:04 stpierre

/remove-lifecycle rotten

Liujingfang1 avatar Apr 22 '20 16:04 Liujingfang1

The workaround I've used for Argo specifically is to define my workflow with a name:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: hello-world-
spec:
  ...

And then tell Kustomize to move that to generateName as the last patch:

resources:
  - hello-world.yaml
patches:
  - patch: |-
      - op: move
        from: /metadata/name
        path: /metadata/generateName
    target:
      kind: Workflow

This is obviously not very good, but it does let us use Kustomize with Argo (and without writing a Kustomize plugin).

stpierre avatar Apr 22 '20 16:04 stpierre

I've just faced this issue using Spinnaker as well because Spinnaker is updated to 1.20.0 and Kubernetes Job behavior is changed to use metadata.generateName filed instead of metadata.name. In this case, kustomize build fails for missing metadata.name.

tyuhara avatar May 06 '20 00:05 tyuhara

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Aug 04 '20 00:08 fejta-bot

/remove-lifecycle stale

jarednielsen avatar Aug 04 '20 01:08 jarednielsen

Is there any progress?

posquit0 avatar Sep 10 '20 05:09 posquit0

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta. /lifecycle stale

fejta-bot avatar Dec 09 '20 06:12 fejta-bot

/remove-lifecycle stale

hadrien-toma avatar Dec 09 '20 06:12 hadrien-toma

Issues go stale after 90d of inactivity. Mark the issue as fresh with /remove-lifecycle stale. Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-contributor-experience at kubernetes/community. /lifecycle stale

fejta-bot avatar Mar 09 '21 07:03 fejta-bot

/remove-lifecycle stale

hadrien-toma avatar Mar 09 '21 07:03 hadrien-toma

The workaround I've used for Argo specifically is to define my workflow with a name:

apiVersion: argoproj.io/v1alpha1
kind: Workflow
metadata:
  name: hello-world-
spec:
  ...

And then tell Kustomize to move that to generateName as the last patch:

resources:
  - hello-world.yaml
patches:
  - patch: |-
      - op: move
        from: /metadata/name
        path: /metadata/generateName
    target:
      kind: Workflow

This is obviously not very good, but it does let us use Kustomize with Argo (and without writing a Kustomize plugin).

But we need to change the generateName to name not the other way around. I tried this but still get the same error, metadata.name missing

mgwismer avatar Apr 30 '21 20:04 mgwismer

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.

boonware avatar Jul 23 '21 08:07 boonware