You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

redis-haproxy-deployment.yaml 5.3 kB

1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. {{- if .Values.haproxy.enabled }}
  2. kind: Deployment
  3. apiVersion: apps/v1
  4. metadata:
  5. name: {{ template "redis-ha.fullname" . }}-haproxy
  6. namespace: {{ .Release.Namespace }}
  7. labels:
  8. {{ include "labels.standard" . | indent 4 }}
  9. spec:
  10. strategy:
  11. type: RollingUpdate
  12. revisionHistoryLimit: 1
  13. replicas: {{ .Values.haproxy.replicas }}
  14. selector:
  15. matchLabels:
  16. app: {{ template "redis-ha.name" . }}-haproxy
  17. release: {{ .Release.Name }}
  18. template:
  19. metadata:
  20. name: {{ template "redis-ha.fullname" . }}-haproxy
  21. labels:
  22. app: {{ template "redis-ha.name" . }}-haproxy
  23. release: {{ .Release.Name }}
  24. annotations:
  25. {{- if .Values.haproxy.metrics.enabled }}
  26. prometheus.io/port: "{{ .Values.haproxy.metrics.port }}"
  27. prometheus.io/scrape: "true"
  28. prometheus.io/path: "{{ .Values.haproxy.metrics.scrapePath }}"
  29. {{- end }}
  30. checksum/config: {{ print (include "config-haproxy.cfg" .) (include "config-haproxy_init.sh" .) | sha256sum }}
  31. {{- if .Values.haproxy.annotations }}
  32. {{ toYaml .Values.haproxy.annotations | indent 8 }}
  33. {{- end }}
  34. spec:
  35. # Needed when using unmodified rbac-setup.yml
  36. {{ if .Values.haproxy.serviceAccount.create }}
  37. serviceAccountName: {{ template "redis-ha.serviceAccountName" . }}-haproxy
  38. {{ end }}
  39. nodeSelector:
  40. {{ toYaml .Values.nodeSeletor | indent 8 }}
  41. tolerations:
  42. {{ toYaml .Values.tolerations | indent 8 }}
  43. affinity:
  44. {{- if .Values.haproxy.affinity }}
  45. {{- with .Values.haproxy.affinity }}
  46. {{ tpl . $ | indent 8 }}
  47. {{- end }}
  48. {{- else }}
  49. {{- if .Values.haproxy.additionalAffinities }}
  50. {{ toYaml .Values.haproxy.additionalAffinities | indent 8 }}
  51. {{- end }}
  52. podAntiAffinity:
  53. {{- if .Values.haproxy.hardAntiAffinity }}
  54. requiredDuringSchedulingIgnoredDuringExecution:
  55. - labelSelector:
  56. matchLabels:
  57. app: {{ template "redis-ha.name" . }}-haproxy
  58. release: {{ .Release.Name }}
  59. topologyKey: kubernetes.io/hostname
  60. {{- else }}
  61. preferredDuringSchedulingIgnoredDuringExecution:
  62. - labelSelector:
  63. matchLabels:
  64. app: {{ template "redis-ha.name" . }}-haproxy
  65. release: {{ .Release.Name }}
  66. topologyKey: kubernetes.io/hostname
  67. {{- end }}
  68. preferredDuringSchedulingIgnoredDuringExecution:
  69. - weight: 100
  70. podAffinityTerm:
  71. labelSelector:
  72. matchLabels:
  73. app: {{ template "redis-ha.name" . }}-haproxy
  74. release: {{ .Release.Name }}
  75. topologyKey: failure-domain.beta.kubernetes.io/zone
  76. {{- end }}
  77. initContainers:
  78. - name: config-init
  79. image: {{ .Values.haproxy.image.repository }}:{{ .Values.haproxy.image.tag }}
  80. imagePullPolicy: {{ .Values.haproxy.image.pullPolicy }}
  81. resources:
  82. {{ toYaml .Values.haproxy.init.resources | indent 10 }}
  83. command:
  84. - sh
  85. args:
  86. - /readonly/haproxy_init.sh
  87. {{- if .Values.auth }}
  88. env:
  89. - name: AUTH
  90. valueFrom:
  91. secretKeyRef:
  92. {{- if .Values.existingSecret }}
  93. name: {{ .Values.existingSecret }}
  94. {{- else }}
  95. name: {{ template "redis-ha.fullname" . }}
  96. {{- end }}
  97. key: {{ .Values.authKey }}
  98. {{- end }}
  99. volumeMounts:
  100. - name: config-volume
  101. mountPath: /readonly
  102. readOnly: true
  103. - name: data
  104. mountPath: /data
  105. {{- if .Values.haproxy.imagePullSecrets }}
  106. imagePullSecrets: {{ toYaml .Values.haproxy.imagePullSecrets | nindent 8 }}
  107. {{- end }}
  108. securityContext:
  109. {{ toYaml .Values.haproxy.securityContext | indent 8 }}
  110. containers:
  111. - name: haproxy
  112. image: {{ .Values.haproxy.image.repository }}:{{ .Values.haproxy.image.tag }}
  113. imagePullPolicy: {{ .Values.haproxy.image.pullPolicy }}
  114. livenessProbe:
  115. httpGet:
  116. path: /healthz
  117. port: 8888
  118. initialDelaySeconds: 5
  119. periodSeconds: 3
  120. ports:
  121. - name: redis
  122. containerPort: {{ default "6379" .Values.redis.port }}
  123. {{- if .Values.haproxy.readOnly.enabled }}
  124. - name: readonlyport
  125. containerPort: {{ default "6380" .Values.haproxy.readOnly.port }}
  126. {{- end }}
  127. {{- if .Values.haproxy.metrics.enabled }}
  128. - name: metrics-port
  129. containerPort: {{ default "9101" .Values.haproxy.metrics.port }}
  130. {{- end }}
  131. resources:
  132. {{ toYaml .Values.haproxy.resources | indent 10 }}
  133. volumeMounts:
  134. - name: data
  135. mountPath: /usr/local/etc/haproxy
  136. - name: shared-socket
  137. mountPath: /run/haproxy
  138. {{- if .Values.haproxy.priorityClassName }}
  139. priorityClassName: {{ .Values.haproxy.priorityClassName }}
  140. {{- end }}
  141. volumes:
  142. - name: config-volume
  143. configMap:
  144. name: {{ template "redis-ha.fullname" . }}-configmap
  145. - name: shared-socket
  146. emptyDir:
  147. {{ toYaml .Values.haproxy.emptyDir | indent 10 }}
  148. - name: data
  149. emptyDir:
  150. {{ toYaml .Values.haproxy.emptyDir | indent 10 }}
  151. {{- end }}