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

Ingress configuration in Helm chart #7

Merged
merged 3 commits into from
Aug 14, 2024
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
2 changes: 2 additions & 0 deletions .github/workflows/functional.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ jobs:

- name: Create k8s Kind Cluster
uses: helm/[email protected]
with:
config: kind-config.yml

- name: Run test
timeout-minutes: 10
Expand Down
30 changes: 30 additions & 0 deletions charts/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- $ingress := .Values.ingress }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Release.Name }}
labels: {{ include "coral-credits.labels" . | nindent 4 }}
{{- $tlsAnnotations := $ingress.tls.enabled | ternary $ingress.tls.annotations dict }}
{{- $annotations := mergeOverwrite $ingress.annotations $tlsAnnotations }}
{{- with $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: {{ include "coral-credits.fullname" . }}
port:
name: http
17 changes: 17 additions & 0 deletions charts/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,23 @@ securityContext:
drop: [ALL]
readOnlyRootFilesystem: true

# Ingress settings
ingress:
# The hostname to use for the portal
host:
# 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
Expand Down
17 changes: 17 additions & 0 deletions kind-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
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
- containerPort: 443
hostPort: 443
protocol: TCP
17 changes: 12 additions & 5 deletions tools/functional_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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/_status/)
if [ "$status" -eq 204 ]; then
return 0
else
Expand All @@ -29,6 +29,13 @@ RELEASE_NAME=$CHART_NAME
NAMESPACE=$CHART_NAME
TEST_PASSWORD="testpassword"

# 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

# Install the CaaS operator from the chart we are about to ship
# Make sure to use the images that we just built
helm upgrade $RELEASE_NAME ./charts \
Expand All @@ -39,12 +46,12 @@ 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.tls.enabled=false

# 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 &

# Wait for port to be open
echo "Waiting for port $PORT to be available..."
Expand Down
Loading