summaryrefslogtreecommitdiffstats
path: root/roles/openshift_logging_elasticsearch/templates/es.j2
blob: 7966d219e6a4a811005146cc329f9544de916511 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
apiVersion: "v1"
kind: "DeploymentConfig"
metadata:
  name: "{{deploy_name}}"
  labels:
    provider: openshift
    component: "{{component}}"
    deployment: "{{deploy_name}}"
    logging-infra: "{{logging_component}}"
spec:
  replicas: {{es_replicas|default(1)}}
  selector:
    provider: openshift
    component: "{{component}}"
    deployment: "{{deploy_name}}"
    logging-infra: "{{logging_component}}"
  strategy:
    type: Recreate
  template:
    metadata:
      name: "{{deploy_name}}"
      labels:
        logging-infra: "{{logging_component}}"
        provider: openshift
        component: "{{component}}"
        deployment: "{{deploy_name}}"
    spec:
      terminationGracePeriod: 600
      serviceAccountName: aggregated-logging-elasticsearch
      securityContext:
        supplementalGroups:
{% for group in es_storage_groups %}
        - {{group}}
{% endfor %}
{% if es_node_selector is iterable and es_node_selector | length > 0 %}
      nodeSelector:
{% for key, value in es_node_selector.iteritems() %}
        {{key}}: "{{value}}"
{% endfor %}
{% endif %}
      containers:
        - name: proxy
          image: {{ proxy_image }}
          imagePullPolicy: Always
          args:
           - --upstream-ca=/etc/elasticsearch/secret/admin-ca
           - --https-address=:4443
           - -provider=openshift
           - -client-id={{openshift_logging_elasticsearch_prometheus_sa}}
           - -client-secret-file=/var/run/secrets/kubernetes.io/serviceaccount/token
           - -cookie-secret={{ 16 | oo_random_word | b64encode }}
           - -upstream=https://localhost:9200
           - '-openshift-sar={"namespace": "{{ openshift_logging_elasticsearch_namespace}}", "verb": "view", "resource": "prometheus", "group": "metrics.openshift.io"}'
           - '-openshift-delegate-urls={"/": {"resource": "prometheus", "verb": "view", "group": "metrics.openshift.io", "namespace": "{{ openshift_logging_elasticsearch_namespace}}"}}'
           - --tls-cert=/etc/tls/private/tls.crt
           - --tls-key=/etc/tls/private/tls.key
           - -pass-access-token
           - -pass-user-headers
          ports:
          - containerPort: 4443
            name: proxy
            protocol: TCP
          volumeMounts:
          - mountPath: /etc/tls/private
            name: proxy-tls
            readOnly: true
          - mountPath: /etc/elasticsearch/secret
            name: elasticsearch
            readOnly: true
          resources:
            limits:
              memory: "{{openshift_logging_elasticsearch_proxy_memory_limit }}"
            requests:
              cpu: "{{openshift_logging_elasticsearch_proxy_cpu_request }}"
              memory: "{{openshift_logging_elasticsearch_proxy_memory_limit }}"
        -
          name: "elasticsearch"
          image: {{image}}
          imagePullPolicy: Always
          resources:
            limits:
{% if es_cpu_limit is defined and es_cpu_limit is not none and es_cpu_limit != '' %}
              cpu: "{{es_cpu_limit}}"
{% endif %}
              memory: "{{es_memory_limit}}"
            requests:
              cpu: "{{es_cpu_request}}"
              memory: "{{es_memory_limit}}"
{% if es_container_security_context %}
          securityContext: {{ es_container_security_context | to_yaml }}
{% endif %}
          ports:
            -
              containerPort: 9200
              name: "restapi"
            -
              containerPort: 9300
              name: "cluster"
          env:
            -
              name: "DC_NAME"
              value: "{{deploy_name}}"
            -
              name: "NAMESPACE"
              valueFrom:
                fieldRef:
                  fieldPath: metadata.namespace
            -
              name: "KUBERNETES_TRUST_CERT"
              value: "true"
            -
              name: "SERVICE_DNS"
              value: "logging-{{es_cluster_name}}-cluster"
            -
              name: "CLUSTER_NAME"
              value: "logging-{{es_cluster_name}}"
            -
              name: "INSTANCE_RAM"
              value: "{{openshift_logging_elasticsearch_memory_limit}}"
            -
              name: "HEAP_DUMP_LOCATION"
              value: "/elasticsearch/persistent/heapdump.hprof"
            -
              name: "NODE_QUORUM"
              value: "{{es_node_quorum | int}}"
            -
              name: "RECOVER_EXPECTED_NODES"
              value: "{{es_recover_expected_nodes}}"
            -
              name: "RECOVER_AFTER_TIME"
              value: "{{openshift_logging_elasticsearch_recover_after_time}}"
            -
              name: "READINESS_PROBE_TIMEOUT"
              value: "30"
            -
              name: "POD_LABEL"
              value: "component={{component}}"
            -
              name: "IS_MASTER"
              value: "{% if deploy_type in ['data-master', 'master'] %}true{% else %}false{% endif %}"

            -
              name: "HAS_DATA"
              value: "{% if deploy_type in ['data-master', 'data-client'] %}true{% else %}false{% endif %}"
            -
              name: "PROMETHEUS_USER"
              value: "{{openshift_logging_elasticsearch_prometheus_sa}}"

          volumeMounts:
            - name: elasticsearch
              mountPath: /etc/elasticsearch/secret
              readOnly: true
            - name: elasticsearch-config
              mountPath: /usr/share/java/elasticsearch/config
              readOnly: true
            - name: elasticsearch-storage
              mountPath: /elasticsearch/persistent
          readinessProbe:
            exec:
              command:
              - "/usr/share/java/elasticsearch/probe/readiness.sh"
            initialDelaySeconds: 10
            timeoutSeconds: 30
            periodSeconds: 5
      volumes:
        - name: proxy-tls
          secret:
            secretName: prometheus-tls
        - name: elasticsearch
          secret:
            secretName: logging-elasticsearch
        - name: elasticsearch-config
          configMap:
            name: logging-elasticsearch
        - name: elasticsearch-storage
{% if openshift_logging_elasticsearch_storage_type == 'pvc' %}
          persistentVolumeClaim:
            claimName: {{ openshift_logging_elasticsearch_pvc_name }}
{% elif openshift_logging_elasticsearch_storage_type == 'hostmount' %}
          hostPath:
            path: {{ openshift_logging_elasticsearch_hostmount_path }}
{% else %}
          emptydir: {}
{% endif %}