_runtimeClassName.tpl 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. {{/* Returns Runtime Class Name */}}
  2. {{/* Call this template:
  3. {{ include "ix.v1.common.lib.pod.runtimeClassName" (dict "rootCtx" $ "objectData" $objectData) }}
  4. rootCtx: The root context of the chart.
  5. objectData: The object data to be used to render the Pod.
  6. */}}
  7. {{- define "ix.v1.common.lib.pod.runtimeClassName" -}}
  8. {{- $rootCtx := .rootCtx -}}
  9. {{- $objectData := .objectData -}}
  10. {{- $runtime := "" -}}
  11. {{/* Initialize from the "defaults" */}}
  12. {{- with $rootCtx.Values.podOptions.runtimeClassName -}}
  13. {{- $runtime = tpl . $rootCtx -}}
  14. {{- end -}}
  15. {{/* Override from the pod values, if defined */}}
  16. {{- with $objectData.podSpec.runtimeClassName -}}
  17. {{- $runtime = tpl . $rootCtx -}}
  18. {{- end -}}
  19. {{- if hasKey $rootCtx.Values.global "ixChartContext" -}}
  20. {{- if $rootCtx.Values.global.ixChartContext.addNvidiaRuntimeClass -}}
  21. {{- range $rootCtx.Values.scaleGPU -}}
  22. {{- if .gpu -}} {{/* Make sure it has a value... */}}
  23. {{- if (kindIs "map" .targetSelector) -}}
  24. {{- range $podName, $containers := .targetSelector -}}
  25. {{- if eq $objectData.shortName $podName -}} {{/* If the pod is selected */}}
  26. {{- $runtime = $rootCtx.Values.global.ixChartContext.nvidiaRuntimeClassName -}}
  27. {{- end -}}
  28. {{- end -}}
  29. {{- else if $objectData.primary -}}
  30. {{/* If the pod is primary and no targetSelector is given, assign to primary */}}
  31. {{- $runtime = $rootCtx.Values.global.ixChartContext.nvidiaRuntimeClassName -}}
  32. {{- end -}}
  33. {{- end -}}
  34. {{- end -}}
  35. {{- end -}}
  36. {{- end -}}
  37. {{- $runtime -}}
  38. {{- end -}}