StatefulSet.yaml 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. apiVersion: apps/v1
  2. kind: StatefulSet
  3. metadata:
  4. name: {{ include "emqx.fullname" . }}
  5. namespace: {{ .Release.Namespace }}
  6. labels:
  7. app.kubernetes.io/name: {{ include "emqx.name" . }}
  8. helm.sh/chart: {{ include "emqx.chart" . }}
  9. app.kubernetes.io/instance: {{ .Release.Name }}
  10. app.kubernetes.io/managed-by: {{ .Release.Service }}
  11. spec:
  12. serviceName: {{ include "emqx.fullname" . }}-headless
  13. podManagementPolicy: {{ .Values.podManagementPolicy }}
  14. {{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
  15. volumeClaimTemplates:
  16. - metadata:
  17. name: emqx-data
  18. namespace: {{ .Release.Namespace }}
  19. labels:
  20. app.kubernetes.io/name: {{ include "emqx.name" . }}
  21. app.kubernetes.io/instance: {{ .Release.Name }}
  22. app.kubernetes.io/managed-by: {{ .Release.Service }}
  23. spec:
  24. {{- if .Values.persistence.storageClassName }}
  25. storageClassName: {{ .Values.persistence.storageClassName | quote }}
  26. {{- end }}
  27. accessModes:
  28. - {{ .Values.persistence.accessMode | quote }}
  29. resources:
  30. requests:
  31. storage: {{ .Values.persistence.size | quote }}
  32. {{- end }}
  33. updateStrategy:
  34. type: RollingUpdate
  35. {{- if .Values.minReadySeconds }}
  36. minReadySeconds: {{ .Values.minReadySeconds }}
  37. {{- end }}
  38. replicas: {{ .Values.replicaCount }}
  39. selector:
  40. matchLabels:
  41. app.kubernetes.io/name: {{ include "emqx.name" . }}
  42. app.kubernetes.io/instance: {{ .Release.Name }}
  43. template:
  44. metadata:
  45. labels:
  46. app: {{ include "emqx.name" . }}
  47. version: {{ .Chart.AppVersion }}
  48. app.kubernetes.io/name: {{ include "emqx.name" . }}
  49. app.kubernetes.io/instance: {{ .Release.Name }}
  50. annotations:
  51. {{- with .Values.podAnnotations }}
  52. {{- toYaml . | nindent 8 }}
  53. {{- end }}
  54. {{- if .Values.recreatePods }}
  55. checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum | quote }}
  56. {{- end }}
  57. spec:
  58. serviceAccountName: {{ include "emqx.serviceAccountName" . }}
  59. volumes:
  60. {{- if .Values.ssl.enabled }}
  61. - name: ssl-cert
  62. secret:
  63. secretName: {{ include "emqx.ssl.secretName" . }}
  64. {{- end }}
  65. {{- if not .Values.persistence.enabled }}
  66. - name: emqx-data
  67. emptyDir: {}
  68. {{- else if .Values.persistence.existingClaim }}
  69. - name: emqx-data
  70. persistentVolumeClaim:
  71. {{- with .Values.persistence.existingClaim }}
  72. claimName: {{ tpl . $ }}
  73. {{- end }}
  74. {{- end }}
  75. {{- if .Values.emqxLicenseSecretName }}
  76. - name: emqx-license
  77. secret:
  78. secretName: {{ .Values.emqxLicenseSecretName }}
  79. {{- end }}
  80. {{- if .Values.extraVolumes }}
  81. {{- toYaml .Values.extraVolumes | nindent 6 }}
  82. {{- end }}
  83. {{- if .Values.podSecurityContext.enabled }}
  84. securityContext: {{- omit .Values.podSecurityContext "enabled" | toYaml | nindent 8 }}
  85. {{- end }}
  86. {{- if .Values.initContainers }}
  87. initContainers:
  88. {{- toYaml .Values.initContainers | nindent 8 }}
  89. {{- end }}
  90. {{- if .Values.image.pullSecrets }}
  91. imagePullSecrets:
  92. {{- range .Values.image.pullSecrets }}
  93. - name: {{ . }}
  94. {{- end }}
  95. {{- end }}
  96. containers:
  97. - name: emqx
  98. image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
  99. imagePullPolicy: {{ .Values.image.pullPolicy }}
  100. {{- if .Values.containerSecurityContext.enabled }}
  101. securityContext: {{- omit .Values.containerSecurityContext "enabled" | toYaml | nindent 12 }}
  102. {{- end }}
  103. ports:
  104. - name: mqtt
  105. containerPort: {{ .Values.emqxConfig.EMQX_LISTENERS__TCP__DEFAULT__BIND | default 1883 }}
  106. - name: mqttssl
  107. containerPort: {{ .Values.emqxConfig.EMQX_LISTENERS__SSL__DEFAULT__BIND | default 8883 }}
  108. - name: ws
  109. containerPort: {{ .Values.emqxConfig.EMQX_LISTENERS__WS__DEFAULT__BIND | default 8083 }}
  110. - name: wss
  111. containerPort: {{ .Values.emqxConfig.EMQX_LISTENERS__WSS__DEFAULT__BIND | default 8084 }}
  112. - name: dashboard
  113. containerPort: {{ .Values.emqxConfig.EMQX_DASHBOARD__LISTENERS__HTTP__BIND | default 18083 }}
  114. {{- if not (empty .Values.emqxConfig.EMQX_LISTENERS__TCP__INTERNAL__BIND) }}
  115. - name: internalmqtt
  116. containerPort: {{ .Values.emqxConfig.EMQX_LISTENERS__TCP__INTERNAL__BIND }}
  117. {{- end }}
  118. {{- if not (empty .Values.emqxConfig.EMQX_DASHBOARD__LISTENERS__HTTPS__BIND) }}
  119. - name: dashboardtls
  120. containerPort: {{ .Values.emqxConfig.EMQX_DASHBOARD__LISTENERS__HTTPS__BIND }}
  121. {{- end }}
  122. - name: ekka
  123. containerPort: 4370
  124. envFrom:
  125. - configMapRef:
  126. name: {{ include "emqx.fullname" . }}-env
  127. {{- if .Values.envFromSecret }}
  128. - secretRef:
  129. name: {{ .Values.envFromSecret }}
  130. {{- end }}
  131. resources:
  132. {{ toYaml .Values.resources | indent 12 }}
  133. volumeMounts:
  134. - name: emqx-data
  135. mountPath: "/opt/emqx/data"
  136. {{- if .Values.ssl.enabled }}
  137. - name: ssl-cert
  138. mountPath: /tmp/ssl
  139. readOnly: true
  140. {{- end}}
  141. {{ if .Values.emqxLicenseSecretName }}
  142. - name: emqx-license
  143. mountPath: "/opt/emqx/etc/emqx.lic"
  144. subPath: "emqx.lic"
  145. readOnly: true
  146. {{- end }}
  147. {{- if .Values.extraVolumeMounts }}
  148. {{- toYaml .Values.extraVolumeMounts | nindent 10 }}
  149. {{- end }}
  150. readinessProbe:
  151. httpGet:
  152. path: /status
  153. port: {{ .Values.emqxConfig.EMQX_DASHBOARD__LISTENERS__HTTP__BIND | default 18083 }}
  154. initialDelaySeconds: 10
  155. periodSeconds: 5
  156. failureThreshold: 30
  157. livenessProbe:
  158. httpGet:
  159. path: /status
  160. port: {{ .Values.emqxConfig.EMQX_DASHBOARD__LISTENERS__HTTP__BIND | default 18083 }}
  161. initialDelaySeconds: 60
  162. periodSeconds: 30
  163. failureThreshold: 10
  164. {{- with .Values.nodeSelector }}
  165. nodeSelector:
  166. {{- toYaml . | nindent 8 }}
  167. {{- end }}
  168. {{- with .Values.affinity }}
  169. affinity:
  170. {{- toYaml . | nindent 8 }}
  171. {{- end }}
  172. {{- with .Values.tolerations }}
  173. tolerations:
  174. {{- toYaml . | nindent 8 }}
  175. {{- end }}
  176. {{- with .Values.topologySpreadConstraints }}
  177. topologySpreadConstraints:
  178. {{- range . }}
  179. - maxSkew: {{ .maxSkew }}
  180. topologyKey: {{ .topologyKey }}
  181. whenUnsatisfiable: {{ .whenUnsatisfiable }}
  182. labelSelector:
  183. matchLabels:
  184. app.kubernetes.io/name: {{ include "emqx.name" $ }}
  185. app.kubernetes.io/instance: {{ $.Release.Name }}
  186. {{- end }}
  187. {{- end }}