Browse Source

Adding anti affinity configurations for ES and kibana pods

Eric Wolinetz 7 years ago
parent
commit
73f0ba45e2

+ 26 - 0
roles/openshift_logging_elasticsearch/templates/2.x/es.j2

@@ -27,6 +27,32 @@ spec:
         component: "{{component}}"
         deployment: "{{deploy_name}}"
     spec:
+      affinity:
+        podAntiAffinity:
+          requiredDuringSchedulingIgnoredDuringExecution:
+          - labelSelector:
+              matchExpressions:
+              - key: logging-infra
+                operator: In
+                values:
+                - elasticsearch
+            topologyKey: kubernetes.io/hostname
+{% if openshift_infra_anti_affinity_labels is defined and openshift_infra_anti_affinity_labels is iterable and openshift_infra_anti_affinity_labels | length > 0 %}
+          preferredDuringSchedulingIgnoredDuringExecution:
+          - weight: 100
+            podAffinityTerm:
+              labelSelector:
+                matchExpressions:
+{% for aa_key, aa_values in openshift_infra_anti_affinity_labels.items() %}
+                - key: "{{ aa_key }}"
+                  operator: In
+                  values:
+{% for aa_value in aa_values %}
+                  - "{{ aa_value }}"
+{% endfor %}
+{% endfor %}
+              topologyKey: kubernetes.io/hostname
+{% endif %}
       terminationGracePeriod: 600
       serviceAccountName: aggregated-logging-elasticsearch
       securityContext:

+ 26 - 0
roles/openshift_logging_elasticsearch/templates/5.x/es.j2

@@ -27,6 +27,32 @@ spec:
         component: "{{component}}"
         deployment: "{{deploy_name}}"
     spec:
+      affinity:
+        podAntiAffinity:
+          requiredDuringSchedulingIgnoredDuringExecution:
+          - labelSelector:
+              matchExpressions:
+              - key: logging-infra
+                operator: In
+                values:
+                - elasticsearch
+            topologyKey: kubernetes.io/hostname
+{% if openshift_infra_anti_affinity_labels is defined and openshift_infra_anti_affinity_labels is iterable and openshift_infra_anti_affinity_labels | length > 0 %}
+          preferredDuringSchedulingIgnoredDuringExecution:
+          - weight: 100
+            podAffinityTerm:
+              labelSelector:
+                matchExpressions:
+{% for aa_key, aa_values in openshift_infra_anti_affinity_labels.items() %}
+                - key: "{{ aa_key }}"
+                  operator: In
+                  values:
+{% for aa_value in aa_values %}
+                  - "{{ aa_value }}"
+{% endfor %}
+{% endfor %}
+              topologyKey: kubernetes.io/hostname
+{% endif %}
       terminationGracePeriod: 600
       serviceAccountName: aggregated-logging-elasticsearch
       securityContext:

+ 26 - 0
roles/openshift_logging_kibana/templates/2.x/kibana.j2

@@ -26,6 +26,32 @@ spec:
         provider: openshift
         component: "{{ component }}"
     spec:
+      affinity:
+        podAntiAffinity:
+          requiredDuringSchedulingIgnoredDuringExecution:
+          - labelSelector:
+              matchExpressions:
+              - key: logging-infra
+                operator: In
+                values:
+                - kibana
+            topologyKey: kubernetes.io/hostname
+{% if openshift_infra_anti_affinity_labels is defined and openshift_infra_anti_affinity_labels is iterable and openshift_infra_anti_affinity_labels | length > 0 %}
+            preferredDuringSchedulingIgnoredDuringExecution:
+            - weight: 100
+              podAffinityTerm:
+                labelSelector:
+                  matchExpressions:
+{% for aa_key, aa_values in openshift_infra_anti_affinity_labels.items() %}
+                  - key: "{{ aa_key }}"
+                    operator: In
+                    values:
+{% for aa_value in aa_values %}
+                    - "{{ aa_value }}"
+{% endfor %}
+{% endfor %}
+                topologyKey: kubernetes.io/hostname
+{% endif %}
       serviceAccountName: aggregated-logging-kibana
 {% if kibana_node_selector is iterable and kibana_node_selector | length > 0 %}
       nodeSelector:

+ 26 - 0
roles/openshift_logging_kibana/templates/5.x/kibana.j2

@@ -26,6 +26,32 @@ spec:
         provider: openshift
         component: "{{ component }}"
     spec:
+      affinity:
+        podAntiAffinity:
+          requiredDuringSchedulingIgnoredDuringExecution:
+          - labelSelector:
+              matchExpressions:
+              - key: logging-infra
+                operator: In
+                values:
+                - kibana
+            topologyKey: kubernetes.io/hostname
+{% if openshift_infra_anti_affinity_labels is defined and openshift_infra_anti_affinity_labels is iterable and openshift_infra_anti_affinity_labels | length > 0 %}
+            preferredDuringSchedulingIgnoredDuringExecution:
+            - weight: 100
+              podAffinityTerm:
+                labelSelector:
+                  matchExpressions:
+{% for aa_key, aa_values in openshift_infra_anti_affinity_labels.items() %}
+                  - key: "{{ aa_key }}"
+                    operator: In
+                    values:
+{% for aa_value in aa_values %}
+                    - "{{ aa_value }}"
+{% endfor %}
+{% endfor %}
+                topologyKey: kubernetes.io/hostname
+{% endif %}
       serviceAccountName: aggregated-logging-kibana
 {% if kibana_node_selector is iterable and kibana_node_selector | length > 0 %}
       nodeSelector: