es-statefulset.yaml 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. # RBAC authn and authz
  2. apiVersion: v1
  3. kind: ServiceAccount
  4. metadata:
  5. name: elasticsearch-logging
  6. namespace: public-service
  7. labels:
  8. k8s-app: elasticsearch-logging
  9. addonmanager.kubernetes.io/mode: Reconcile
  10. ---
  11. kind: ClusterRole
  12. apiVersion: rbac.authorization.k8s.io/v1
  13. metadata:
  14. name: elasticsearch-logging
  15. labels:
  16. k8s-app: elasticsearch-logging
  17. addonmanager.kubernetes.io/mode: Reconcile
  18. rules:
  19. - apiGroups:
  20. - ""
  21. resources:
  22. - "services"
  23. - "namespaces"
  24. - "endpoints"
  25. verbs:
  26. - "get"
  27. ---
  28. kind: ClusterRoleBinding
  29. apiVersion: rbac.authorization.k8s.io/v1
  30. metadata:
  31. namespace: public-service
  32. name: elasticsearch-logging
  33. labels:
  34. k8s-app: elasticsearch-logging
  35. addonmanager.kubernetes.io/mode: Reconcile
  36. subjects:
  37. - kind: ServiceAccount
  38. name: elasticsearch-logging
  39. namespace: public-service
  40. apiGroup: ""
  41. roleRef:
  42. kind: ClusterRole
  43. name: elasticsearch-logging
  44. apiGroup: ""
  45. ---
  46. # Elasticsearch deployment itself
  47. apiVersion: apps/v1
  48. kind: StatefulSet
  49. metadata:
  50. name: elasticsearch-logging
  51. namespace: public-service
  52. labels:
  53. k8s-app: elasticsearch-logging
  54. version: v7.4.2
  55. addonmanager.kubernetes.io/mode: Reconcile
  56. spec:
  57. serviceName: elasticsearch-logging
  58. replicas: 1
  59. selector:
  60. matchLabels:
  61. k8s-app: elasticsearch-logging
  62. version: v7.4.2
  63. template:
  64. metadata:
  65. labels:
  66. k8s-app: elasticsearch-logging
  67. version: v7.4.2
  68. spec:
  69. serviceAccountName: elasticsearch-logging
  70. containers:
  71. - image: quay.io/fluentd_elasticsearch/elasticsearch:v7.4.2
  72. name: elasticsearch-logging
  73. imagePullPolicy: Always
  74. resources:
  75. # need more cpu upon initialization, therefore burstable class
  76. limits:
  77. cpu: 1000m
  78. memory: 3Gi
  79. requests:
  80. cpu: 100m
  81. memory: 1Gi
  82. ports:
  83. - containerPort: 9200
  84. name: db
  85. protocol: TCP
  86. - containerPort: 9300
  87. name: transport
  88. protocol: TCP
  89. livenessProbe:
  90. tcpSocket:
  91. port: transport
  92. initialDelaySeconds: 5
  93. timeoutSeconds: 10
  94. readinessProbe:
  95. tcpSocket:
  96. port: transport
  97. initialDelaySeconds: 5
  98. timeoutSeconds: 10
  99. volumeMounts:
  100. - name: elasticsearch-logging
  101. mountPath: /data
  102. env:
  103. - name: "NAMESPACE"
  104. valueFrom:
  105. fieldRef:
  106. fieldPath: metadata.namespace
  107. volumes:
  108. - name: elasticsearch-logging
  109. emptyDir: {}
  110. # Elasticsearch requires vm.max_map_count to be at least 262144.
  111. # If your OS already sets up this number to a higher value, feel free
  112. # to remove this init container.
  113. initContainers:
  114. - image: alpine:3.6
  115. command: ["/sbin/sysctl", "-w", "vm.max_map_count=262144"]
  116. name: elasticsearch-logging-init
  117. securityContext:
  118. privileged: true