Search code examples
kuberneteskubernetes-helmkubernetes-ingresskubernetes-pod

create an ip alias for a sidecar


We have a sidecar running an API at localhost:myportnumber (lets say 8888 for this example), and we are trying to reference it from the main container in the same pod.

Does the main container need to be aware of the port the sidecar is running on? (like by creating an environment variable equal to 8888?)

Or is there a convenient way we can reference the sidecar using something similar to cluster ip (like namespace.servicename.sidecarname), or by creating a HostAlias?


Solution

  • Does the main container need to be aware of the port the sidecar is running on? (like by creating an environment variable equal to 8888?)

    Yes , sidecar containers share same network(IP,namespace) so you have to make main container aware of the port number on which it can reach the sidecar container.

    is there a convenient way we can reference the sidecar using something similar to cluster ip (like namespace.servicename.sidecarname), or by creating a HostAlias?

    I think DNS/similar things cannot be extended to containers that are running inside pods . because as mentioned above all the contianers inside a pod share same nework(IP , Network namespace)