mattyh88
mattyh88

Reputation: 1645

How can I refer to my mysql container in the same pod?

I have a Kubernetes deployment.yml file that includes a container setup for:

I have some environment variables set for my php-fpm container:

I'm wondering how I can set the DB_HOST env var to link to my MySQL container (running in the same pod as my nginx & php-fpm containers).

Or should I create a new pod for my MySQL container as then I can create a 'service' from that pod and refer to the MySQL service name?

Thanks!

Upvotes: 0

Views: 227

Answers (1)

wargre
wargre

Reputation: 4753

It is a real bad practice to setup 2 'business' container in one pod (scale you stuff individually is better than scaling everything, pod can be started on different host, ...).

Anyway, a pod share network across the container, so you can use localhost as hostname if you really want to set everything in one pod.

But yes it is really better to set 1 statefulset for mysql and use the name in php-fpm

Upvotes: 2

Related Questions