dmikusa / binding-tool

Generate Kubernetes service bindings for use with Cloud Native Buildpacks
Apache License 2.0
26 stars 4 forks source link

Support for kpack service bindings #5

Open devhuber opened 1 year ago

devhuber commented 1 year ago

It would be great if the tool could support creating the service bindings for kpack. Would it also be a volume mount to the builder? Sofar I don't know how one would add the bindings of this sort via kpack. Or could it look something like this, where "..." is the URI to the file (might also be an https URL)?

apiVersion: v1
kind: Secret
metadata:
  name: dependencies
type: service.binding/dependency-mapping
stringData:
  type: dependency-mapping
  0d82ad4821b55d276d25486132f708f4cc747e242a9ce256fdf1c7f21979a94c : ...
  2bda48088925a5cead341ff9ae8b12c4075937f444827946a268ba773cf0339b : ...
  4f07a1c52b47c77b4e6a50623055de584d347002954ffa0029aedc915c035a17 : ...
  583d7da65e1b3f4b470e595c21d55dd3eb176789c7dea7d15cbec42b74877b50 : ...
  73c602ff0790a4ab325db06cae45f488f7e3613d781d688a204efa6325cebdd0 : ...
  74de76313848ef719d066854fe94dcec53fdcd111c630921b6b24e1b2e6897e7 : ...
  7d1056af3efbc998ac62c31197e18f32f7e58ac086d4636e559cc57d5edfb23d : ...
  883a25a15a6aa9d74ae35b23efdb6dced85e52b9519fc590313cec6c2626af79 : ...
  b389036c7ba1eca72c784c73c02d9397e81ced07a713f289430d7089376aac7f : ...
  c0feff461fb48d6b5745638fa6ac3901238b5fcbf09a2fcc5e771c55a743f0df : ...
  cf23e85f5a6b4e22007ce2572d38182f535ad22fcf937def8f781181fbb86b65 : ...
  d9e9ba6e872c2d7073e69407196be29db27d4fcd22de6ca7dde40840b934c286 : ...
doddisam commented 3 months ago

@dmikusa - We are looking for similar feature, so is there any plan to get this in near future ?

dmikusa commented 3 months ago

Please check out https://github.com/paketo-buildpacks/rfcs/pull/302. I think this is going to be the path forward for most users with respect to dependency mapping. Please let me know though.

To move this one forward, i think I'd need to get some examples of what we need the tool to generate. I don't have kpack deployed, so I can't easily make them. If you give me some templates, it's pretty easy to make the tool generate them.

doddisam commented 3 months ago

If my understanding is right ,currently pack users should use the --volume flag to mount a binding directory into the build or app containers. Users of the kpack platform should store key value pairs in a Kubernetes Secret and provide that secret and associated metadata to an Image as described in the kpack documentation(opens in a new tab).

Is binding tool going to supports creation of secrets in future ?

doddisam commented 3 months ago

Basically i am looking for the tool to create binding for all the dependencies in the form of secrets like below. If the bt tool can provide secret file as an output it will very easy for kpack user to just create secret and build image.

image

doddisam commented 2 months ago

@dmikusa - Can above format be possible from the bt tool ?

dmikusa commented 2 months ago

Yes, the tool could definitely generate secrets.

What is your thought on how to tell the CLI you want it to generate the secrets file? I could add a flag to bt dm, like bt dm --k8s-secrets that when set would also write the secrets file.

Also, what is your thought on running the command multiple times? I suspect that we'd need to read the secrets file, locate the particular dependency mapping and then update it (if modified) or add new mappings to the list of mappings. Does that sound reasonable?

doddisam commented 2 months ago

Yes, Something like bt dm --k8s-secrets should work.

I think we can just add new mappings to the list when command is run multiple times.

doddisam commented 1 month ago

@dmikusa Just checking if the above capability is added to the tool?

dmikusa commented 1 month ago

Sorry @doddisam I went to look at this again, and I'm not sure I follow in terms of what the value of the secret should be. In the example you provided, it's pointing to artifactory, which isn't really consistent with what the tool does now. It's purpose is to fetch from remote URLs and to generate a local folder structure that could be used as place from which to fetch the dependencies. Given that, the value would probably be file://... but I'm not sure what makes the most sense there in terms of K8s. What were you thinking?

I would also refer you back to https://github.com/dmikusa/binding-tool/issues/5#issuecomment-2026102918 because if you're just trying to point your buildpacks to an artifactory cache that you have already set up, you can do that with the dependency mirror RFC, which has been implemented for all of the Java-based buildpacks.

See https://paketo.io/docs/howto/configuration/#dependency-mirrors for docs on using that.

doddisam commented 2 weeks ago

@dmikusa will dependency mirrors work for dotnet build pack also ?

dmikusa commented 2 weeks ago

I believe that it should. It looks like packit implemented the RFC a few months back, see https://github.com/paketo-buildpacks/packit/pull/563.

So long as that set of buildpack has updated packit to at least https://github.com/paketo-buildpacks/packit/releases/tag/v2.13.0.

I don't think there should be anything else that's needed.