diff --git a/production/ksonnet/loki/common.libsonnet b/production/ksonnet/loki/common.libsonnet index eefc8c9e0dfa..f233a0c1eb3d 100644 --- a/production/ksonnet/loki/common.libsonnet +++ b/production/ksonnet/loki/common.libsonnet @@ -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), + }, } diff --git a/production/ksonnet/loki/config.libsonnet b/production/ksonnet/loki/config.libsonnet index d00fc6e80a1b..5389bdd697bc 100644 --- a/production/ksonnet/loki/config.libsonnet +++ b/production/ksonnet/loki/config.libsonnet @@ -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', @@ -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 {}, + }, }, diff --git a/production/ksonnet/loki/images.libsonnet b/production/ksonnet/loki/images.libsonnet index 71e3030d036b..fa7188c492fe 100644 --- a/production/ksonnet/loki/images.libsonnet +++ b/production/ksonnet/loki/images.libsonnet @@ -11,5 +11,6 @@ querier: self.loki, tableManager: self.loki, query_frontend: self.loki, + ruler: self.loki, }, } diff --git a/production/ksonnet/loki/loki.libsonnet b/production/ksonnet/loki/loki.libsonnet index 7714b6ee4300..141a2f8e073e 100644 --- a/production/ksonnet/loki/loki.libsonnet +++ b/production/ksonnet/loki/loki.libsonnet @@ -12,6 +12,7 @@ (import 'querier.libsonnet') + (import 'table-manager.libsonnet') + (import 'query-frontend.libsonnet') + +(import 'ruler.libsonnet') + // Supporting services (import 'memcached.libsonnet') diff --git a/production/ksonnet/loki/ruler.libsonnet b/production/ksonnet/loki/ruler.libsonnet new file mode 100644 index 000000000000..f769d2fd09bb --- /dev/null +++ b/production/ksonnet/loki/ruler.libsonnet @@ -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 {}, +}