@@ -19,10 +19,12 @@ job "api" {
1919 static = " ${ port_number } "
2020 }
2121
22- port "grpc " {
23- static = " ${ api_grpc_port } "
22+ port "api_internal_grpc " {
23+ static = " ${ api_internal_grpc_port } "
2424 }
2525
26+ port "grpc_api" {}
27+
2628 % { if prevent_colocation }
2729 port " scheduling-block" {
2830 // This port is used to block scheduling of jobs with the same block on the same node.
@@ -61,16 +63,39 @@ job "api" {
6163 }
6264
6365 service {
64- name = " api-grpc"
65- port = " grpc "
66+ name = " api-internal- grpc"
67+ port = " api_internal_grpc "
6668 task = " start"
6769
6870 check {
6971 type = " tcp"
70- name = " grpc"
72+ name = " api-internal-grpc"
73+ interval = " 3s"
74+ timeout = " 3s"
75+ port = " api_internal_grpc"
76+ }
77+ }
78+
79+ service {
80+ name = " grpc-api"
81+ port = " grpc_api"
82+ task = " start"
83+
84+ tags = [
85+ " traefik.enable=true" ,
86+ " traefik.http.routers.grpc-api.rule=HostRegexp(`grpc-api.{domain:.+}`)" ,
87+ " traefik.http.routers.grpc-api.ruleSyntax=v2" ,
88+ " traefik.http.routers.grpc-api.priority=500" ,
89+ " traefik.http.routers.grpc-api.service=grpc-api" ,
90+ " traefik.http.services.grpc-api.loadbalancer.server.scheme=h2c"
91+ ]
92+
93+ check {
94+ type = " tcp"
95+ name = " grpc-api"
7196 interval = " 3s"
7297 timeout = " 3s"
73- port = " grpc "
98+ port = " grpc_api "
7499 }
75100 }
76101
@@ -114,7 +139,8 @@ job "api" {
114139 NODE_ID = " $${node.unique.id}"
115140 NOMAD_TOKEN = " ${ nomad_acl_token } "
116141 ORCHESTRATOR_PORT = " ${ orchestrator_port } "
117- API_GRPC_PORT = " ${ api_grpc_port } "
142+ API_INTERNAL_GRPC_PORT = " ${ api_internal_grpc_port } "
143+ API_EDGE_GRPC_PORT = " $${NOMAD_PORT_grpc_api}"
118144 ADMIN_TOKEN = " ${ admin_token } "
119145 SANDBOX_ACCESS_TOKEN_HASH_SEED = " ${ sandbox_access_token_hash_seed } "
120146
@@ -164,7 +190,7 @@ job "api" {
164190 config {
165191 network_mode = " host"
166192 image = " ${ api_docker_image } "
167- ports = [" ${ port_name } " ]
193+ ports = [" ${ port_name } " , " grpc_api " ]
168194 args = [
169195 " --port" , " ${ port_number } " ,
170196 ]
0 commit comments