statefulset.yaml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. apiVersion: apps/v1
  2. kind: StatefulSet
  3. metadata:
  4. name: {{ include "rabbitmq.fullname" . }}
  5. labels:
  6. {{ include "rabbitmq.labels" . | indent 4 }}
  7. spec:
  8. serviceName: {{ include "rabbitmq.fullname" . }}-headless
  9. replicas: {{ .Values.replicaCount }}
  10. selector:
  11. matchLabels:
  12. app.kubernetes.io/name: {{ include "rabbitmq.fullname" . }}
  13. template:
  14. metadata:
  15. labels:
  16. {{ include "rabbitmq.labels" . | nindent 8 }}
  17. spec:
  18. {{- if .Values.nodeSelector }}
  19. nodeSelector:
  20. {{ toYaml .Values.nodeSelector | indent 8 }}
  21. {{- end }}
  22. {{- if .Values.tolerations }}
  23. tolerations:
  24. {{ toYaml .Values.tolerations | indent 8 }}
  25. {{- end }}
  26. containers:
  27. - name: rabbitmq
  28. image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
  29. imagePullPolicy: {{ .Values.image.pullPolicy }}
  30. ports:
  31. - containerPort: 5672
  32. name: amqp
  33. - containerPort: 15672
  34. name: management
  35. - containerPort: 1883
  36. name: mqtt
  37. env:
  38. - name: RABBITMQ_DEFAULT_USER
  39. valueFrom:
  40. secretKeyRef:
  41. name: {{ include "rabbitmq.fullname" . }}-credentials
  42. key: username
  43. - name: RABBITMQ_DEFAULT_PASS
  44. valueFrom:
  45. secretKeyRef:
  46. name: {{ include "rabbitmq.fullname" . }}-credentials
  47. key: password
  48. readinessProbe:
  49. tcpSocket:
  50. port: 5672
  51. initialDelaySeconds: 10
  52. periodSeconds: 10
  53. livenessProbe:
  54. tcpSocket:
  55. port: 5672
  56. initialDelaySeconds: 20
  57. periodSeconds: 20
  58. volumeMounts:
  59. - name: rabbitmq-data
  60. mountPath: /var/lib/rabbitmq
  61. - name: rabbitmq-plugins
  62. mountPath: /etc/rabbitmq/enabled_plugins
  63. subPath: enabled_plugins
  64. - name: rabbitmq-conf
  65. mountPath: /etc/rabbitmq/rabbitmq.conf
  66. subPath: rabbitmq.conf
  67. {{- if .Values.definitions.enabled }}
  68. - name: rabbitmq-definitions
  69. mountPath: /etc/rabbitmq/definitions.json
  70. subPath: definitions.json
  71. {{- end }}
  72. volumes:
  73. - name: rabbitmq-plugins
  74. configMap:
  75. name: {{ include "rabbitmq.fullname" . }}-enabled-plugins
  76. items:
  77. - key: enabled_plugins
  78. path: enabled_plugins
  79. - name: rabbitmq-conf
  80. configMap:
  81. name: {{ include "rabbitmq.fullname" . }}-conf
  82. items:
  83. - key: rabbitmq.conf
  84. path: rabbitmq.conf
  85. {{- if .Values.definitions.enabled }}
  86. - name: rabbitmq-definitions
  87. configMap:
  88. name: {{ include "rabbitmq.fullname" . }}-definitions
  89. items:
  90. - key: definitions.json
  91. path: definitions.json
  92. {{- end }}
  93. volumeClaimTemplates:
  94. - metadata:
  95. name: rabbitmq-data
  96. spec:
  97. accessModes: [ "ReadWriteOnce" ]
  98. {{- if .Values.persistence.storageClass }}
  99. storageClassName: {{ .Values.persistence.storageClass }}
  100. {{- end }}
  101. resources:
  102. requests:
  103. storage: {{ .Values.persistence.size }}