Skip to content

Commit

Permalink
Add base path support (#96)
Browse files Browse the repository at this point in the history
* Add base path support

* Remove trailing -

* Add base path support to Studio Ingress

* Remove trailing slash in the ingress rule for UI

* Use template for base path

* Split Ingress resources

* Add regex groups to paths

* Fix regex in paths

* Fix borked installation when basePath is set to /

* Fix UI health check endpoint

* Don't strip path prefix in UI

* Revert "Fix UI health check endpoint"

This reverts commit d5599a7.

* Add BASE_PATH variable for Studio frontend

* Revert "Add BASE_PATH variable for Studio frontend"

This reverts commit 65b0237.

* Revert "Revert "Fix UI health check endpoint""

This reverts commit 67d95b8.

* /api/health -> /fapi/health

* Set BASE_PATH automatically

* Update charts/studio/templates/ingress-studio-webhook.yaml

Co-authored-by: Marcin Jasion <5058132+mjasion@users.noreply.github.com>

* Update charts/studio/templates/ingress-studio-ui.yaml

Co-authored-by: Marcin Jasion <5058132+mjasion@users.noreply.github.com>

* Update charts/studio/templates/ingress-studio-api.yaml

Co-authored-by: Marcin Jasion <5058132+mjasion@users.noreply.github.com>

* Update charts/studio/templates/deployment-studio-ui.yaml

Co-authored-by: Marcin Jasion <5058132+mjasion@users.noreply.github.com>

* Fix version

* Fix version again

* Upgrade appVersion in chart

---------

Co-authored-by: Marcin Jasion <5058132+mjasion@users.noreply.github.com>
  • Loading branch information
jesper7 and mjasion authored May 18, 2023
1 parent 235e6eb commit 4cac458
Show file tree
Hide file tree
Showing 9 changed files with 152 additions and 38 deletions.
4 changes: 2 additions & 2 deletions charts/studio/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.26
version: 0.1.27

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "v1.59.0"
appVersion: "v1.78.0"

dependencies:
- name: nginx
Expand Down
5 changes: 5 additions & 0 deletions charts/studio/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,8 @@ checksum/configmap-studio: {{ include (print $.Template.BasePath "/configmap-stu
checksum/configmap-ca-cert: {{ include (print $.Template.BasePath "/configmap-ca-cert.yaml") . | sha256sum }}
checksum/secret-studio: {{ include (print $.Template.BasePath "/secret-studio.yaml") . | sha256sum }}
{{- end }}


{{- define "studio.basePath" -}}
{{- printf "%s" .Values.global.basePath | trimPrefix "/" | trimSuffix "/" }}
{{- end }}
13 changes: 8 additions & 5 deletions charts/studio/templates/configmap-studio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ data:
{{- end }}

ALLOWED_HOSTS: "*"
API_URL: "http{{ if $.Values.global.ingress.tlsEnabled }}s{{ end }}://{{.Values.global.host }}/api"
UI_URL: "http{{ if $.Values.global.ingress.tlsEnabled }}s{{ end }}://{{.Values.global.host }}/"
API_URL: "http{{ if $.Values.global.ingress.tlsEnabled }}s{{ end }}://{{.Values.global.host }}{{- if and .Values.global.basePath (not (eq .Values.global.basePath "/")) }}/{{ include "studio.basePath" . }}{{- end }}/api"
UI_URL: "http{{ if $.Values.global.ingress.tlsEnabled }}s{{ end }}://{{.Values.global.host }}/{{- if and .Values.global.basePath (not (eq .Values.global.basePath "/")) }}{{ include "studio.basePath" . }}{{- end }}"

{{- if and .Values.global.basePath (not (eq .Values.global.basePath "/")) }}
BASE_PATH: /{{ include "studio.basePath" . }}
{{- end }}

{{- if .Values.global.scmProviders.bitbucket.url }}
BITBUCKET_URL: {{.Values.global.scmProviders.bitbucket.url | quote }}
Expand All @@ -35,8 +39,8 @@ data:
{{- else }}
BLOBVAULT_LOCAL_ENABLED: "True"
BLOBVAULT_LOCAL_PATH: "/blobvault"
BLOBVAULT_ENDPOINT_URL: "http{{ if $.Values.global.ingress.tlsEnabled }}s{{ end }}://{{.Values.global.host }}/blobvault"
BLOBVAULT_ENDPOINT_URL_FE: "http{{ if $.Values.global.ingress.tlsEnabled }}s{{ end }}://{{.Values.global.host }}/blobvault"
BLOBVAULT_ENDPOINT_URL: "http{{ if $.Values.global.ingress.tlsEnabled }}s{{ end }}://{{.Values.global.host }}{{- if and .Values.global.basePath (not (eq .Values.global.basePath "/")) }}/{{ include "studio.basePath" . }}{{- end }}/blobvault"
BLOBVAULT_ENDPOINT_URL_FE: "http{{ if $.Values.global.ingress.tlsEnabled }}s{{ end }}://{{.Values.global.host }}{{- if and .Values.global.basePath (not (eq .Values.global.basePath "/")) }}/{{ include "studio.basePath" . }}{{- end }}/blobvault"
{{- end }}

{{- if .Values.global.celery.brokerUrl }}
Expand Down Expand Up @@ -109,4 +113,3 @@ data:
{{- else }}
SOCIAL_AUTH_ALLOWED_REDIRECT_HOSTS: "studio-ui.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.studioUi.service.port }},studio-backend.{{ .Release.Namespace }}.svc.cluster.local:{{ .Values.studioBackend.service.port }}"
{{- end }}

6 changes: 5 additions & 1 deletion charts/studio/templates/deployment-studio-ui.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ spec:
periodSeconds: 10
readinessProbe:
httpGet:
path: /api/health
{{- if and .Values.global.basePath (not (eq .Values.global.basePath "/")) }}
path: /{{ include "studio.basePath" . }}/{{- if semverCompare ">=1.78.0" (.Values.studioUi.image.tag | default .Chart.AppVersion) }}f{{end}}api/health
{{- else }}
path: /{{- if semverCompare ">=1.78.0" (.Values.studioUi.image.tag | default .Chart.AppVersion) }}f{{end}}api/health
{{- end }}
port: 3000
initialDelaySeconds: 5
periodSeconds: 25
Expand Down
4 changes: 4 additions & 0 deletions charts/studio/templates/ingress-blobvault.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@ spec:
rules:
- http:
paths:
{{- if and .Values.global.basePath (not (eq .Values.global.basePath "/")) }}
- path: /{{ include "studio.basePath" . }}/blobvault(/|$)(.*)
{{- else }}
- path: /blobvault(/|$)(.*)
{{- end }}
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
pathType: ImplementationSpecific
{{- end }}
Expand Down
60 changes: 60 additions & 0 deletions charts/studio/templates/ingress-studio-api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
{{- if .Values.global.ingress.enabled -}}
{{- if and .Values.global.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.global.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.global.ingress.annotations "kubernetes.io/ingress.class" .Values.global.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ .Release.Name }}-studio-api
labels:
{{- include "studio-ui.labels" . | nindent 4 }}
annotations:
{{- if and .Values.global.basePath (not (eq .Values.global.basePath "/")) }}
nginx.ingress.kubernetes.io/rewrite-target: /$1
{{- end }}
{{- with .Values.global.ingress.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.global.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.global.ingress.className }}
{{- end }}
{{- if and .Values.global.ingress.tlsEnabled .Values.global.ingress.hostnameEnabled }}
tls:
- hosts:
- {{ .Values.global.host }}
secretName: {{ .Values.global.ingress.tlsSecretName }}
{{- end }}
rules:
- http:
paths:
{{- if and .Values.global.basePath (not (eq .Values.global.basePath "/")) }}
- path: /{{ include "studio.basePath" . }}/(api(?:/|$).*)
{{- else }}
- path: /api
{{- end }}
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
pathType: ImplementationSpecific
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: studio-backend
port:
number: {{ .Values.studioBackend.service.port }}
{{- else }}
serviceName: studio-backend
servicePort: {{ .Values.studioBackend.service.port }}
{{- end }}
{{- if .Values.global.ingress.hostnameEnabled }}
host: {{ .Values.global.host }}
{{- end }}
{{- end }}
57 changes: 57 additions & 0 deletions charts/studio/templates/ingress-studio-ui.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{{- if .Values.global.ingress.enabled -}}
{{- if and .Values.global.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.global.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.global.ingress.annotations "kubernetes.io/ingress.class" .Values.global.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ .Release.Name }}-studio-ui
labels:
{{- include "studio-ui.labels" . | nindent 4 }}
annotations:
{{- with .Values.global.ingress.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.global.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.global.ingress.className }}
{{- end }}
{{- if and .Values.global.ingress.tlsEnabled .Values.global.ingress.hostnameEnabled }}
tls:
- hosts:
- {{ .Values.global.host }}
secretName: {{ .Values.global.ingress.tlsSecretName }}
{{- end }}
rules:
- http:
paths:
{{- if and .Values.global.basePath (not (eq .Values.global.basePath "/")) }}
- path: /{{ include "studio.basePath" . }}((?:/|$).*)
{{- else }}
- path: /
{{- end }}
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
pathType: ImplementationSpecific
{{- end }}
backend:
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: studio-ui
port:
number: {{ .Values.studioUi.service.port }}
{{- else }}
serviceName: studio-ui
servicePort: {{ .Values.studioUi.service.port }}
{{- end }}
{{- if .Values.global.ingress.hostnameEnabled }}
host: {{ .Values.global.host }}
{{- end }}
{{- end }}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,14 @@ apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: app
name: {{ .Release.Name }}-studio-webhook
labels:
{{- include "studio-ui.labels" . | nindent 4 }}
{{- with .Values.global.ingress.annotations }}
annotations:
{{- if and .Values.global.basePath (not (eq .Values.global.basePath "/")) }}
nginx.ingress.kubernetes.io/rewrite-target: /$1
{{- end }}
{{- with .Values.global.ingress.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
Expand All @@ -33,35 +36,11 @@ spec:
rules:
- http:
paths:
- path: /
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
pathType: ImplementationSpecific
{{- end }}
backend:
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: studio-ui
port:
number: {{ .Values.studioUi.service.port }}
{{- else }}
serviceName: studio-ui
servicePort: {{ .Values.studioUi.service.port }}
{{- end }}
- path: /api
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
pathType: ImplementationSpecific
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: studio-backend
port:
number: {{ .Values.studioBackend.service.port }}
{{- else }}
serviceName: studio-backend
servicePort: {{ .Values.studioBackend.service.port }}
{{- end }}
{{- if and .Values.global.basePath (not (eq .Values.global.basePath "/")) }}
- path: /{{ include "studio.basePath" . }}/(webhook(?:/|$).*)
{{- else }}
- path: /webhook
{{- end }}
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
pathType: ImplementationSpecific
{{- end }}
Expand Down
2 changes: 2 additions & 0 deletions charts/studio/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ imagePullSecrets: []
global:
# -- Studio: Hostname for accessing Studio (no http(s) scheme)
host: "studio.example.com"
# -- Studio: Base path (prefix)
basePath: ""
# -- Studio: Maximum number of views
maxViews: "100"
# -- Studio: Maximum number of teams
Expand Down

0 comments on commit 4cac458

Please sign in to comment.