So now that we saw all these different ways
of connecting pods and containers,
the question of course is, which approach is the best one
and how can we finalize this picture
and make sure the tasks API also works?
Well regarding the best approach,
it of course depends on whether you wanna
have two containers in the same pod or not.
And in most cases you don't wanna
have multiple containers per pod.
You can have it, but you should really only do that,
if two containers are tightly coupled,
with each other, if some container also interacts
with another container in another pod, like we have it here
you definitely do wanna have that container
in a separate pod, which is why we are working
with free pods here,
and not just to pause as planned initially.
Now, when it comes to connecting pods
with each other, then we got three different options,
we of course need services for the different pods,
that's always the case
because that gives us stable IP addresses,
even if it's just a cluster internal IP address,
but then when it comes to sending requests
to that service, we can either look up the IP address
on our own and then use it in our code.
For example, through an environment variable,
or we use the automatically generated environment variables,
a feature Kubernetes has built in, to give us access
to the IP addresses, of the different services
our cluster has,
or we use the automatically generated domain names,
these names are all generated for every service,
which is launched in a cluster,
and we can use that domain name from inside the cluster
to send the request there.
So these are the different options we got there,
and the domain names are the most common way
of connecting pause here,
because they are easy to remember, easy to add,
you don't need to fiddle around with environment variables,
if you don't want to hear, I do want to make this work both
in Kubernetes and with docker-compose,
but even then, it's simply a bit easier
than looking up an IP address manually,
or typing this longer auto-generated environment variable.
Ultimately of course, you can choose your favorite approach
and then connect the pods
and containers as it best works for you,
with that however we are, of course not done,
we also want to deploy this tasks, API, the tasks container
and make sure it's able to talk to the auth API as well.
And I would say that's a great exercise for you,
so definitely try doing this
on your own first, create a deployment for that,
create a service, make sure to tasks API
can be reached from outside the cluster,
but also make sure it's able to talk to the auth API.
We're going to implement it together in the next lecture.