I am deploying simple hello-world microservice that listens on port given by following variable:
PORT = os.environ.get("TEST_SERVICE_PORT", "").strip() or "50001"
I deployed it without configuring any variables on container, and expected it to serve on default 50001 port, but instead got error
socket.gaierror: [Errno -8] Servname not supported for ai_socktype
When I logged into container and checked environment, I found out that evironment is filled with different variables (some of them belong to other services), and TEST_SERVICE_PORT
variable exists and contains definitely not port:
root@test-service-697464787c-xpd6k:/opt/app/src# env | grep TEST
TEST_SERVICE_PORT_7002_TCP_ADDR=10.145.23.43
TEST_SERVICE_SERVICE_PORT_GRPC_API=7002
TEST_SERVICE_PORT_7002_TCP_PORT=7002
TEST_SERVICE_PORT=tcp://10.145.23.43:7002
TEST_SERVICE_SERVICE_HOST=10.145.23.43
TEST_SERVICE_PORT_7002_TCP=tcp://10.145.23.43:7002
TEST_SERVICE_PORT_7002_TCP_PROTO=tcp
TEST_SERVICE_SERVICE_PORT=7002
I have following questions and were not able find answers to them in documentation:
What created this variables? Could I somehow isolate container from them? Or are they set intentionally by kubernetes, and serve some purpose I don't know about? How should I name my configuration variables to avoid naming collisions? Should I use that variables istead of using services names as hostnames?
There is following documentation, but it only explains variable TEST_SERVICE_SERVICE_PORT
and TEST_SERVICE_SERVICE_HOST
. What TEST_SERVICE_PORT
and others mean then? What adds TEST_SERVICE_SERVICE_PORT_GRPC_API
?
There is also Istio and Ambassador gateway installed on cluster that I'm using.