-
Notifications
You must be signed in to change notification settings - Fork 31
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
Copying a file to a container before starting it #53
Comments
The |
Thanks, will give this a try tomorrow |
Good news is that I also can't see the kubedock sidecar logging anything. Any suggestions for debugging this? I notice that kubedock seems to use logback -- I am not very familiar with go, but perhaps I can add an environment variable to enable debug logging? |
When You can increase debugging by adding a What might go wrong is that kubedock can't access the files that you want to copy over; e.g. if kubedock is running in a sidecar of some pipeline, you have to make sure that the whatever you want to copy over, is also available on that exact same location in the sidecar. In the tekton-example you can see it mounts the source in the sidecar as well, ensuring kubedock can access whatever is required if something needs to be copied over. |
Some testcontainers also annoyingly try to copy before starting e.g.
I'll try rewriting them to use |
One thing you can try is to start kubedock with Looking at the redpanda one; that seems to wait before starting the container until the file is actually present, which is a pattern that should work. |
Thanks,
I see that's what kubedock does to unpack the files within the container: kubedock/internal/backend/copy.go Line 37 in 5b30566
If I exec into the container and run that manually (obviously I don't have the actual stdin input though):
Also I don't see any configmaps (unless kubedock deletes them right after untar?) |
Hi, |
The error is caused because the user that is execution the tar command in the kafka pod (appuser, uid 1000) does not have permissions to write to /. This causes tar to exit with error code 2. Unfortunately, this is not something that can be fixed in kubedock. The configuration should be copied to another location instead, which requires a change (or maybe custom) kafka testcontainer. |
So far I missed this ticket, ending up with this workaround: withCreateContainerCmdModifier(cmd -> {
// force "root" user, so that the STARTER_SCRIPT written to / is then ran by "root" as "appuser"
cmd.withUser("0");
});
/*
* Override the default command injecting "su appuser -c"
* in order to work with kubedock, where the copy of STARTER_SCRIPT to /
* needs "root" permissions:
* while original docker api operates as root for "docker copy" command
* its kubedock counterpart (tar command) leverages the user of the container.
* OTOH the startup scripts are meant for "appuser".
*/
setCommand("-c", "while [ ! -f " + STARTER_SCRIPT + " ]; do sleep 0.1; done; su appuser -c " + STARTER_SCRIPT); where I really don't like it, but at least it works for confluentinc/cp-kafka:7.0.9 both on microk8s and plain docker, along with testcontainers 1.19.5 and 1.19.1. That said, I'm still looking for a better way to get it working. |
Thank you @davidecavestro for your temporary solution. I could adopt your approach but had difficulties to understand some parts until I could figure it out. To make it more clear for others, the content of the variable Furthermore, your code above:
didn't work for me. I had to do it slightly different with the bash executable as the first parameter:
|
Hi @joyrex2001,
We have a container that we would like to copy some files to before starting it (debezium)
We were using testcontainer's
withCopyToContainer
to copy these files in, which worked locally but did not work in k8s with kubedock. I found this thread where the same issue was being discussed:#1
So I updated our test to use
withFileSystemBind
instead, and while this worked locally it unfortunately didn't seem to work in k8s either.While investigating the issue, I notice that the debezium connector pod has a kubedock sidecar:
It looks like this is to do with the way the configmap is created.
As you can see the image cannot be pulled -- this is because
<my company>
is quite a large bank, so we very quickly get rate limited by docker hub when trying to pull images (all traffic from our infrastructure comes from a small range of IP addresses from the wider internet's perspective).Our solution to being rate limited is to cache images from docker hub in our own image repo (
eu.gcr.io/my-company/...
), and reference those ones instead of the public ones from docker hub. Is it possible to tell kubedock to use the cached GCR kubedock image when it spins up the sidecar instead of the docker hub one?Thanks!
The text was updated successfully, but these errors were encountered: