es.j2 6.3 KB

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