cdk8s-team / cdk8s-core

Define Kubernetes native apps and abstractions using object-oriented programming
Apache License 2.0
67 stars 26 forks source link

Yaml Comments #2573

Open Alwin-Stockinger opened 7 months ago

Alwin-Stockinger commented 7 months ago

Description of the feature or enhancement:

Make it possible to set comments that are rendered to specific yaml fields, something like:

metadata: {
  name: "awesome-deployment",
  nameComment:  "This is an awesome deployment"
}

should output

metadata:
  name: "awesome-deployment"  #This is an awesome deployment

Use Case:

Flux has a feature that allows you to automate image update. To enable this you have to mark the field with a yaml comment e.g.

apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
  name: podinfo
  namespace: default
spec:
  values:
    image:
      repository: ghcr.io/stefanprodan/podinfo # {"$imagepolicy": "flux-system:podinfo:name"}
      tag: 5.0.0  # {"$imagepolicy": "flux-system:podinfo:tag"}

See https://fluxcd.io/flux/guides/image-update/#configure-image-update-for-custom-resources for explanation

Proposed Solution:

Something like mentioned above in the description.

This is a :rocket: Feature Request

srgvg commented 7 months ago

I can confirm this would be a use case for Flux Image Automation.

That is, assuming cdk8s generated yaml is committed to a git repository, which then gets update by Flux.

However, I'm not sure how the workflow would go further from there. When an update is made via cdk8s, how would the last Flux committed change be preserved?

In this sense, this feels like an anti-pattern to me, but that's unrelated to the validity of this feature request.