Geen omschrijving

_helpers.tpl 4.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. {{/*
  2. Return the common name for app components.
  3. */}}
  4. {{- define "shuffle.app.name" -}}
  5. {{- printf "%s-app" (include "common.names.fullname" .) | trunc 63 -}}
  6. {{- end -}}
  7. {{/*
  8. Return the common labels for app components deployed via helm.
  9. NOTE: App deployments and services use shuffle.appInstance.labels instead.
  10. */}}
  11. {{- define "shuffle.app.labels" -}}
  12. {{- include "common.labels.standard" . }}
  13. app.kubernetes.io/component: app
  14. {{- end -}}
  15. {{/*
  16. Create the name of the service account to use for Shuffle apps
  17. */}}
  18. {{- define "shuffle.app.serviceAccount.name" -}}
  19. {{- if .Values.app.serviceAccount.create -}}
  20. {{ default (include "shuffle.app.name" .) .Values.app.serviceAccount.name | trunc 63 | trimSuffix "-" }}
  21. {{- else -}}
  22. {{ default "default" .Values.app.serviceAccount.name }}
  23. {{- end -}}
  24. {{- end -}}
  25. {{/*
  26. Return the proper Docker Image Registry Secret Names for the app service account
  27. */}}
  28. {{- define "shuffle.app.serviceAccount.imagePullSecrets" -}}
  29. {{- $pullSecrets := list }}
  30. {{- range .Values.global.imagePullSecrets -}}
  31. {{- if kindIs "map" . -}}
  32. {{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" .name "context" .)) -}}
  33. {{- else -}}
  34. {{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" . "context" .)) -}}
  35. {{- end -}}
  36. {{- end -}}
  37. {{- range .Values.app.serviceAccount.imagePullSecrets -}}
  38. {{- if kindIs "map" . -}}
  39. {{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" .name "context" .)) -}}
  40. {{- else -}}
  41. {{- $pullSecrets = append $pullSecrets (include "common.tplvalues.render" (dict "value" . "context" .)) -}}
  42. {{- end -}}
  43. {{- end -}}
  44. {{- if (not (empty $pullSecrets)) -}}
  45. imagePullSecrets:
  46. {{- range $pullSecrets | uniq }}
  47. - name: {{ . }}
  48. {{- end }}
  49. {{- end }}
  50. {{- end -}}
  51. {{/*
  52. Return the match labels for ALL apps.
  53. These match the labels of helm-deployed apps (shuffle.appInstance.labels),
  54. as well as worker-deployed apps (deployK8sApp).
  55. */}}
  56. {{- define "shuffle.app.matchLabels" -}}
  57. app.kubernetes.io/name: shuffle-app
  58. {{- end -}}
  59. {{/*
  60. Return the sanitized name of a shuffle app.
  61. Usage:
  62. {{ include "shuffle.appInstance.name" $app }}
  63. */}}
  64. {{- define "shuffle.appInstance.name" -}}
  65. {{ .name | replace "_" "-" | lower }}
  66. {{- end -}}
  67. {{/*
  68. Return the sanitized name of a shuffle app, including the version of the app.
  69. Usage:
  70. {{ include "shuffle.appInstance.fullname" $app }}
  71. */}}
  72. {{- define "shuffle.appInstance.fullname" -}}
  73. {{ printf "%s-%s" .name .version | replace "." "-" | replace "_" "-" | lower }}
  74. {{- end -}}
  75. {{/*
  76. Return the labels for a shuffle app deployed by helm.
  77. Usage:
  78. {{ include "shuffle.appInstance.labels" (dict "app" $app "customLabels" .Values.commonLabels "context" $) }}
  79. */}}
  80. {{- define "shuffle.appInstance.labels" -}}
  81. {{- $customLabels := mustMerge (dict "app.kubernetes.io/name" "shuffle-app" "app.kubernetes.io/part-of" "shuffle") (include "common.tplvalues.render" (dict "value" .customLabels "context" .context) | fromYaml) -}}
  82. {{ include "common.labels.standard" (dict "customLabels" $customLabels "context" .context) }}
  83. app.shuffler.io/name: {{ include "shuffle.appInstance.name" .app }}
  84. app.shuffler.io/version: {{ .app.version | quote }}
  85. {{- end -}}
  86. {{/*
  87. Return the match labels of a single app, deployed via helm.
  88. Usage:
  89. {{ include "shuffle.appInstance.matchLabels" (dict "app" $app "customLabels" .Values.commonLabels "context" $) }}
  90. */}}
  91. {{- define "shuffle.appInstance.matchLabels" -}}
  92. {{- $customLabels := mustMerge (dict "app.kubernetes.io/name" "shuffle-app" "app.kubernetes.io/part-of" "shuffle") (include "common.tplvalues.render" (dict "value" .customLabels "context" .context) | fromYaml) -}}
  93. {{ include "common.labels.matchLabels" (dict "customLabels" $customLabels "context" .context) }}
  94. app.shuffler.io/name: {{ include "shuffle.appInstance.name" .app }}
  95. app.shuffler.io/version: {{ .app.version | quote }}
  96. {{- end -}}
  97. {{/*
  98. Return a podAffinity/podAntiAffinity definition.
  99. Usage:
  100. {{ include "shuffle.appInstance.affinities.pods" (dict "type" "soft" "app" $app "customLabels" $podLabels "context" $) -}}
  101. */}}
  102. {{- define "shuffle.appInstance.affinities.pods" -}}
  103. {{- $customLabels := mustMerge (dict "app.kubernetes.io/name" "shuffle-app" "app.kubernetes.io/part-of" "shuffle") (include "common.tplvalues.render" (dict "value" .customLabels "context" .context) | fromYaml) -}}
  104. {{- $extraMatchLabels := dict "app.shuffler.io/name" (include "shuffle.appInstance.name" .app) "app.shuffler.io/version" (.app.version) }}
  105. {{ include "common.affinities.pods" (dict "type" .type "customLabels" $customLabels "context" .context "extraMatchLabels" $extraMatchLabels )}}
  106. {{- end -}}
  107. {{/*
  108. Return the environment variables of shuffle apps in the format
  109. KEY: VALUE
  110. */}}
  111. {{- define "shuffle.appInstance.env" -}}
  112. SHUFFLE_APP_SDK_TIMEOUT: {{ .Values.app.sdkTimeout | quote }}
  113. SHUFFLE_APP_EXPOSED_PORT: {{ .Values.app.exposedContainerPort | quote }}
  114. SHUFFLE_LOGS_DISABLED: {{ .Values.app.disableLogs | quote }}
  115. {{- end -}}