From 5e547e560657bf440dd0b00836bbe4f9852ed5c2 Mon Sep 17 00:00:00 2001 From: Jake Hutchinson Date: Fri, 12 Jul 2024 16:50:23 +0100 Subject: [PATCH] Ingress --- charts/templates/ingress.yaml | 26 ++++++++++++++++++++++++++ charts/values.yaml | 20 ++++++++++++++++++++ tools/functional_test.sh | 12 +++++++++++- 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 charts/templates/ingress.yaml diff --git a/charts/templates/ingress.yaml b/charts/templates/ingress.yaml new file mode 100644 index 0000000..d731975 --- /dev/null +++ b/charts/templates/ingress.yaml @@ -0,0 +1,26 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: {{ .Release.Name }} + {{- with .Values.ingress.annotations }} + annotations: {{ toYaml . | nindent 4 }} + {{- end }} +spec: + ingressClassName: {{ .Values.ingress.className }} + {{- if .Values.ingress.tls.enabled }} + tls: + - hosts: + - {{ .Values.ingress.host }} + secretName: {{ .Values.ingress.tls.secretName }} + {{- end }} + rules: + - host: {{ .Values.ingress.host }} + http: + paths: + - path: / + pathType: Prefix + backend: + service: + name: {{ .Values.service.name }} + port: + name: http diff --git a/charts/values.yaml b/charts/values.yaml index 7fcd139..f6228d2 100644 --- a/charts/values.yaml +++ b/charts/values.yaml @@ -67,6 +67,25 @@ securityContext: drop: [ALL] readOnlyRootFilesystem: true +# Ingress settings +ingress: + # The hostname to use for the portal + host: + # The path for the coral credits API + path: + # The ingress class to use + className: nginx + # Annotations for the portal ingress + annotations: {} + # TLS configuration for the portal ingress + tls: + # Indicates if TLS should be enabled + enabled: true + # The secret to use for the TLS certificate and key + secretName: + # TLS-specific ingress annotations, e.g. for cert-manager configuration + annotations: {} + # Django settings settings: # The Django secret key @@ -104,6 +123,7 @@ replicaCount: 1 # Service details for the api service: + name: coral-credits type: ClusterIP port: 8080 diff --git a/tools/functional_test.sh b/tools/functional_test.sh index cd1434f..3db5ed2 100755 --- a/tools/functional_test.sh +++ b/tools/functional_test.sh @@ -25,7 +25,10 @@ check_http_status() { # Set variables CHART_NAME="coral-credits" +NGINX_NAME="ingress-nginx" +NGINX_CHART="oci://ghcr.io/nginxinc/charts/nginx-ingress" RELEASE_NAME=$CHART_NAME +RELEASE_NGINX=$NGINX_NAME NAMESPACE=$CHART_NAME TEST_PASSWORD="testpassword" @@ -39,10 +42,17 @@ helm upgrade $RELEASE_NAME ./charts \ --wait \ --timeout 3m \ --set-string image.tag=${GITHUB_SHA::7} \ - --set settings.superuserPassword=$TEST_PASSWORD + --set settings.superuserPassword=$TEST_PASSWORD \ + --set ingress.host='localhost' \ + --set ingress.path='/' # Wait for rollout kubectl rollout status deployment/$RELEASE_NAME -n $NAMESPACE --timeout=300s -w + +# Install nginx +helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx +helm install --wait --debug ingress-nginx ingress-nginx/ingress-nginx + # Port forward in the background kubectl port-forward -n $NAMESPACE svc/$RELEASE_NAME $PORT:$PORT &