From 5c6c627d3ef539d798695e747c3b7c06da1cf1eb Mon Sep 17 00:00:00 2001 From: Dawid Rusnak Date: Tue, 12 Nov 2024 10:48:30 +0100 Subject: [PATCH] fix: add back CLI ingress --- charts/testkube-api/README.md | 7 +++ .../testkube-api/templates/cli-ingress.yaml | 58 +++++++++++++++++++ charts/testkube-api/values.yaml | 20 +++++++ charts/testkube/README.md | 6 ++ charts/testkube/values.yaml | 29 ++++++++++ 5 files changed, 120 insertions(+) create mode 100644 charts/testkube-api/templates/cli-ingress.yaml diff --git a/charts/testkube-api/README.md b/charts/testkube-api/README.md index be4085688..2a7637dd7 100644 --- a/charts/testkube-api/README.md +++ b/charts/testkube-api/README.md @@ -29,6 +29,13 @@ A Helm chart for Testkube api | autoscaling.targetCPUUtilizationPercentage | int | `80` | | | autoscaling.targetMemoryUtilizationPercentage | int | `80` | | | cdeventsTarget | string | `""` | | +| cliIngress.annotations | object | `{}` | | +| cliIngress.enabled | bool | `false` | | +| cliIngress.hosts | list | `[]` | | +| cliIngress.labels | object | `{}` | | +| cliIngress.path | string | `"/results/(v\\d/.*)"` | | +| cliIngress.tls | list | `[]` | | +| cliIngress.tlsenabled | bool | `false` | | | cloud.envId | string | `""` | | | cloud.existingSecret.envId | string | `""` | | | cloud.existingSecret.key | string | `""` | | diff --git a/charts/testkube-api/templates/cli-ingress.yaml b/charts/testkube-api/templates/cli-ingress.yaml new file mode 100644 index 000000000..d2a260baf --- /dev/null +++ b/charts/testkube-api/templates/cli-ingress.yaml @@ -0,0 +1,58 @@ +{{- if .Values.cliIngress.enabled -}} +apiVersion: {{ include "global.capabilities.ingress.apiVersion" . }} +kind: Ingress +metadata: + name: cli-{{ include "testkube-api.fullname" $ }}-{{ .Release.Name }} + labels: + {{- include "testkube-api.labels" . | nindent 4 }} + {{- if .Values.cliIngress.labels }} + {{- include "global.tplvalues.render" ( dict "value" .Values.cliIngress.labels "context" $ ) | nindent 4 }} + {{- end }} + {{- if .Values.global.labels }} + {{- include "global.tplvalues.render" ( dict "value" .Values.global.labels "context" $ ) | nindent 4 }} + {{- end }} + annotations: + {{- if and .Values.cliIngress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.Version)) }} + kubernetes.io/ingress.class: {{ .Values.cliIngress.className }} + {{- end }} + {{- if .Values.cliIngress.annotations }} + {{- include "global.tplvalues.render" (dict "value" .Values.cliIngress.annotations "context" $) | nindent 4 }} + {{- end }} + {{- if .Values.global.annotations }} + {{- include "global.tplvalues.render" ( dict "value" .Values.global.annotations "context" $ ) | nindent 4 }} + {{- end }} +spec: + {{- if and .Values.cliIngress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.Version) }} + ingressClassName: {{ .Values.cliIngress.className }} + {{- end }} + {{- if .Values.cliIngress.tls }} + tls: + {{- if .Values.cliIngress.tlsenabled }} + {{- range .Values.cliIngress.tls }} + - hosts: + {{- range .hosts }} + - {{ . | quote }} + {{- end }} + secretName: {{ .secretName }} + {{- end }} + {{- end }} + {{- end }} + rules: + {{- range .Values.cliIngress.hosts }} + - host: {{ . | quote }} + http: + paths: + - path: {{ $.Values.cliIngress.path }} + pathType: Prefix + backend: + {{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.Version }} + service: + name: {{ include "testkube-api.fullname" $ }} + port: + number: {{ $.Values.service.port }} + {{- else }} + serviceName: {{ include "testkube-api.fullname" $ }} + servicePort: {{ $.Values.service.port }} + {{- end }} + {{- end }} + {{- end }} diff --git a/charts/testkube-api/values.yaml b/charts/testkube-api/values.yaml index 378b4145c..1ea1db55d 100644 --- a/charts/testkube-api/values.yaml +++ b/charts/testkube-api/values.yaml @@ -633,6 +633,26 @@ uiIngress: # - testkube.example.com # secretName: testkube-cert-secret +## cliIngress parameters +cliIngress: + ## Use cliIngress + enabled: false + ## Labels to add to the Ingress + labels: {} + ## Annotations to add to the Ingress + annotations: {} + ## The Path to Nginx. + path: /results/(v\d/.*) + ## Hostnames must be provided if Ingress is enabled. + hosts: [] + # - testkube.example.com + tlsenabled: false + # Placing a host in the TLS config will indicate a certificate should be created + tls: [] + # - hosts: + # - testkube.example.com + # secretName: testkube-cert-secret + ## Prometheus monitoring prometheus: ## Toggle whether to install ServiceMonitor diff --git a/charts/testkube/README.md b/charts/testkube/README.md index c00083fd7..d2af72dd2 100644 --- a/charts/testkube/README.md +++ b/charts/testkube/README.md @@ -219,6 +219,12 @@ kubectl label --overwrite crds scripts.tests.testkube.io app.kubernetes.io/manag | testkube-api.additionalVolumes | list | `[]` | Additional volumes to be added | | testkube-api.analyticsEnabled | bool | `true` | Enable analytics for Testkube | | testkube-api.cdeventsTarget | string | `""` | target for cdevents emission via http(s) | +| testkube-api.cliIngress.annotations | object | `{}` | Additional annotations for the Ingress resource. | +| testkube-api.cliIngress.enabled | bool | `false` | Use ingress | +| testkube-api.cliIngress.hosts | list | `["testkube.example.com"]` | Hostnames must be provided if Ingress is enabled. | +| testkube-api.cliIngress.path | string | `"/results/(v\\d/.*)"` | | +| testkube-api.cliIngress.tls | list | `[]` | Placing a host in the TLS config will indicate a certificate should be created | +| testkube-api.cliIngress.tlsenabled | bool | `false` | Toggle whether to enable TLS on the ingress | | testkube-api.cloud.key | string | `""` | Testkube Clouc License Key (for Environment) | | testkube-api.cloud.tls.certificate.caFile | string | `"/tmp/agent-cert/ca.crt"` | Default path for ca file | | testkube-api.cloud.tls.certificate.certFile | string | `"/tmp/agent-cert/cert.crt"` | Default path for certificate file | diff --git a/charts/testkube/values.yaml b/charts/testkube/values.yaml index b874b1199..9bf44d201 100644 --- a/charts/testkube/values.yaml +++ b/charts/testkube/values.yaml @@ -614,6 +614,35 @@ testkube-api: # - testkube.example.com # secretName: testkube-cert-secret + # cliIngress parameters + cliIngress: + # -- Use ingress + enabled: false + # -- Additional annotations for the Ingress resource. + annotations: {} + # e.g. annotations for NGINX Ingress Controller: + # kubernetes.io/ingress.class: nginx + # nginx.ingress.kubernetes.io/rewrite-target: /$1 + # nginx.ingress.kubernetes.io/force-ssl-redirect: "false" + # nginx.ingress.kubernetes.io/ssl-redirect: "false" + # nginx.ingress.kubernetes.io/configuration-snippet: | + # more_set_headers "X-CLI-Ingress: true"; + # for websockets + # nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" + # nginx.ingress.kubernetes.io/proxy-send-timeout: "3600" + path: /results/(v\d/.*) + # -- Hostnames must be provided if Ingress is enabled. + hosts: + - testkube.example.com + # -- Toggle whether to enable TLS on the ingress + tlsenabled: false + # -- Placing a host in the TLS config will indicate a certificate should be created + tls: + [] + # - hosts: + # - testkube.example.com + # secretName: testkube-cert-secret + # Storage for Testkube API using MinIO storage: # -- MinIO endpoint