Skip to content

Commit

Permalink
Jsonnet/ruler (#2560)
Browse files Browse the repository at this point in the history
* ruler jsonnet

* jsonnet fixes
  • Loading branch information
owen-d authored Aug 27, 2020
1 parent 0a0ad68 commit f6f83fe
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 0 deletions.
8 changes: 8 additions & 0 deletions production/ksonnet/loki/common.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@

util+:: {
local containerPort = $.core.v1.containerPort,
local container = $.core.v1.container,

defaultPorts::
[
containerPort.new(name='http-metrics', port=$._config.http_listen_port),
containerPort.new(name='grpc', port=9095),
],

readinessProbe::
container.mixin.readinessProbe.httpGet.withPath('/ready') +
container.mixin.readinessProbe.httpGet.withPort($._config.http_listen_port) +
container.mixin.readinessProbe.withInitialDelaySeconds(15) +
container.mixin.readinessProbe.withTimeoutSeconds(1),

},
}
25 changes: 25 additions & 0 deletions production/ksonnet/loki/config.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
table_prefix: $._config.namespace,
index_period_hours: 168, // 1 week

ruler_enabled: false,

// Bigtable variables
bigtable_instance: error 'must specify bigtable instance',
bigtable_project: error 'must specify bigtable project',
Expand Down Expand Up @@ -308,6 +310,29 @@
},
},
},

ruler: if $._config.ruler_enabled then {
rule_path: '/tmp/rules',
enable_api: true,
alertmanager_url: 'http://alertmanager.%s.svc.cluster.local/alertmanager' % $._config.namespace,
enable_sharding: true,
enable_alertmanager_v2: true,
ring: {
kvstore: {
store: 'consul',
consul: {
host: 'consul.%s.svc.cluster.local:8500' % $._config.namespace,
},
},
},
storage+: {
type: 'gcs',
gcs+: {
bucket_name: '%(cluster)s-%(namespace)s-ruler' % $._config,
},
},
} else {},

},
},

Expand Down
1 change: 1 addition & 0 deletions production/ksonnet/loki/images.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,6 @@
querier: self.loki,
tableManager: self.loki,
query_frontend: self.loki,
ruler: self.loki,
},
}
1 change: 1 addition & 0 deletions production/ksonnet/loki/loki.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
(import 'querier.libsonnet') +
(import 'table-manager.libsonnet') +
(import 'query-frontend.libsonnet') +
(import 'ruler.libsonnet') +

// Supporting services
(import 'memcached.libsonnet')
37 changes: 37 additions & 0 deletions production/ksonnet/loki/ruler.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
local container = $.core.v1.container,

ruler_args:: $._config.commonArgs {
target: 'ruler',
},

ruler_container::
if $._config.ruler_enabled then
container.new('ruler', $._images.ruler) +
container.withPorts($.util.defaultPorts) +
container.withArgsMixin($.util.mapToFlags($.ruler_args)) +
$.util.resourcesRequests('1', '6Gi') +
$.util.resourcesLimits('16', '16Gi') +
$.util.readinessProbe +
$.jaeger_mixin
else {},

local deployment = $.apps.v1.deployment,

ruler_deployment:
if $._config.ruler_enabled then
deployment.new('ruler', 2, [$.ruler_container]) +
deployment.mixin.spec.template.spec.withTerminationGracePeriodSeconds(600) +
$.config_hash_mixin +
$.util.configVolumeMount('loki', '/etc/loki/config') +
$.util.configVolumeMount('overrides', '/etc/loki/overrides') +
$.util.antiAffinity
else {},

local service = $.core.v1.service,

ruler_service:
if $._config.ruler_enabled then
$.util.serviceFor($.ruler_deployment)
else {},
}

0 comments on commit f6f83fe

Please sign in to comment.