workspace status command variable substitution for images
rules_docker has variable substitution from workspace status. So we can do
container_bundle(
name = "all_images",
images = {
"gcr.io/{PROJECT_ID}/server:{DOCKER_TAG}": "//cmd/server:server_image",
},
)
When we tried to switch to rules_k8s this surprisingly stopped working.
k8s_deploy(
name = "development",
cluster = "gke-cluster-name",
template = ":kustomize-development",
images = {
"gcr.io/our-project/server:dev": "//cmd/server:server_image",
# this doesn't work
#"gcr.io/{PROJECT_ID}/server:{DOCKER_TAG}": "//cmd/server:server_image",
},
)
What is the correct way to do this? Is there a plan to make this compatible with rules_docker?
can you please provide a more detailed example of what you mean with "switch to rules_k8s"? I.e., what type of target is working with rules_docker when you specify images with substitutions and what type of target are you using in rules_k8s.
Thanks for responding, I added more context to the text above.
Thanks for the additional context @codesuki , It took a bit to remember how that works, but the logic to resolve the workspace status variables in rules_docker is here: https://github.com/bazelbuild/rules_docker/blob/master/container/join_layers.py#L201. To get this feature to work with rules_k8s it would be necessary to modify the resolver (https://github.com/bazelbuild/rules_k8s/blob/master/k8s/resolver.py) to also take in as input the stamp info (and get object.bzl to pass the info when calling resolver) and get the functionality similar to the one in join_layers. It's not a trivial change, and we are currently not working on adding new features to rules_k8s. If you are interested in volunteering a PR to get this working I'd be happy to help guide you.
Thank you for your guidance. Right now I don't have time on my schedule for it but might consider it in the near future. In that case, I'll write here again.
we are currently not working on adding new features to rules_k8s.
Is this because you are satisfied with how it works right now or what are the reasons? Would it be better not to rely on it?
it's because we are satisfied with how it works right now and have other higher priorities. You can continue to rely on it as we are committed to keep the current features working.
and we will also continue receiving community contributions for new features/improvements!
Thanks for clearing that up!
Is this still valid? We've replaced the python resolver with a golang one.
https://github.com/bazelbuild/rules_k8s/pull/423 This one solved my use case. If the golang resolver has the same functionality then I think it's fine :)