es.j2 6.7 KB

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