Skip to content

Commit

Permalink
Fixed third-party charts modifications
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaspi committed Dec 5, 2024
1 parent 8df19e9 commit a6221d6
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 8 deletions.
17 changes: 15 additions & 2 deletions charts/library-chart/templates/_common.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Return the target Kubernetes version
{{- end -}}

{{/*
Return the URL at which the service can be reached
Return the URL at which the service can be accessed
*/}}
{{- define "library-chart.service-url" -}}
{{- if .Values.ingress.enabled -}}
Expand All @@ -27,7 +27,20 @@ Return the URL at which the service can be reached
{{- end -}}

{{/*
Return the URL at which the custom port can be reached
Return the URL at which the service can be accessed
*/}}
{{- define "library-chart.spark-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 -}}
Expand Down
100 changes: 97 additions & 3 deletions charts/library-chart/templates/_notes.tpl
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{{/* vim: set filetype=mustache: */}}

{{/* Template to generate a general message as a note header */}}
{{/*
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 }}
Expand All @@ -9,8 +11,79 @@
{{ end -}}
{{- end -}}

{{/*
Generate NOTES about connection to the service.
{{/* Template to generate notes about custom user-defined port exposition */}}
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" . }} <port-local>:{{ .Values.networking.service.port }}`
puis en vous connectant depuis votre navigateur à l'URL suivante : `http://localhost:<port-local>`
{{ end -}}
- Votre mot de passe : **`{{ .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" . }} <local-port>:{{ .Values.networking.service.port }}`
and then use the following URL with your browser: `http://localhost:<local-port>`
{{ 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.spark-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" . }} <port-local>:{{ .Values.networking.sparkui.port }}`
puis en vous connectant depuis votre navigateur à l'URL suivante : `http://localhost:<port-local>`
{{ 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.spark-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" . }} <local-port>:{{ .Values.networking.sparkui.port }}`
and then use the following URL with your browser: `http://localhost:<local-port>`
{{ 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
Expand Down Expand Up @@ -44,7 +117,9 @@ If you access these URL without starting the corresponding services you will get
{{- end -}}


{{/* Template to generate notes about service deletion */}}
{{/*
Generate NOTES about service deletion.
*/}}
{{- define "library-chart.notes-deletion" -}}
{{- if and (.Values.persistence).enabled (not .Values.persistence.existingClaim) -}}
{{- if eq .Values.userPreferences.language "fr" }}
Expand All @@ -68,3 +143,22 @@ It is possible to associate an initialization script with your service to set up
{{ 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 -}}
97 changes: 96 additions & 1 deletion charts/vscode-python/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1 +1,96 @@
{{- include "library-chart.notes" (dict "serviceName" "Visual Studio Code" "context" $) -}}
{{- if eq .Values.userPreferences.language "fr" -}}
{{ (.Values.message).fr }}

{{ if .Values.ingress.enabled -}}
- Vous pouvez vous connecter à ce Visual Studio Code avec votre navigateur en utilisant ce [lien](http{{ if $.Values.ingress.tls }}s{{ end }}://{{ .Values.ingress.hostname }})
{{- end }}
{{- if .Values.route.enabled }}
- Vous pouvez vous connecter à ce Visual Studio Code avec votre navigateur en utilisant ce [lien](https://{{ .Values.route.hostname }})
{{- end }}
- Votre password: {{ .Values.security.password }}

{{- 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) -}}
{{- if eq (len $userPorts) 1 -}}
{{- if .Values.ingress.enabled }}
Vous pouvez vous connecter à votre port personnalisé ({{ first $userPorts }}) en utilisant [ce lien](http{{ if .Values.ingress.tls }}s{{ end }}://{{ .Values.ingress.userHostname }}).
{{- end -}}
{{- if .Values.route.enabled }}
Vous pouvez vous connecter à votre port personnalisé ({{ first $userPorts }}) en utilisant [ce lien](https://{{ .Values.route.userHostname }}).
{{- end -}}
{{- else }}
Vous pouvez vous connecter à vos services personnalisés en utilisant les liens ci-dessous :
{{- range $userPort := $userPorts -}}
{{- if $.Values.ingress.enabled -}}
{{- $hostname := (regexReplaceAll "([^\\.]+)\\.(.*)" $.Values.ingress.userHostname (printf "${1}-%d.${2}" (int $userPort))) }}
- [Port {{ $userPort }}](http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $hostname }})
{{- end -}}
{{- if $.Values.route.enabled -}}
{{- $hostname := (regexReplaceAll "([^\\.]+)\\.(.*)" $.Values.route.userHostname (printf "${1}-%d.${2}" (int $userPort))) }}
- [Port {{ $userPort }}](https://{{ $hostname }})
{{- end -}}
{{- end }}
{{ end }}
Si vous accédez ces URL sans démarrer vos services personnalisés, vous obtiendrez une erreur 502 Bad Gateway.
{{- end }}

*REMARQUES concernant la suppression :*

{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
- Le volume associé au chemin suivant **/home/{{ .Values.environment.user }}/work** sera supprimé
- Par conséquent, vous devriez sauvegarder votre code dans un dépôt Git externe
- Vous devriez également sauvegarder vos données dans un référentiel de données externe tel que S3
- Vous pouvez facilement créer un nouveau service {{ .Chart.Name }}, cloner votre code et réinstaller les bibliothèques dont vous avez besoin
{{- end }}
{{- else }}
{{ (.Values.message).en }}
{{- if .Values.ingress.enabled }}
- You can connect to this vscode with your browser on this [link](http{{ if $.Values.ingress.tls }}s{{ end }}://{{ .Values.ingress.hostname }})
{{- end }}
{{- if .Values.route.enabled }}
- You can connect to this vscode with your browser on this [link](https://{{ .Values.route.hostname }})
{{- end }}
- Your password: {{ .Values.security.password }}

{{- 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) -}}
{{- if eq (len $userPorts) 1 -}}
{{- if .Values.ingress.enabled }}
You can connect to your custom port ({{ first $userPorts }}) using [this link](http{{ if .Values.ingress.tls }}s{{ end }}://{{ .Values.ingress.userHostname }}).
{{- end -}}
{{- if .Values.route.enabled }}
You can connect to your custom port ({{ first $userPorts }}) using [this link](https://{{ .Values.route.userHostname }}).
{{- end -}}
{{- else }}
You can connect to your custom services using the following links:
{{- range $userPort := $userPorts -}}
{{- if $.Values.ingress.enabled -}}
{{- $hostname := (regexReplaceAll "([^\\.]+)\\.(.*)" $.Values.ingress.userHostname (printf "${1}-%d.${2}" (int $userPort))) }}
- [Port {{ $userPort }}](http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $hostname }})
{{- end -}}
{{- if $.Values.route.enabled -}}
{{- $hostname := (regexReplaceAll "([^\\.]+)\\.(.*)" $.Values.route.userHostname (printf "${1}-%d.${2}" (int $userPort))) }}
- [Port {{ $userPort }}](https://{{ $hostname }})
{{- end -}}
{{- end }}
{{ end }}
If you access these URL without starting the corresponding services you will get a 502 bad gateway error.
{{- end }}

*NOTES about deletion :*
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
- The volume associated with the following path **/home/{{ .Values.environment.user }}/work** will be deleted
- So, you should save your code to an external git repository
- So, You should save your data to an external data repository like S3
- You can easily create a new {{ .Chart.Name }} service, clone your code and install again some librairies you need
{{- end -}}

{{- end -}}
1 change: 0 additions & 1 deletion charts/vscode-python/templates/_common.tpl

This file was deleted.

1 change: 0 additions & 1 deletion charts/vscode-python/templates/_notes.tpl

This file was deleted.

0 comments on commit a6221d6

Please sign in to comment.