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

Option to append to a ImagesLock when --imgpkg-lock-output is used #175

Open
voor opened this issue Oct 2, 2021 · 2 comments
Open

Option to append to a ImagesLock when --imgpkg-lock-output is used #175

voor opened this issue Oct 2, 2021 · 2 comments
Labels
discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution enhancement This issue is a feature request

Comments

@voor
Copy link

voor commented Oct 2, 2021

Describe the problem/challenge you have
We have different environments that use different configuration and this shares common manifests, in particular things like Helm charts. We generate our ImagesLock file at the same time we output samples that are committed into the repository for readability purposes (sometimes it can be hard to decipher extremely abstracted ytt templates). This loops through various configurations, for example turning on or off a prometheus metrics exporter or a cluster autoscaler. Since these manifests are all part of the same bundle it'd be nice if they had the same pattern of ./imgpkg/images.yml being referenced in the App CR. However, if the "last" sample isn't using a container then that container is excluded from the ImagesLock file since kbld will not append to an existing one.

Try it yourself:

helm template bitnami/postgresql --set metrics.enabled=true --set postgresqlDatabase=bob | kbld -f - --imgpkg-lock-output images.yml >/dev/null
cat images.yml
helm template bitnami/postgresql --set postgresqlDatabase=bob | kbld -f - --imgpkg-lock-output images.yml >/dev/null
cat images.yml

First output will look something like this:

---
apiVersion: imgpkg.carvel.dev/v1alpha1
images:
- annotations:
    kbld.carvel.dev/id: docker.io/bitnami/postgres-exporter:0.10.0-debian-10-r40
  image: index.docker.io/bitnami/postgres-exporter@sha256:896cb4c4f86d93ceba1f876c4c2ed6206f7d9de911dc29cce291fa2133e966f3
- annotations:
    kbld.carvel.dev/id: docker.io/bitnami/postgresql:11.13.0-debian-10-r12
  image: index.docker.io/bitnami/postgresql@sha256:eab9cdbb7417a51ef17009ed8b90b4f621cb177b54c51d62fedfd571e0398f15
kind: ImagesLock

Second one will be smaller, missing the metrics exporter (which was removed)

---
apiVersion: imgpkg.carvel.dev/v1alpha1
images:
- annotations:
    kbld.carvel.dev/id: docker.io/bitnami/postgresql:11.13.0-debian-10-r12
  image: index.docker.io/bitnami/postgresql@sha256:eab9cdbb7417a51ef17009ed8b90b4f621cb177b54c51d62fedfd571e0398f15
kind: ImagesLock

Describe the solution you'd like
Add something like --append-imgpkg-lock-output that would understand there is most likely already a ImagesLock at the provided location to --imgpkg-lock-output and instead of rewriting the file it would just look to see if the provided reference already existed, do a no-op, or update it, or add it to the end.

Anything else you would like to add:
If kbld would process this better as just appending full yml files, so you end up with something like:

---
apiVersion: imgpkg.carvel.dev/v1alpha1
---
apiVersion: imgpkg.carvel.dev/v1alpha1
---
apiVersion: imgpkg.carvel.dev/v1alpha1

that's fine too


Vote on this request

This is an invitation to the community to vote on issues, to help us prioritize our backlog. Use the "smiley face" up to the right of this comment to vote.

👍 "I would like to see this addressed as soon as possible"
👎 "There are other more important things to focus on right now"

We are also happy to receive and review Pull Requests if you want to help working on this issue.

@voor voor added carvel triage This issue has not yet been reviewed for validity enhancement This issue is a feature request labels Oct 2, 2021
@cppforlife
Copy link
Contributor

@voor could you combine multiple invocations into one?

kbld -f <(helm template bitnami/postgresql --set metrics.enabled=true --set postgresqlDatabase=bob) \
  -f <(helm template bitnami/postgresql --set postgresqlDatabase=bob) \
  --imgpkg-lock-output images.yml >/dev/null

@cppforlife cppforlife added the discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution label Oct 3, 2021
@voor
Copy link
Author

voor commented Oct 3, 2021

Not effectively, since they're also being output to a sample folder and/or part of loops that run at other times.

For the non-helm chart related things, what I've been doing is putting the image as something like:

    spec:
      initContainers:
      - image: change-me-later

And using kbld config:

apiVersion: kbld.k14s.io/v1alpha1
kind: Config
minimumRequiredVersion: 0.24.0
overrides:
- image: change-me-later
  newImage: registry.example.com/project/now-i-am-a-container:latest

@pivotaljohn pivotaljohn removed the carvel triage This issue has not yet been reviewed for validity label Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion This issue is not a bug or feature and a conversation is needed to find an appropriate resolution enhancement This issue is a feature request
Projects
Status: To Triage
Development

No branches or pull requests

3 participants