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

Support reproducible builds to an OCI registry #12973

Open
stevehipwell opened this issue Apr 22, 2024 · 6 comments
Open

Support reproducible builds to an OCI registry #12973

stevehipwell opened this issue Apr 22, 2024 · 6 comments
Labels
feature oci Related to Helm OCI feature

Comments

@stevehipwell
Copy link

I'd like to be able to support creating Helm charts targeting an OCI registry as a reproducible build, which means being able to pass in the value for the org.opencontainers.image.created OCI annotation to helm push. This would build on the changes made in #12903 but work for cases where the package was being recreated.

An example use case for this would be as follows.

chart="my-chart"
chart_path="./charts/${chart}"
version="0.1.0"

date_epoch="$(git log -1 --format='%ct' "${chart_path}")"
created_date="$(date -u --date="@${date_epoch}" "+%Y-%m-%dT%H:%M:%SZ" 2>/dev/null)"

helm package "${chart_path}" --version "${version}"
helm push --created-date "${created_date}" "${chart}-${version}.tgz" "oci://my-registry.io/my-repo/${chart}"

CC @sabre1041

@gjenkins8 gjenkins8 added feature oci Related to Helm OCI feature labels Apr 27, 2024
@sabre1041
Copy link
Contributor

@stevehipwell been thinking about the different options at hand and comparing existing container/artifact packaging tools.

Docker does not natively support adding creation timestamps via CLI options, but Podman does. For Docker, labels (associated with the org.opencontainers.image.created) can be add during build time. ORAS does provide the ability to specify annotations that are applied to the artifact either from inline parameters or from a file.

There are really two options that could be applied at artifact push time:

  • The change proposed here where the build time is provided inline
  • Providing a set of annotations (either inline or file) that could be applied to the artifact that combines the annotations in the Chart.yaml and the provided values. There would need to be appropriate validation logic to ensure it complies with the appropriate timestamp format

@stevehipwell
Copy link
Author

@sabre1041 my preference for Helm v3 would be to support either the proposed --created-date or ORAS mirroring --annotation (I'm not sure why this is annotation and not --label?) flag. Logically this is aligned well with the current implementation which is either now or the created date of a file.

For Helm v4 I think there are some really good use cases for driving the annotations from another location to Chart.yaml; personally I'd like to see the chart source be (more) static with common changes such as image tag/digest, CHANGELOG, etc being merged to create the package. But I guess that's another discussion; I missed the Helm 4 highway KubeCon session and can't find the recording so I don't know if this was covered.

@sabre1041
Copy link
Contributor

@stevehipwell Labels (in the traditional container build sense) are stored within the OCI Image Configuration. Helm stores the contents of the Chart.yaml in the OCI Image Configuration, but what we would want to target here is the OCI annotations that are placed on the OCI Image Manifest. Helm populates a set of default annotations along with user defined annotations within the Chart.yaml file. The logic for populating annotations are found here.

@stevehipwell
Copy link
Author

@sabre1041 in this case the only annotation changing is the created one, so what's required is to set that manually. I had the same issue with ORAS pushing the Artifact Hub config, but due to the --annotation flag it was easily solved.

@sabre1041
Copy link
Contributor

@sabre1041 in this case the only annotation changing is the created one, so what's required is to set that manually. I had the same issue with ORAS pushing the Artifact Hub config, but due to the --annotation flag it was easily solved.

I personally lean toward the annotation and/or annotation-file options as it provides flexibility to include other use cases in the future

@stevehipwell
Copy link
Author

@sabre1041 wouldn't the annotation pattern require significantly more code to implement? I think it's the right way to go but I'm not sure if it's a reason not to also do the pragmatic option?

Adding a --created-date flag (I think this aligns with the annotation) to override the current logic would be pretty simple and consistent with the current behaviour. I assume that if/when the annotation functionality was added it'd take precedent over the existed created date logic anyway.

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

No branches or pull requests

3 participants