Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add redirect #72

Merged
merged 8 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions charts/testkube-cloud-ui/templates/ingress-redirect.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
{{- if .Values.ingressRedirect.enabled -}}
{{- $fullName := include "testkube-cloud-ui.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.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: {{ $fullName }}-{{ .Values.global.redirectSubdomain }}
labels:
{{- include "testkube-cloud-ui.labels" . | nindent 4 }}
{{- if .Values.ingressRedirect.labels }}
{{- toYaml .Values.ingressRedirect.labels | nindent 4 }}
{{- end }}
annotations:
nginx.ingress.kubernetes.io/backend-protocol: "HTTP"
nginx.ingress.kubernetes.io/preserve-trailing-slash: "true"
nginx.ingress.kubernetes.io/configuration-snippet: |
add_header X-Frame-Options "sameorigin";
add_header X-XSS-Protection "1; mode=block";
add_header X-Content-Type-Options nosniff;
add_header Referrer-Policy 'same-origin';
add_header Permissions-Policy "accelerometer=(), camera=(), geolocation=(), gyroscope=(), magnetometer=(), microphone=(), payment=(), usb=()";
{{- if (eq .Values.global.certificateProvider "cert-manager") }}
cert-manager.io/cluster-issuer: {{ required ".Values.global.certManager.issuerRef must be provided if provider is cert-manager" .Values.global.certManager.issuerRef }}
{{- end }}
{{- with .Values.ingressRedirect.annotations }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
tls:
- hosts:
- {{ .Values.global.redirectSubdomain }}.{{ .Values.global.domain }}
secretName: "{{ .Values.ingress.tlsSecretName }}-{{ .Values.global.redirectSubdomain }}"
rules:
- host: {{ .Values.global.redirectSubdomain }}.{{ .Values.global.domain }}
http:
paths:
- path: /
{{- if semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion }}
pathType: Prefix
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
name: http
{{- else }}
serviceName: {{ $fullName }}
servicePort: http
{{- end }}
{{- end }}
7 changes: 7 additions & 0 deletions charts/testkube-cloud-ui/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ global:
domain: ""
# -- UI subdomain which get prepended to the domain
uiSubdomain: "cloud"
# -- Different UI subdomain which gets prepended to the domain. May be used for the redirect from your actual uiSubdomain endpoint. Works is ingressRedirect option is enabled.
redirectSubdomain: "app"
# -- TLS provider (possible values: "", "cert-manager")
certificateProvider: ""
certManager:
Expand Down Expand Up @@ -92,6 +94,11 @@ ingress:
provider: "cert-manager"
# -- Hostname for which to create rules and TLS certificates
host: ""
# -- Toggle whether to enable redirect Ingress which allows having a different subdomain redirecting to the actual Dashboard UI Ingress URL
ingressRedirect:
enabled: false
ypoplavs marked this conversation as resolved.
Show resolved Hide resolved
annotations: {}
labels: {}
resources:
requests:
cpu: 50m
Expand Down
5 changes: 5 additions & 0 deletions charts/testkube-enterprise/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ global:
domain: ""
# -- UI subdomain which get prepended to the domain
uiSubdomain: "dashboard"
# -- Different UI subdomain which gets prepended to the domain. May be used for the redirect from your actual uiSubdomain endpoint. Works is ingressRedirect option is enabled.
redirectSubdomain: "app"
# -- REST API subdomain which get prepended to the domain
restApiSubdomain: "api"
# -- gRPC API subdomain which get prepended to the domain
Expand Down Expand Up @@ -205,6 +207,9 @@ testkube-cloud-ui:
ingress:
# -- Name of the TLS secret which contains the certificate files
tlsSecretName: testkube-enterprise-ui-tls
# -- Toggle whether to enable redirect Ingress which allows having a different subdomain redirecting to the actual Dashboard UI Ingress URL
ingressRedirect:
enabled: false

## NATS chart parameter
## For more configuration parameters of NATS chart please look here: https://docs.nats.io/running-a-nats-service/nats-kubernetes/helm-charts
Expand Down