Just like the Sidecar pattern, the Ambassador is a container that runs in the same Pod that the application container runs.
Basically, the Ambassador works as a proxy, it handles all the requests coming from the application.
One of the main advantages of this pattern is that there is no need that the application container knows the external services URLs, he will always communicate through localhost
with the Ambassador.
The Ambassador is responsible to discover
the external service address (this process is also knows as Service Discovery
).
- We have a
StatefulSet
defining 3 replicas of aredis
container; - Also, there is a
Service
calledredis-svc
to expose the containers to the cluster; - We're using twemproxy to act as a proxy to the redis containers;
- Lastly, we defined a
Pod
calledambassador-example
. It defines two containers:nginx
: our client application that needs to communicate with theredis
twemproxy
: who will send the request to one of the redis containers.
As you may see in the above image. All the requests coming from the application are send through localhost to the Ambassador (twemproxy
).