Skip to content

Commit

Permalink
ensures components with required SRV lookups use the correct port (#4737
Browse files Browse the repository at this point in the history
)

* ensures components with required SRV lookups use the correct port naming (_grpclb prefix)

* Update production/ksonnet/loki/query-frontend.libsonnet

Co-authored-by: Ed Welch <ed@oqqer.com>

Co-authored-by: Ed Welch <ed@oqqer.com>
  • Loading branch information
owen-d and slim-bean authored Nov 11, 2021
1 parent 925de9e commit 0116aa6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
11 changes: 11 additions & 0 deletions production/ksonnet/loki/common.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,17 @@ local k = import 'ksonnet-util/kausal.libsonnet';
containerPort.new(name='grpc', port=9095),
],

// We use DNS SRV record for discovering the schedulers or the frontends if schedulers are disabled.
// These expect port names like _grpclb on the services.
grpclbDefaultPorts:: [
containerPort.new(name='http-metrics', port=$._config.http_listen_port),
containerPort.new(name='grpclb', port=9095),
],

// This helps ensure we create SRV records starting with _grpclb
grpclbServiceFor(deployment):: k.util.serviceFor(deployment, nameFormat='%(port)s'),


readinessProbe::
container.mixin.readinessProbe.httpGet.withPath('/ready') +
container.mixin.readinessProbe.httpGet.withPort($._config.http_listen_port) +
Expand Down
4 changes: 2 additions & 2 deletions production/ksonnet/loki/query-frontend.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ local k = import 'ksonnet-util/kausal.libsonnet';

query_frontend_container::
container.new('query-frontend', $._images.query_frontend) +
container.withPorts($.util.defaultPorts) +
container.withPorts($.util.grpclbDefaultPorts) +
container.withArgsMixin(k.util.mapToFlags($.query_frontend_args)) +
container.mixin.readinessProbe.httpGet.withPath('/ready') +
container.mixin.readinessProbe.httpGet.withPort($._config.http_listen_port) +
Expand Down Expand Up @@ -43,7 +43,7 @@ local k = import 'ksonnet-util/kausal.libsonnet';
local service = k.core.v1.service,

query_frontend_service:
k.util.serviceFor($.query_frontend_deployment) +
$.util.grpclbServiceFor($.query_frontend_deployment) +
// Make sure that query frontend worker, running in the querier, do resolve
// each query-frontend pod IP and NOT the service IP. To make it, we do NOT
// use the service cluster IP so that when the service DNS is resolved it
Expand Down
4 changes: 2 additions & 2 deletions production/ksonnet/loki/query-scheduler.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ local k = import 'ksonnet-util/kausal.libsonnet';
local container = k.core.v1.container,
query_scheduler_container:: if $._config.query_scheduler_enabled then
container.new('query-scheduler', $._images.query_scheduler) +
container.withPorts($.util.defaultPorts) +
container.withPorts($.util.grpclbDefaultPorts) +
container.withArgsMixin(k.util.mapToFlags($.query_scheduler_args)) +
$.jaeger_mixin +
k.util.resourcesRequests('2', '600Mi') +
Expand All @@ -58,7 +58,7 @@ local k = import 'ksonnet-util/kausal.libsonnet';

// Headless to make sure resolution gets IP address of target pods, and not service IP.
query_scheduler_discovery_service: if !$._config.query_scheduler_enabled then {} else
k.util.serviceFor($.query_scheduler_deployment) +
$.util.grpclbServiceFor($.query_scheduler_deployment) +
service.mixin.spec.withPublishNotReadyAddresses(true) +
service.mixin.spec.withClusterIp('None') +
service.mixin.metadata.withName('query-scheduler-discovery'),
Expand Down

0 comments on commit 0116aa6

Please sign in to comment.