Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Command running in kubernetes hangs

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?

like image 434
ogbofjnr Avatar asked Nov 06 '22 06:11

ogbofjnr


1 Answers

@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.

like image 165
bharat nc Avatar answered Nov 15 '22 06:11

bharat nc