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

"YAML object does not have a .metadata.name" error when use the ConfigGroup with a generated name #3370

Open
emirozmen07 opened this issue Dec 13, 2024 · 1 comment
Labels
kind/enhancement Improvements or new features

Comments

@emirozmen07
Copy link

What happened?

I was trying to use the ConfigGroup to release a number of YAML job files and some of the files does not have a name in their metadata, instead they have generateName property. But when you run the ConfigGroup class with this file it does not recognize this name and returns the error below.

 Exception: YAML object does not have a .metadata.name: batch/v1/Job 

Example

        self.k8s_provider = k8s.Provider(pulumi.get_stack())
        k8s_resources = k8s.yaml.ConfigGroup(
            self.name,
            files=self.yaml_files,
            opts=pulumi.ResourceOptions(provider=self.k8s_provider),
        )

Try to insert the YAML below using the code above.

apiVersion: batch/v1
kind: Job
metadata:
  generateName: project-backup-
  namespace: current_namespace
  labels:
    app: project-backup
spec:
  ttlSecondsAfterFinished: 54000
  template:
    metadata:
      name: project-backup
    spec:
      containers:
        - name: backup-engine
          image: europe-west1-docker.pkg.dev/test_name/test_name-docker-repo/backup-project:latest
      restartPolicy: Never
      imagePullSecrets:
        - name: docker-registry-company

Output of pulumi about

CLI          
Version      3.139.0
Go Version   go1.23.3
Go Compiler  gc

Plugins
KIND      NAME        VERSION
resource  docker      4.5.5
resource  gcp         7.38.0
resource  kubernetes  4.17.1
resource  postgresql  3.11.3
language  python      3.139.0
resource  random      4.16.4

Host     
OS       darwin
Version  14.5
Arch     x86_64


Dependencies:
NAME              VERSION
pip               24.2
pulumi_random     4.16.4
setuptools        74.1.2
wheel             0.44.0

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

@emirozmen07 emirozmen07 added kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Dec 13, 2024
@rquitales
Copy link
Member

@emirozmen07 Unfortunately we do not currently support manifests within a ConfigGroup to not have an explicit name. There are a few challenges that would need to be addressed before we can support this feature:

  1. It is not trivial to be able to assign a Pulumi resource name
  2. Server-side apply does not support generateName

Please ensure that your raw k8s manifest contain an explicit name within them if you would like to use them within a ConfigGroup resource.

@rquitales rquitales added kind/enhancement Improvements or new features and removed kind/bug Some behavior is incorrect or out of spec needs-triage Needs attention from the triage team labels Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/enhancement Improvements or new features
Projects
None yet
Development

No branches or pull requests

2 participants