contrib/kube-prometheus: Set podAntiAffinity for Prometheus & Alertmanager
contrib/kube-prometheus: Generate new manifests with antiAffinity contrib/kube-prometheus: jb update Documentation: Generate after updating kube-prometheus manifests contrib/kube-prometheus: Move antiaffinity into own jsonnet file foobar
This commit is contained in:
@@ -0,0 +1,39 @@
|
|||||||
|
local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
||||||
|
local statefulSet = k.apps.v1beta2.statefulSet;
|
||||||
|
local affinity = statefulSet.mixin.spec.template.spec.affinity.podAntiAffinity.preferredDuringSchedulingIgnoredDuringExecutionType;
|
||||||
|
local matchExpression = affinity.mixin.podAffinityTerm.labelSelector.matchExpressionsType;
|
||||||
|
|
||||||
|
{
|
||||||
|
local antiaffinity(key, values) = {
|
||||||
|
affinity: {
|
||||||
|
podAntiAffinity: {
|
||||||
|
preferredDuringSchedulingIgnoredDuringExecution: [
|
||||||
|
affinity.new() +
|
||||||
|
affinity.withWeight(100) +
|
||||||
|
affinity.mixin.podAffinityTerm.withNamespaces($._config.namespace) +
|
||||||
|
affinity.mixin.podAffinityTerm.withTopologyKey('kubernetes.io/hostname') +
|
||||||
|
affinity.mixin.podAffinityTerm.labelSelector.withMatchExpressions([
|
||||||
|
matchExpression.new() +
|
||||||
|
matchExpression.withKey(key) +
|
||||||
|
matchExpression.withOperator('In') +
|
||||||
|
matchExpression.withValues(values),
|
||||||
|
]),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
alertmanager+:: {
|
||||||
|
alertmanager+: {
|
||||||
|
spec+:
|
||||||
|
antiaffinity('alertmanager', [$._config.alertmanager.name]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
prometheus+: {
|
||||||
|
prometheus+: {
|
||||||
|
spec+:
|
||||||
|
antiaffinity('prometheus', [$._config.prometheus.name]),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
}
|
@@ -144,12 +144,14 @@ local k = import 'ksonnet/ksonnet.beta.3/k.libsonnet';
|
|||||||
local roleList = k.rbac.v1.roleList;
|
local roleList = k.rbac.v1.roleList;
|
||||||
roleList.new([newSpecificRole(x) for x in $._config.prometheus.namespaces]),
|
roleList.new([newSpecificRole(x) for x in $._config.prometheus.namespaces]),
|
||||||
prometheus:
|
prometheus:
|
||||||
local container = k.core.v1.pod.mixin.spec.containersType;
|
local statefulSet = k.apps.v1beta2.statefulSet;
|
||||||
|
local container = statefulSet.mixin.spec.template.spec.containersType;
|
||||||
local resourceRequirements = container.mixin.resourcesType;
|
local resourceRequirements = container.mixin.resourcesType;
|
||||||
local selector = k.apps.v1beta2.deployment.mixin.spec.selectorType;
|
local selector = statefulSet.mixin.spec.selectorType;
|
||||||
|
|
||||||
local resources = resourceRequirements.new() +
|
local resources =
|
||||||
resourceRequirements.withRequests({ memory: '400Mi' });
|
resourceRequirements.new() +
|
||||||
|
resourceRequirements.withRequests({ memory: '400Mi' });
|
||||||
|
|
||||||
{
|
{
|
||||||
apiVersion: 'monitoring.coreos.com/v1',
|
apiVersion: 'monitoring.coreos.com/v1',
|
||||||
|
Reference in New Issue
Block a user