_chia.tpl 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. {{- define "chia.workload" -}}
  2. workload:
  3. chia:
  4. enabled: true
  5. primary: true
  6. type: Deployment
  7. podSpec:
  8. {{ if or (lt (int .Values.chiaNetwork.chiaPort) 9000)
  9. (lt (int .Values.chiaNetwork.farmerPort) 9000) }}
  10. hostNetwork: true
  11. {{ else }}
  12. hostNetwork: false
  13. {{ end }}
  14. containers:
  15. chia:
  16. enabled: true
  17. primary: true
  18. imageSelector: image
  19. securityContext:
  20. runAsUser: 0
  21. runAsGroup: 0
  22. runAsNonRoot: false
  23. readOnlyRootFilesystem: false
  24. env:
  25. plots_dir: {{ include "chia.plotDirs" $ | quote }}
  26. {{ with .Values.chiaConfig.full_node_peer }}
  27. full_node_peer: {{ . | quote }}
  28. {{ end }}
  29. {{ with .Values.chiaConfig.service }}
  30. service: {{ . }}
  31. {{ end }}
  32. {{ if eq .Values.chiaConfig.service "harvester" }}
  33. farmer_address: {{ .Values.chiaConfig.farmer_address | quote }}
  34. farmer_port: {{ .Values.chiaConfig.farmer_port | quote }}
  35. ca: {{ .Values.chiaConfig.ca | quote }}
  36. keys: "none"
  37. {{ else }}
  38. keys: {{ include "chia.keyfile" . | quote }}
  39. {{ end }}
  40. {{ with .Values.chiaConfig.additionalEnvs }}
  41. {{ range $env := . }}
  42. {{ $env.name }}: {{ $env.value }}
  43. {{ end }}
  44. {{ end }}
  45. probes:
  46. liveness:
  47. enabled: true
  48. type: exec
  49. command:
  50. - /bin/sh
  51. - -c
  52. - |
  53. chmod +x /usr/local/bin/docker-healthcheck.sh && \
  54. /usr/local/bin/docker-healthcheck.sh || exit 1
  55. readiness:
  56. enabled: true
  57. type: exec
  58. command:
  59. - /bin/sh
  60. - -c
  61. - |
  62. chmod +x /usr/local/bin/docker-healthcheck.sh && \
  63. /usr/local/bin/docker-healthcheck.sh || exit 1
  64. startup:
  65. enabled: true
  66. type: exec
  67. command:
  68. - /bin/sh
  69. - -c
  70. - |
  71. chmod +x /usr/local/bin/docker-healthcheck.sh && \
  72. /usr/local/bin/docker-healthcheck.sh || exit 1
  73. {{ if ne .Values.chiaConfig.service "harvester" }}
  74. initContainers:
  75. keygen:
  76. enabled: true
  77. type: init
  78. imageSelector: image
  79. securityContext:
  80. runAsUser: 0
  81. runAsGroup: 0
  82. runAsNonRoot: false
  83. command: /bin/sh
  84. args:
  85. - -c
  86. - |
  87. if [ ! -f {{ include "chia.keyfile" . | quote }} ]; then
  88. echo "Generating keys..."
  89. /chia-blockchain/venv/bin/python3 -c \
  90. "from chia.util.keychain import generate_mnemonic;print(generate_mnemonic())" > {{ include "chia.keyfile" . | quote }};
  91. if [ ! -f {{ include "chia.keyfile" . | quote }} ]; then
  92. echo "Failed to generate keys." && exit 1
  93. fi
  94. echo "Keys generated."
  95. fi
  96. {{ end }}
  97. {{/* Service */}}
  98. service:
  99. chia:
  100. enabled: true
  101. primary: true
  102. type: NodePort
  103. targetSelector: chia
  104. ports:
  105. chia-net:
  106. enabled: true
  107. primary: true
  108. port: {{ .Values.chiaNetwork.chiaPort }}
  109. nodePort: {{ .Values.chiaNetwork.chiaPort }}
  110. targePort: 8444
  111. targetSelector: chia
  112. chia-farmer:
  113. enabled: true
  114. port: {{ .Values.chiaNetwork.farmerPort }}
  115. nodePort: {{ .Values.chiaNetwork.farmerPort }}
  116. targePort: 8447
  117. targetSelector: chia
  118. {{/* Persistence */}}
  119. persistence:
  120. data:
  121. enabled: true
  122. type: {{ .Values.chiaStorage.data.type }}
  123. datasetName: {{ .Values.chiaStorage.data.datasetName | default "" }}
  124. hostPath: {{ .Values.chiaStorage.data.hostPath | default "" }}
  125. targetSelector:
  126. chia:
  127. chia:
  128. mountPath: /root/.chia
  129. plots:
  130. enabled: true
  131. type: {{ .Values.chiaStorage.plots.type }}
  132. datasetName: {{ .Values.chiaStorage.plots.datasetName | default "" }}
  133. hostPath: {{ .Values.chiaStorage.plots.hostPath | default "" }}
  134. targetSelector:
  135. chia:
  136. chia:
  137. mountPath: /plots
  138. keygen:
  139. mountPath: /plots
  140. tmp:
  141. enabled: true
  142. type: emptyDir
  143. targetSelector:
  144. chia:
  145. chia:
  146. mountPath: /tmp
  147. {{ range $idx, $vol := .Values.chiaStorage.additionalVolumes }}
  148. {{ printf "volume-%s" (toString $idx) }}:
  149. enabled: true
  150. type: {{ $vol.type }}
  151. datasetName: {{ $vol.datasetName | default "" }}
  152. hostPath: {{ $vol.hostPath | default "" }}
  153. targetSelector:
  154. chia:
  155. chia:
  156. mountPath: {{ $vol.mountPath }}
  157. {{ end }}
  158. {{- end -}}