Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit ada12a9

Browse files
authored
Merge pull request #153 from grafana/duologic/k8s-alpha
refactor(cortex): use first class citizens
2 parents 3b28551 + 031339c commit ada12a9

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

cortex/consul.libsonnet

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,13 @@ local consul = import 'consul/consul.libsonnet';
2929
local deployment = $.apps.v1.deployment,
3030
local podAntiAffinity = deployment.mixin.spec.template.spec.affinity.podAntiAffinity,
3131
local volume = $.core.v1.volume,
32+
33+
// backwards compatibility with ksonnet
34+
local podAffinityTerm =
35+
if std.objectHasAll($.core.v1, 'podAffinityTerm')
36+
then $.core.v1.podAffinityTerm
37+
else podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecutionType,
38+
3239
consul_deployment+:
3340

3441
// Keep the consul state on a ramdisk, as they are ephemeral to us.
@@ -41,10 +48,9 @@ local consul = import 'consul/consul.libsonnet';
4148
// Ensure Consul is not scheduled on the same host as an ingester
4249
// (in any namespace - hence other_namespaces).
4350
podAntiAffinity.withRequiredDuringSchedulingIgnoredDuringExecutionMixin([
44-
podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecutionType.new() +
45-
podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecutionType.mixin.labelSelector.withMatchLabels({ name: 'ingester' }) +
46-
podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecutionType.withNamespaces([$._config.namespace] + $._config.other_namespaces) +
47-
podAntiAffinity.requiredDuringSchedulingIgnoredDuringExecutionType.withTopologyKey('kubernetes.io/hostname'),
51+
podAffinityTerm.mixin.labelSelector.withMatchLabels({ name: 'ingester' }) +
52+
podAffinityTerm.withNamespaces([$._config.namespace] + $._config.other_namespaces) +
53+
podAffinityTerm.withTopologyKey('kubernetes.io/hostname'),
4854
]) +
4955

5056
$.util.podPriority('high'),

cortex/gossip.libsonnet

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,13 @@
6363
// During migration to gossip, it may be useful to use distributors instead, since they are restarted faster.
6464
gossip_ring_service:
6565
local service = $.core.v1.service;
66-
local servicePort = service.mixin.spec.portsType;
66+
67+
// backwards compatibility with ksonnet
68+
local servicePort =
69+
if std.objectHasAll($.core.v1, 'servicePort')
70+
then $.core.v1.servicePort
71+
else service.mixin.spec.portsType;
72+
6773
local ports = [
6874
servicePort.newNamed('gossip-ring', gossipRingPort, gossipRingPort) +
6975
servicePort.withProtocol('TCP'),

0 commit comments

Comments
 (0)