Allow K8S container to talk to Docker container outside of its cluster

Asking for help? Comment out what you need so we can get more information to help you!

I have a python script as part of a Docker image that is trying to create an exchange in a RabbitMQ server. I use this image to create a container, but since the RabbitMQ server is in a Docker container outside of the k8s cluster, I receive the error “Connection Refused”. How can I redirect the message from the k8s container to reach the RabbitMQ Docker container?

Cluster information:

Kubernetes version: 1.21.2
Cloud being used: (put bare-metal if not on a public cloud)
Installation method:
Host OS:
CNI and version:
CRI and version:

You can format your yaml by highlighting it and pressing Ctrl-Shift-C, it will make your output easier to read.