diff --git a/.github/workflows/functional.yaml b/.github/workflows/functional.yaml index 78327b1..45ab671 100644 --- a/.github/workflows/functional.yaml +++ b/.github/workflows/functional.yaml @@ -19,6 +19,8 @@ jobs: - name: Create k8s Kind Cluster uses: helm/kind-action@v1.9.0 + with: + config: kind-config.yml - name: Run test timeout-minutes: 10 diff --git a/charts/templates/ingress.yaml b/charts/templates/ingress.yaml new file mode 100644 index 0000000..9a109d9 --- /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: {{ .Values.ingress.path }} + pathType: Prefix + backend: + service: + name: {{ .Values.service.name }} + port: + number: 8080 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/kind-config.yml b/kind-config.yml new file mode 100644 index 0000000..a85fe0d --- /dev/null +++ b/kind-config.yml @@ -0,0 +1,14 @@ +kind: Cluster +apiVersion: kind.x-k8s.io/v1alpha4 +nodes: +- role: control-plane + kubeadmConfigPatches: + - | + kind: InitConfiguration + nodeRegistration: + kubeletExtraArgs: + node-labels: "ingress-ready=true" + extraPortMappings: + - containerPort: 80 + hostPort: 80 + protocol: TCP diff --git a/tools/functional_test.sh b/tools/functional_test.sh index cd1434f..fe2e2bd 100755 --- a/tools/functional_test.sh +++ b/tools/functional_test.sh @@ -4,7 +4,7 @@ set -eux SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd) -PORT=8080 +PORT=80 SITE=localhost # Function to check if port is open check_port() { @@ -14,7 +14,7 @@ check_port() { # Function to check HTTP status check_http_status() { - local status=$(curl -s -o /dev/null -w "%{http_code}" http://$SITE:$PORT/_status/) + local status=$(curl -s -o /dev/null -w "%{http_code}" http://$SITE/coral-credits/_status/) if [ "$status" -eq 204 ]; then return 0 else @@ -39,12 +39,19 @@ 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=$SITE \ + --set ingress.path='/coral-credits' # Wait for rollout kubectl rollout status deployment/$RELEASE_NAME -n $NAMESPACE --timeout=300s -w -# Port forward in the background -kubectl port-forward -n $NAMESPACE svc/$RELEASE_NAME $PORT:$PORT & + +# Install nginx +kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/kind/deploy.yaml +kubectl wait --namespace ingress-nginx \ + --for=condition=ready pod \ + --selector=app.kubernetes.io/component=controller \ + --timeout=90s # Wait for port to be open echo "Waiting for port $PORT to be available..."