es.j2 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. volumeMounts:
  115. - name: elasticsearch
  116. mountPath: /etc/elasticsearch/secret
  117. readOnly: true
  118. - name: elasticsearch-config
  119. mountPath: /usr/share/java/elasticsearch/config
  120. readOnly: true
  121. - name: elasticsearch-storage
  122. mountPath: /elasticsearch/persistent
  123. readinessProbe:
  124. exec:
  125. command:
  126. - "/usr/share/java/elasticsearch/probe/readiness.sh"
  127. initialDelaySeconds: 10
  128. timeoutSeconds: 30
  129. periodSeconds: 5
  130. -
  131. name: proxy
  132. image: {{ proxy_image }}
  133. imagePullPolicy: IfNotPresent
  134. args:
  135. - --upstream-ca=/etc/elasticsearch/secret/admin-ca
  136. - --https-address=:4443
  137. - -provider=openshift
  138. - -client-id=system:serviceaccount:{{ openshift_logging_elasticsearch_namespace }}:aggregated-logging-elasticsearch
  139. - -client-secret-file=/var/run/secrets/kubernetes.io/serviceaccount/token
  140. - -cookie-secret={{ 16 | lib_utils_oo_random_word | b64encode }}
  141. - -basic-auth-password={{ basic_auth_passwd }}
  142. - -upstream=https://localhost:9200
  143. - '-openshift-sar={"namespace": "{{ openshift_logging_elasticsearch_namespace}}", "verb": "view", "resource": "prometheus", "group": "metrics.openshift.io"}'
  144. - '-openshift-delegate-urls={"/": {"resource": "prometheus", "verb": "view", "group": "metrics.openshift.io", "namespace": "{{ openshift_logging_elasticsearch_namespace}}"}}'
  145. - --tls-cert=/etc/tls/private/tls.crt
  146. - --tls-key=/etc/tls/private/tls.key
  147. - -pass-access-token
  148. - -pass-user-headers
  149. ports:
  150. - containerPort: 4443
  151. name: proxy
  152. protocol: TCP
  153. volumeMounts:
  154. - mountPath: /etc/tls/private
  155. name: proxy-tls
  156. readOnly: true
  157. - mountPath: /etc/elasticsearch/secret
  158. name: elasticsearch
  159. readOnly: true
  160. resources:
  161. limits:
  162. memory: "{{openshift_logging_elasticsearch_proxy_memory_limit }}"
  163. requests:
  164. cpu: "{{openshift_logging_elasticsearch_proxy_cpu_request }}"
  165. memory: "{{openshift_logging_elasticsearch_proxy_memory_limit }}"
  166. volumes:
  167. - name: proxy-tls
  168. secret:
  169. secretName: prometheus-tls
  170. - name: elasticsearch
  171. secret:
  172. secretName: logging-elasticsearch
  173. - name: elasticsearch-config
  174. configMap:
  175. name: logging-elasticsearch
  176. - name: elasticsearch-storage
  177. {% if openshift_logging_elasticsearch_storage_type == 'pvc' %}
  178. persistentVolumeClaim:
  179. claimName: {{ openshift_logging_elasticsearch_pvc_name }}
  180. {% elif openshift_logging_elasticsearch_storage_type == 'hostmount' %}
  181. hostPath:
  182. path: {{ openshift_logging_elasticsearch_hostmount_path }}
  183. {% else %}
  184. emptydir: {}
  185. {% endif %}