8000 Allow ResourceGraphDefinition authors to maintain serveral versions by acll19 · Pull Request #577 · kro-run/kro · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow ResourceGraphDefinition authors to maintain serveral versions #577

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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

acll19
Copy link
@acll19 acll19 commented May 30, 2025

In the issue #482 I initially proposed a way that would allow RGD authors to declare multiple versions in their RGD. However, after trying to implement a POC I realized that providing this kind of support would make the implementation too complex, specially when handling changes in the resource graph. Besides, from a UX standpoint it would not be too pleasant either as users would need to move what has changed from schema to previousSchema which could introduce unwanted errors.

This PR proposes a different approach, still based on some of the conventions mentioned in the issue, namely...

  • spec.schema.apiVersion will always be the latest version of the underlying CRD
  • spec.schema.apiVersion will always be both the served and storage version.

And defining the latest version in the underlying CRD as the one where both served and storage are true.

Kro will detect when the schema's apiVersion has changed and add it to the underlying CRD. As described here #482 (comment) the limitation is that RGD authors will only see all the available versions if they inspect the underlying CRD. If we follow through with this approach maybe the Kro CLI can help mitigate that limitation somehow?

This PR is missing validation:

  • is it a version older than the current latest version
  • is it not one of the existing previous versions?

And of course, there is the question of how to provide conversion between versions. Will Kro provide basic conversion or will all the responsibility fall on the user side?

If you find this approach valid, I am happy to continue with the implementation.

How to test

Create a RGD

apiVersion: kro.run/v1alpha1
kind: ResourceGraphDefinition
metadata:
  name: my-application
spec:
  schema:
    apiVersion: v1alpha1
    kind: Application
    spec:
      # Spec fields that users can provide.
      name: string
      image: string | default="nginx"
    status:
      deploymentConditions: ${deployment.status.conditions}
      availableReplicas: ${deployment.status.availableReplicas}
  resources:
    - id: deployment
      template:
        apiVersion: apps/v1
        kind: Deployment
        metadata:
          name: ${schema.spec.name} 
        spec:
          replicas: 3
          selector:
            matchLabels:
              app: ${schema.spec.name}
          template:
            metadata:
              labels:
                app: ${schema.spec.name}
            spec:
              containers:
                - name: ${schema.spec.name}
                  image: ${schema.spec.image} # Use the image provided by user
                  ports:
                    - containerPort: 80

Then create a new version

apiVersion: kro.run/v1alpha1
kind: ResourceGraphDefinition
metadata:
  name: my-application
spec:
  schema:
    apiVersion: v1alpha2
    kind: Application
    spec:
      # Spec fields that users can provide.
      name: string
      image:
        repository: string | default="nginx"
        tag: string | default="latest"
    status:
      deploymentConditions: ${deployment.status.conditions}
      availableReplicas: ${deployment.status.availableReplicas}
  resources:
    - id: deployment
      template:
        apiVersion: apps/v1
        kind: Deployment
        metadata:
          name: ${schema.spec.name} # Use the name provided by user
        spec:
          replicas: 3
          selector:
            matchLabels:
              app: ${schema.spec.name}
          template:
            metadata:
              labels:
                app: ${schema.spec.name}
            spec:
              containers:
                - name: ${schema.spec.name}
                  image: ${schema.spec.image.repository}:${schema.spec.image.tag} # Use the image provided by user
                  ports:
                    - containerPort: 80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0