Loki microservices Tanka: fix error during manifest generation (#9362)

**What this PR does / why we need it**:
Fixes an error on the ServiceMonitor generated when
```
memberlist_ring_enabled: true,
create_service_monitor: true,
```
It also adds some checks on `memberlist.libsonnet` to avoid generating
invalid kubernetes manifests.

**Which issue(s) this PR fixes**:
Fixes #9361
pull/9155/head^2
irizzant 2 years ago committed by GitHub
parent 25c4b4ce35
commit 3478e18021
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      production/ksonnet/loki/memberlist.libsonnet
  2. 2
      production/ksonnet/loki/servicemonitor.libsonnet

@ -121,7 +121,7 @@
compactor_statefulset+: if !$._config.memberlist_ring_enabled then {} else gossipLabel,
distributor_deployment+: if !$._config.memberlist_ring_enabled then {} else gossipLabel,
index_gateway_statefulset+: if !$._config.memberlist_ring_enabled then {} else gossipLabel,
index_gateway_statefulset+: if !$._config.memberlist_ring_enabled || !$._config.use_index_gateway then {} else gossipLabel,
ingester_statefulset: if $._config.multi_zone_ingester_enabled && !$._config.multi_zone_ingester_migration_enabled then {} else
(super.ingester_statefulset + if !$._config.memberlist_ring_enabled then {} else gossipLabel),
ingester_zone_a_statefulset+:
@ -136,7 +136,7 @@
if $._config.multi_zone_ingester_enabled && $._config.memberlist_ring_enabled
then gossipLabel
else {},
query_scheduler_deployment+: if !$._config.memberlist_ring_enabled then {} else gossipLabel,
query_scheduler_deployment+: if !$._config.memberlist_ring_enabled || !$._config.query_scheduler_enabled then {} else gossipLabel,
ruler_deployment+: if !$._config.memberlist_ring_enabled || !$._config.ruler_enabled || $._config.stateful_rulers then {} else gossipLabel,
ruler_statefulset+: if !$._config.memberlist_ring_enabled || !$._config.ruler_enabled || !$._config.stateful_rulers then {} else gossipLabel,
// Headless service (= no assigned IP, DNS returns all targets instead) pointing to gossip network members.

@ -41,7 +41,7 @@
values: [
this[name].spec.selector.name
for name in std.objectFields(this)
if std.isObject(this[name]) && std.objectHas(this[name], 'kind') && this[name].kind == 'Service'
if std.isObject(this[name]) && std.objectHas(this[name], 'kind') && this[name].kind == 'Service' && std.objectHasAll(this[name].spec.selector, 'name')
],
}],
},

Loading…
Cancel
Save