netflix eureka - Can a kubernetes Deployment inject the service nodeport as an environment variable? -
inside service yaml file, can use jsonpath select named nodeport value so:
- name: my_node_port valuefrom: fieldref: fieldpath: spec.ports[?(@.name=="http")].nodeport
however, in deployment yaml file, have environment variable my_node_port
above exposed container pod. happen have combined service , deployment single file me kubectl create -f
. possible select named service nodeport in deployment section, rather in service section?
my purpose register kubernetes service , deployment legacy service discovery mechanism, in case netflix oss eureka.
you automatically have number of environment variables in containers. need make sure service created before deployment.
as example, service named mysql (in same namespace) have variables this:
mysql_port="tcp://10.96.0.3:3306" mysql_port_3306_tcp="tcp://10.96.0.3:3306" mysql_port_3306_tcp_addr="10.96.0.3" mysql_port_3306_tcp_port="3306" mysql_port_3306_tcp_proto="tcp" mysql_service_host="10.96.0.3" mysql_service_port="3306" mysql_service_port_mysql="3306"
as alternative can make use of cluster dns service special attention srv records).
Comments
Post a Comment