diff --git a/charts/library-chart/Chart.yaml b/charts/library-chart/Chart.yaml index 6a41d211..71597cec 100644 --- a/charts/library-chart/Chart.yaml +++ b/charts/library-chart/Chart.yaml @@ -1,4 +1,4 @@ apiVersion: v2 name: library-chart -version: 1.5.33 +version: 1.5.34 type: library diff --git a/charts/library-chart/templates/_common.tpl b/charts/library-chart/templates/_common.tpl index 39a449df..08bca639 100644 --- a/charts/library-chart/templates/_common.tpl +++ b/charts/library-chart/templates/_common.tpl @@ -1,7 +1,5 @@ -{{/* vim: set filetype=mustache: */}} - {{/* -Return the target Kubernetes version + Return the target Kubernetes version */}} {{- define "library-chart.capabilities.kubeVersion" -}} {{- if .Values.global }} @@ -13,4 +11,39 @@ Return the target Kubernetes version {{- else }} {{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}} {{- end -}} -{{- end -}} \ No newline at end of file +{{- end -}} + +{{/* + Return the URL at which the service can be accessed +*/}} +{{- define "library-chart.service-url" -}} + {{- if .Values.ingress.enabled -}} + {{- printf "%s://%s" (.Values.ingress.tls | ternary "https" "http") .Values.ingress.hostname -}} + {{- else if .Values.route.enabled -}} + {{- printf "https://%s" .Values.route.hostname -}} + {{- end -}} +{{- end -}} + +{{/* + Return the URL at which the service can be accessed +*/}} +{{- define "library-chart.sparkui-url" -}} + {{- if (.Values.spark).sparkui -}} + {{- if .Values.ingress.enabled -}} + {{- printf "%s://%s" (.Values.ingress.tls | ternary "https" "http") .Values.ingress.sparkHostname -}} + {{- else if .Values.route.enabled -}} + {{- printf "https://%s" .Values.route.sparkHostname -}} + {{- end -}} + {{- end -}} +{{- end -}} + +{{/* + Return the URL at which the user-defined custom port(s) can be accessed +*/}} +{{- define "library-chart.user-url" -}} + {{- if .Values.ingress.enabled -}} + {{- printf "%s://%s" (.Values.ingress.tls | ternary "https" "http") .Values.ingress.userHostname -}} + {{- else if .Values.route.enabled -}} + {{- printf "https://%s" .Values.route.userHostname -}} + {{- end -}} +{{- end -}} diff --git a/charts/library-chart/templates/_notes.tpl b/charts/library-chart/templates/_notes.tpl new file mode 100644 index 00000000..924c3025 --- /dev/null +++ b/charts/library-chart/templates/_notes.tpl @@ -0,0 +1,163 @@ +{{/* + Generate a general message as a NOTES header. +*/}} +{{- define "library-chart.general-message" -}} +{{- if and (eq .Values.userPreferences.language "fr" (.Values.message).fr) -}} +{{- (.Values.message).fr }} +{{ else -}} +{{- (.Values.message).en }} +{{ end -}} +{{- end -}} + + +{{/* + Generate NOTES about connection to the service. + + Usage: + {{ include "library-chart.notes-connection" (dict "serviceName" "Visual Studio Code" "context" $) }} + + Params: + - serviceName - String - Optional. The human readable name of the service. + - context - Dict - Required. The context for the template evaluation. +*/}} +{{- define "library-chart.notes-connection" -}} +{{- $serviceName := .serviceName | default .context.Chart.Name -}} +{{- with .context -}} +{{- if eq .Values.userPreferences.language "fr" -}} +{{- if or (.Values.ingress).enabled (.Values.route).enabled }} +- Vous pouvez vous connecter à {{ $serviceName }} depuis votre navigateur en utilisant [ce lien]({{ include "library-chart.service-url" . }}). +{{ else }} +- Votre service {{ $serviceName }} n'est pas directement exposé sur internet. +Vous pouvez tout de même y accéder en executant la commande suivante depuis un terminal : +`kubectl port-forward service/{{ include "library-chart.fullname" . }} :{{ .Values.networking.service.port }}` +puis en vous connectant depuis votre navigateur à l'URL suivante : `http://localhost:` +{{ end -}} +- Votre password: {{ .Values.security.password }} +{{ else -}} +{{- if or (.Values.ingress).enabled (.Values.route).enabled }} +- You can connect to {{ $serviceName }} with your browser using [this link]({{ include "library-chart.service-url" . }}). +{{ else }} +- Your service {{ $serviceName }} is not exposed on the internet. +You can still access it by running the following command from a terminal: +`kubectl port-forward service/{{ include "library-chart.fullname" . }} :{{ .Values.networking.service.port }}` +and then use the following URL with your browser: `http://localhost:` +{{ end -}} +- Your password: {{ .Values.security.password }} +{{ end -}} +{{- end -}} +{{- end -}} + + +{{/* + Generate NOTES about connection to the Spark UI (if enabled). +*/}} +{{- define "library-chart.notes-sparkui" -}} +{{- if (.Values.spark).sparkui -}} +{{- if eq .Values.userPreferences.language "fr" -}} +{{- if or (.Values.ingress).enabled (.Values.route).enabled }} +- Vous pouvez vous connecter à l'interface Spark depuis votre navigateur en utilisant [ce lien]({{ include "library-chart.sparkui-url" . }}). +{{ else }} +- Votre interface Spark n'est pas directement exposée sur internet. +Vous pouvez tout de même y accéder en executant la commande suivante depuis un terminal : +`kubectl port-forward service/{{ include "library-chart.fullname" . }} :{{ .Values.networking.sparkui.port }}` +puis en vous connectant depuis votre navigateur à l'URL suivante : `http://localhost:` +{{ end -}} +- Votre nom d'utilisateur : **`{{ .Values.environment.user }}`** +- Votre mot de passe : **`{{ .Values.security.password }}`** +{{ else -}} +{{- if or (.Values.ingress).enabled (.Values.route).enabled }} +- You can connect to the Spark UI with your browser using [this link]({{ include "library-chart.sparkui-url" . }}). +{{ else }} +- Your Spark interface is not exposed on the internet. +You can still access it by running the following command from a terminal: +`kubectl port-forward service/{{ include "library-chart.fullname" . }} :{{ .Values.networking.sparkui.port }}` +and then use the following URL with your browser: `http://localhost:` +{{ end -}} +- Your login: **`{{ .Values.environment.user }}`** +- Your password: **`{{ .Values.security.password }}`** +{{ end -}} +{{- end -}} +{{- end -}} + + +{{/* + Generate NOTES about custom user-defined port exposition. +*/}} +{{- define "library-chart.notes-custom-ports" -}} +{{- if and + ((.Values.networking).user).enabled + (or .Values.networking.user.ports .Values.networking.user.port) + (or (.Values.ingress).enabled (.Values.route).enabled) +-}} +{{- $userPorts := .Values.networking.user.ports | default (list .Values.networking.user.port) -}} +{{- $URL := include "library-chart.user-url" . -}} +{{- if eq .Values.userPreferences.language "fr" -}} +{{- if eq (len $userPorts) 1 }} +Vous pouvez vous connecter à votre port personnalisé ({{ first $userPorts }}) en utilisant [ce lien]({{ $URL }}). +{{- else }} +Vous pouvez vous connecter à vos ports personnalisés en utilisant les liens ci-dessous : +{{ range $userPort := $userPorts -}} +- [Port {{ $userPort }}]({{ regexReplaceAll "([^\\.]+)\\.(.*)" $URL (printf "${1}-%d.${2}" (int $userPort)) }}) +{{ end -}} +{{- end -}} +Si vous accédez ces URL sans démarrer vos services personnalisés, vous obtiendrez une erreur 502 Bad Gateway. +{{ else -}} +{{- if eq (len $userPorts) 1 }} +You can connect to your custom port ({{ first $userPorts }}) using [this link]({{ $URL }}). +{{- else }} +You can connect to your custom ports using the following links: +{{ range $userPort := $userPorts -}} +- [Port {{ $userPort }}]({{ regexReplaceAll "([^\\.]+)\\.(.*)" $URL (printf "${1}-%d.${2}" (int $userPort)) }}) +{{ end -}} +{{- end -}} +If you access these URL without starting the corresponding services you will get a 502 bad gateway error. +{{ end -}} +{{- end -}} +{{- end -}} + + +{{/* + Generate NOTES about service deletion. +*/}} +{{- define "library-chart.notes-deletion" -}} +{{- if not (and (.Values.persistence).enabled .Values.persistence.existingClaim) -}} +{{- if eq .Values.userPreferences.language "fr" }} +**REMARQUES concernant la suppression :** +Votre répertoire de travail `/home/{{ .Values.environment.user }}/work` +sera **immédiatement effacé** à la suppression de votre service {{ .Chart.Name }}. +Assurez-vous de sauvegarder toutes vos ressources de travail sur des supports persistants : +- Votre code peux être stocké dans une forge logicielle telle que git. +- Vos données et modèles peuvent être stockés dans un système de stockage objet tel que S3. +Il est possible d'associer un script d'initialisation à votre service pour mettre en place un environnement de travail sur mesure +(télécharger vos ressources, installer les bibliothèques et outils dont vous avez besoin, configurer votre service, etc.) +{{ else }} +**NOTES about deletion:** +Your work directory `/home/{{ .Values.environment.user }}/work` +will be **immediately deleted** upon the termination of your {{ .Chart.Name }} service. +Make sure to save all your work resources on persistent storage: +- Your code can be stored in a version control system such as git. +- Your data and models can be stored in an object storage system such as S3. +It is possible to associate an initialization script with your service to set up a customized working environment +(download your resources, install the libraries and tools you need, configure your service, etc.). +{{ end -}} +{{- end -}} +{{- end -}} + + +{{/* + Prints out all NOTES. + + Usage: + {{- template "library-chart.notes" (dict "serviceName" "Visual Studio Code" "context" $) -}} + + Params: + - serviceName - String - Optional. The human readable name of the service. + - context - Dict - Required. The context for the template evaluation. +*/}} +{{- define "library-chart.notes" -}} +{{- template "library-chart.general-message" .context -}} +{{- template "library-chart.notes-connection" . -}} +{{- template "library-chart.notes-sparkui" .context -}} +{{- template "library-chart.notes-custom-ports" .context -}} +{{- template "library-chart.notes-deletion" .context -}} +{{- end -}}