cni: set hostname as K8S_POD_NAME#3044
Conversation
In my case I'm already setting the hostname using The provided value is a base32-encoded hash of the data value used to generate the LLB. This PR should only affect folks who a) maintain their own Buildkit config with CNI + plugins that use This change shouldn't affect Buildkit's default behavior, and if Hope this helps it make more sense. :) |
|
Ok, but make it so that these new calls only happen when the custom hostname is set and not by default. |
|
Sounds good. The latest commit should address all feedback, but I haven't added tests yet. I have to dash out for today, but I'm leaning towards adding unit tests for the CNI network provider. I'm interested in integration testing but it might be a bit invasive unless I figure out a way to use an alternative stage to Let me know if you have a preferred approach. edit: hm, unit testing this is tricky; I can't assert what options are passed since they're just functions that run against a |
Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
note: the default hostname is not set in meta.Hostname; meta.Hostname is used to override the default, so we don't have to check for it here and this should only apply if the user explicitly sets llb.Hostname. Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
|
Added an integration test. It was less invasive than I thought. I was worried all the other tests would start running |
hostname addressability feels like the more obvious contract to test Signed-off-by: Alex Suraci <suraci.alex@gmail.com>
…ter-evans/create-pull-request-7.0.8 build(deps): bump peter-evans/create-pull-request from 7.0.7 to 7.0.8
This PR passes the hostname along to the network provider. The CNI provider sets it as
K8S_POD_NAME, the rest ignore it.My goal is to be able to use the
dnsnameCNI plugin for inter-container networking in Buildkit. Using DNS works great because it lets me keep non-reproducible values like IP addresses out of LLB, maximizing cache reuse for builds that depend on services.The
dnsnameplugin uses the "container name" as its address, which it reads from an arg calledK8S_POD_NAME. This arg seems to be used by other CNI plugins too. It's kind of a bummer that this arg name isn't something more generic. This plugin is actually designed forpodmanwhich sets the same arg; it seems to be a de-facto standard at this point. :/The hostname seems like the closest thing to a "container name," and it seems reasonable for a network provider to be interested in the hostname, so I threaded the value through and called it done. I'm not married to this approach, but if it seems reasonable I can start working on a test for it.
I also considered adding support for arbitrary CNI options, since folks like me might want port mapping someday, but I'm not sure if y'all would want to commit to that (or even this, frankly).