I need to run a command in clickhouse database in kubernetes.
When I try it with docker it works ok:
docker run -it yandex/clickhouse-client -h 172.19.0.1 --database=test --query="SYSTEM RELOAD DICTIONARIES"
but when I run it in kub:
kubectl run --quiet -it --rm clickhouse-client --image=yandex/clickhouse-client -- -h clickhouse-server --database=test --query="SYSTEM RELOAD DICTIONARIES"
Second command hangs. The pod is in CrashLoopBackOff with Back-off restarting failed container/ And the logs of container contains the result of query.
Why do the result not flushed to tty?
This command works for me:
kubectl run busybox --quiet -it --rm --restart=Never --image=busybox -- nslookup foobar
What is the difference with click-house client?
@ogbofjnr this is likely because the pod is getting killed as soon as your query is done. Kubernetes will restart the pod, and it will again die after executing the query. This is why you are seeing a restart loop.
For busy box, the entrypoint is a long running command like sleep 3600 https://github.com/kubernetes/kubernetes/blob/master/hack/testdata/recursive/pod/pod/busybox.yaml#L10-L12.
You should either try something similar or try Kubernetes cron job if the idea is to run the query on a schedule.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With