mirror of
https://github.com/bitnami/charts.git
synced 2026-03-12 14:57:18 +08:00
175 lines
7.7 KiB
YAML
175 lines
7.7 KiB
YAML
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
|
|
kind: Deployment
|
|
metadata:
|
|
name: {{ include "common.names.fullname" . }}{{ if eq .Values.mode "distributed" }}-master{{ end }}
|
|
labels: {{- include "common.labels.standard" . | nindent 4 }}
|
|
app.kubernetes.io/component: master
|
|
spec:
|
|
replicas: 1
|
|
selector:
|
|
matchLabels: {{- include "common.labels.matchLabels" . | nindent 6 }}
|
|
app.kubernetes.io/component: master
|
|
template:
|
|
metadata:
|
|
labels: {{- include "common.labels.standard" . | nindent 8 }}
|
|
app.kubernetes.io/component: master
|
|
spec:
|
|
{{- include "pytorch.imagePullSecrets" . | nindent 6 }}
|
|
{{- if .Values.hostAliases }}
|
|
hostAliases: {{- include "common.tplvalues.render" (dict "value" .Values.hostAliases "context" $) | nindent 8 }}
|
|
{{- end }}
|
|
{{- if .Values.affinity }}
|
|
affinity: {{- include "common.tplvalues.render" ( dict "value" .Values.affinity "context" $) | nindent 8 }}
|
|
{{- else }}
|
|
affinity:
|
|
podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAffinityPreset "component" "master" "context" $) | nindent 10 }}
|
|
podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.podAntiAffinityPreset "component" "master" "context" $) | nindent 10 }}
|
|
nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.nodeAffinityPreset.type "key" .Values.nodeAffinityPreset.key "values" .Values.nodeAffinityPreset.values) | nindent 10 }}
|
|
{{- end }}
|
|
{{- if .Values.nodeSelector }}
|
|
nodeSelector: {{- include "common.tplvalues.render" ( dict "value" .Values.nodeSelector "context" $) | nindent 8 }}
|
|
{{- end }}
|
|
{{- if .Values.tolerations }}
|
|
tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.tolerations "context" .) | nindent 8 }}
|
|
{{- end }}
|
|
{{- if .Values.securityContext.enabled }}
|
|
securityContext:
|
|
fsGroup: {{ .Values.securityContext.fsGroup }}
|
|
runAsUser: {{ .Values.securityContext.runAsUser }}
|
|
{{- end }}
|
|
{{- if or .Values.cloneFilesFromGit.enabled (and .Values.volumePermissions.enabled .Values.persistence.enabled) }}
|
|
initContainers:
|
|
{{- if .Values.cloneFilesFromGit.enabled }}
|
|
- name: git-clone-repository
|
|
image: {{ include "git.image" . }}
|
|
imagePullPolicy: {{ .Values.git.pullPolicy | quote }}
|
|
command:
|
|
- /bin/sh
|
|
- -c
|
|
- |
|
|
[[ -f "/opt/bitnami/scripts/git/entrypoint.sh" ]] && source "/opt/bitnami/scripts/git/entrypoint.sh"
|
|
git clone {{ .Values.cloneFilesFromGit.repository }} --branch {{ .Values.cloneFilesFromGit.revision }} /app
|
|
volumeMounts:
|
|
- name: git-cloned-files
|
|
mountPath: /app
|
|
{{- if .Values.cloneFilesFromGit.extraVolumeMounts }}
|
|
{{- include "common.tplvalues.render" (dict "value" .Values.cloneFilesFromGit.extraVolumeMounts "context" $) | nindent 12 }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- if and .Values.volumePermissions.enabled .Values.persistence.enabled }}
|
|
- name: volume-permissions
|
|
image: "{{ template "mxnet.volumePermissions.image" . }}"
|
|
imagePullPolicy: {{ default "" .Values.volumePermissions.image.pullPolicy | quote }}
|
|
command:
|
|
- /bin/bash
|
|
- -ec
|
|
- |
|
|
chown -R {{ .Values.securityContext.runAsUser }}:{{ .Values.securityContext.fsGroup }} {{ .Values.persistence.mountPath }}
|
|
securityContext:
|
|
runAsUser: 0
|
|
{{- if .Values.volumePermissions.resources }}
|
|
resources: {{- toYaml .Values.volumePermissions.resources | nindent 12 }}
|
|
{{- end }}
|
|
volumeMounts:
|
|
- name: data
|
|
mountPath: {{ .Values.persistence.mountPath }}
|
|
{{- end }}
|
|
{{- end }}
|
|
containers:
|
|
- name: master
|
|
image: {{ include "pytorch.image" . }}
|
|
imagePullPolicy: {{ .Values.image.pullPolicy | quote }}
|
|
command:
|
|
- bash
|
|
- -c
|
|
- |
|
|
{{- if .Values.entrypoint.file }}
|
|
python {{ .Values.entrypoint.file }} {{ if .Values.entrypoint.args }}{{ .Values.entrypoint.args }}{{ end }}
|
|
{{- end }}
|
|
sleep infinity
|
|
env:
|
|
{{- if eq .Values.mode "distributed" }}
|
|
- name: MASTER_ADDR
|
|
value: "127.0.0.1"
|
|
- name: MASTER_PORT
|
|
value: {{ .Values.port | quote }}
|
|
- name: WORLD_SIZE
|
|
value: {{ .Values.worldSize | quote }}
|
|
- name: RANK
|
|
value: "0"
|
|
{{- end }}
|
|
{{- if .Values.extraEnvVars }}
|
|
{{- toYaml .Values.extraEnvVars | nindent 12 }}
|
|
{{- end }}
|
|
ports:
|
|
- name: pytorch
|
|
containerPort: {{ .Values.port }}
|
|
{{- if .Values.livenessProbe.enabled }}
|
|
livenessProbe:
|
|
exec:
|
|
command:
|
|
- python
|
|
- -c
|
|
- import torch; torch.__version__
|
|
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
|
|
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
|
|
timeoutSeconds: {{ .Values.livenessProbe.timeoutSeconds }}
|
|
successThreshold: {{ .Values.livenessProbe.successThreshold }}
|
|
failureThreshold: {{ .Values.livenessProbe.failureThreshold }}
|
|
{{- end }}
|
|
{{- if .Values.readinessProbe.enabled }}
|
|
readinessProbe:
|
|
exec:
|
|
command:
|
|
- python
|
|
- -c
|
|
- import torch; torch.__version__
|
|
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
|
|
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
|
|
timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}
|
|
successThreshold: {{ .Values.readinessProbe.successThreshold }}
|
|
failureThreshold: {{ .Values.readinessProbe.failureThreshold }}
|
|
{{- end }}
|
|
{{- if .Values.resources }}
|
|
resources: {{- toYaml .Values.resources | nindent 12 }}
|
|
{{- end }}
|
|
volumeMounts:
|
|
{{- if .Values.configMap }}
|
|
- name: ext-files
|
|
mountPath: /app
|
|
{{- else if .Files.Glob "files/*" }}
|
|
- name: local-files
|
|
mountPath: /app
|
|
{{- else if .Values.cloneFilesFromGit.enabled }}
|
|
- name: git-cloned-files
|
|
mountPath: /app
|
|
{{- end }}
|
|
{{- if .Values.extraVolumeMounts }}
|
|
{{- include "common.tplvalues.render" ( dict "value" .Values.extraVolumeMounts "context" $) | nindent 12 }}
|
|
{{- end }}
|
|
- name: data
|
|
mountPath: {{ .Values.persistence.mountPath }}
|
|
volumes:
|
|
{{- if .Values.configMap }}
|
|
- name: ext-files
|
|
configMap:
|
|
name: {{ .Values.configMap }}
|
|
{{- else if .Files.Glob "files/*" }}
|
|
- name: local-files
|
|
configMap:
|
|
name: {{ include "common.names.fullname" . }}-files
|
|
{{- else if .Values.cloneFilesFromGit.enabled }}
|
|
- name: git-cloned-files
|
|
emptyDir: {}
|
|
{{- end }}
|
|
- name: data
|
|
{{- if .Values.persistence.enabled }}
|
|
persistentVolumeClaim:
|
|
claimName: {{ include "common.names.fullname" . }}{{ if eq .Values.mode "distributed" }}-master{{ end }}
|
|
{{- else }}
|
|
emptyDir: {}
|
|
{{- end }}
|
|
{{- if .Values.extraVolumes }}
|
|
{{- include "common.tplvalues.render" ( dict "value" .Values.extraVolumes "context" $) | nindent 8 }}
|
|
{{- end }}
|