statefulset.yaml 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. apiVersion: apps/v1
  2. kind: StatefulSet
  3. metadata:
  4. name: {{ template "horovod.fullname" . }}
  5. labels:
  6. app: {{ template "horovod.name" . }}
  7. chart: {{ template "horovod.chart" . }}
  8. release: {{ .Release.Name }}
  9. heritage: {{ .Release.Service }}
  10. role: worker
  11. spec:
  12. selector:
  13. matchLabels:
  14. app: {{ template "horovod.name" . }}
  15. release: {{ .Release.Name }}
  16. heritage: {{ .Release.Service }}
  17. role: worker
  18. serviceName: {{ template "horovod.fullname" . }}
  19. podManagementPolicy: {{ .Values.worker.podManagementPolicy }}
  20. replicas: {{.Values.worker.number}}
  21. template:
  22. metadata:
  23. labels:
  24. app: {{ template "horovod.name" . }}
  25. chart: {{ template "horovod.chart" . }}
  26. release: {{ .Release.Name }}
  27. heritage: {{ .Release.Service }}
  28. role: worker
  29. spec:
  30. {{- if .Values.useHostNetwork }}
  31. hostNetwork: {{ .Values.useHostNetwork }}
  32. dnsPolicy: ClusterFirstWithHostNet
  33. {{- end }}
  34. {{- if .Values.useHostPID }}
  35. hostPID: {{ .Values.useHostPID }}
  36. {{- end }}
  37. volumes:
  38. - name: {{ template "horovod.fullname" . }}-cm
  39. configMap:
  40. name: {{ template "horovod.fullname" . }}
  41. items:
  42. - key: hostfile.config
  43. path: hostfile
  44. mode: 438
  45. - key: ssh.readiness
  46. path: check.sh
  47. mode: 365
  48. - key: worker.run
  49. path: run.sh
  50. mode: 365
  51. {{- if .Values.ssh.useSecrets }}
  52. - name: {{ template "horovod.fullname" . }}-secret
  53. secret:
  54. secretName: {{ template "horovod.fullname" . }}
  55. defaultMode: 448
  56. items:
  57. - key: host-key
  58. path: id_rsa
  59. - key: host-key-pub
  60. path: authorized_keys
  61. {{- end }}
  62. {{- if .Values.volumes }}
  63. {{ toYaml .Values.volumes | indent 6 }}
  64. {{- end }}
  65. containers:
  66. - name: worker
  67. image: "{{ .Values.worker.image.repository }}:{{ .Values.worker.image.tag }}"
  68. imagePullPolicy: {{ .Values.worker.image.pullPolicy }}
  69. env:
  70. - name: SSHPORT
  71. value: "{{ .Values.ssh.port }}"
  72. {{- if .Values.ssh.useSecrets }}
  73. - name: USESECRETS
  74. value: "{{ .Values.ssh.useSecrets }}"
  75. {{- end }}
  76. {{- if .Values.driver.env }}
  77. {{- range $key, $value := .Values.driver.env }}
  78. - name: "{{ $key }}"
  79. value: "{{ $value }}"
  80. {{- end }}
  81. {{- end }}
  82. {{- if .Values.worker.privileged }}
  83. securityContext:
  84. privileged: true
  85. {{- end }}
  86. ports:
  87. - containerPort: {{ .Values.ssh.port }}
  88. volumeMounts:
  89. - name: {{ template "horovod.fullname" . }}-cm
  90. mountPath: /horovod/generated
  91. {{- if .Values.ssh.useSecrets }}
  92. - name: {{ template "horovod.fullname" . }}-secret
  93. readOnly: true
  94. mountPath: "/etc/secret-volume"
  95. {{- end }}
  96. {{- if .Values.volumeMounts }}
  97. {{ toYaml .Values.volumeMounts | indent 8 }}
  98. {{- end }}
  99. command:
  100. - /horovod/generated/run.sh
  101. {{- if .Values.ssh.useSecrets }}
  102. readinessProbe:
  103. exec:
  104. command:
  105. - /horovod/generated/check.sh
  106. initialDelaySeconds: 1
  107. periodSeconds: 2
  108. {{- end }}
  109. resources:
  110. {{ toYaml .Values.resources | indent 10 }}