Skip to content

feat: adding haproxy support #1

feat: adding haproxy support

feat: adding haproxy support #1

name: Test HAProxy Ingress
on:
pull_request:
branches:
- main
workflow_dispatch:
inputs:
debug_enabled:
description: 'Run workflow with debug logging'
required: false
default: false
type: boolean
jobs:
test-haproxy-ingress:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set up Helm
uses: azure/setup-helm@v3
with:
version: v3.10.3
- uses: actions/setup-python@v4
with:
python-version: 3.11
- name: Install test dependencies
run: |
npm install -g wscat
sudo apt-get update && sudo apt-get install -y curl
- name: Create kind cluster
uses: helm/[email protected]
with:
wait: 600s
config: |
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 80
hostPort: 80
protocol: TCP
- containerPort: 443
hostPort: 443
protocol: TCP
- name: Install HAProxy Ingress Controller
run: |
helm repo add haproxy-ingress https://haproxy-ingress.github.io/charts
helm repo update
helm install haproxy-ingress haproxy-ingress/haproxy-ingress \
--set controller.service.type=NodePort \
--set controller.watchIngressWithoutClass=true
- name: Wait for HAProxy Ingress
run: |
kubectl wait --namespace default \
--for=condition=ready pod \
--selector=app.kubernetes.io/instance=haproxy-ingress \
--timeout=90s
- name: Set up chart-testing
uses: helm/[email protected]
- name: Create test values for haproxy
run: |
cat <<EOF > haproxy-values.yaml
global:
ingress:
enabled: true
className: haproxy
classType: haproxy
websocketPrefix: /websocket
backendPrefix: /v2/docs
frontendPrefix: /
frontend:
enabled: true
backend:
enabled: true
websocket:
enabled: true
EOF
- name: Debug - Show test values
if: ${{ inputs.debug_enabled }}
run: cat haproxy-values.yaml
- name: Run chart-testing install
run: |
ct install --debug --config ct.yaml --namespace default --values haproxy-values.yaml
- name: Wait for the backend pod
run: |
kubectl wait --namespace default \
--for=condition=ready pod \
--selector=app.kubernetes.io/instance=keep,keep-component=backend \
--timeout=90s
- name: Debug - Show pods and services
if: ${{ inputs.debug_enabled }}
run: |
kubectl get pods -A
kubectl get svc -A
kubectl get ingress -A
kubectl describe ingress -A
- name: Test HAProxy Ingress endpoints
run: |
INGRESS_IP="127.0.0.1"
APP_NAME=$(helm list -n default -o json | jq -r '.[0].name')
echo "Testing frontend endpoint..."
RESP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://$INGRESS_IP/)
echo "Frontend response code: $RESP_CODE"
[ "$RESP_CODE" -eq 200 ] || exit 1
echo "Testing backend endpoint..."
RESP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://$INGRESS_IP/v2/docs/)
echo "Backend response code: $RESP_CODE"
[ "$RESP_CODE" -eq 200 ] || exit 1
echo "Testing websocket endpoint..."
RESP_CODE=$(curl -s -o /dev/null -w "%{http_code}" -H "Upgrade: websocket" -H "Connection: Upgrade" http://$INGRESS_IP/websocket/)
echo "WebSocket response code: $RESP_CODE"
[ "$RESP_CODE" -eq 101 ] || [ "$RESP_CODE" -eq 400 ] || exit 1
- name: Debug - Show logs on failure
if: ${{ failure() && inputs.debug_enabled }}
run: |
echo "HAProxy Ingress Controller logs:"
kubectl logs -l app.kubernetes.io/instance=haproxy-ingress -n default --tail=100
echo "Application pods logs:"
for pod in $(kubectl get pods -n default -l app.kubernetes.io/instance=$APP_NAME -o name); do
echo "Logs for $pod:"
kubectl logs $pod -n default --tail=100
done