I have a pod with a database running. My goal is to initialize the db with k8s Job using Helm Hooks.
I have managed to set up the Job with the schema script.
Unfortunately I have some issues with connecting from command
of Job to the existing Pod.
Here's my error:
Connection error: ('Unable to connect to any servers', {'127.0.0.1': error(111, "Tried connecting to [('127.0.0.1', 9042)]. Last error: Connection refused")}]
On the Pod I have Cassandra container running, on my Job I'm using the following command:
command: ["/bin/sh", "-c", "cqlsh -f /path/to/schema.cql"]
Do I have to define somehow the way to connect to the Pod? I have a Service with Cassandra running as well.
Helm hook creates a new pod as part of the hook.You can not use 127.0.0.1
or localhost
to connect to a pod from another pod because they are in different.network namespace. You should use the <PODIP>:9042
or if the pod is exposed by a service then use the service name ie <service-name>.<namespace-name>.svc.cluster.local:9042
Alternative to helm hook you can use an initcontainer wherein you can use 127.0.0.1
or localhost
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.