Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ensures components with required SRV lookups use the correct port #4737

Merged
merged 2 commits into from
Nov 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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