|
| 1 | +name: E2E Test |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + - cron: '00 03 * * *' |
| 6 | + workflow_dispatch: # Allow manual triggering |
| 7 | + inputs: |
| 8 | + operator_version: |
| 9 | + description: 'Operator version/tag (e.g., edge, x.y.z)' |
| 10 | + required: false |
| 11 | + default: 'edge' |
| 12 | + type: string |
| 13 | + workflow_call: # Allow being called by other workflows |
| 14 | + inputs: |
| 15 | + operator_version: |
| 16 | + description: 'Operator version/tag (e.g., edge, x.y.z)' |
| 17 | + required: false |
| 18 | + default: 'edge' |
| 19 | + type: string |
| 20 | + |
| 21 | +env: |
| 22 | + OPERATOR_VERSION: ${{ inputs.operator_version || 'edge' }} |
| 23 | + |
| 24 | +concurrency: |
| 25 | + group: ${{ github.ref_name }}-e2e |
| 26 | + cancel-in-progress: true |
| 27 | + |
| 28 | +permissions: |
| 29 | + contents: read |
| 30 | + |
| 31 | +jobs: |
| 32 | + e2e-test: |
| 33 | + name: End-to-End Test |
| 34 | + runs-on: ubuntu-22.04 |
| 35 | + steps: |
| 36 | + - name: Checkout Repository |
| 37 | + uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 38 | + |
| 39 | + - name: Get Latest Versions |
| 40 | + run: | |
| 41 | + # Get latest Kubernetes version |
| 42 | + echo "KUBERNETES_VERSION=$(curl -s https://api.github.com/repos/kubernetes/kubernetes/releases/latest | grep '"tag_name"' | cut -d'"' -f4)" >> $GITHUB_ENV |
| 43 | + |
| 44 | + # Get latest Minikube version |
| 45 | + echo "MINIKUBE_VERSION=$(curl -s https://api.github.com/repos/kubernetes/minikube/releases/latest | grep '"tag_name"' | cut -d'"' -f4)" >> $GITHUB_ENV |
| 46 | +
|
| 47 | + - name: Install kubectl |
| 48 | + run: | |
| 49 | + curl -LO "https://dl.k8s.io/release/${{ env.KUBERNETES_VERSION }}/bin/linux/amd64/kubectl" |
| 50 | + chmod +x kubectl |
| 51 | + sudo mv kubectl /usr/local/bin/ |
| 52 | +
|
| 53 | + - name: Install Minikube |
| 54 | + run: | |
| 55 | + curl -Lo minikube https://storage.googleapis.com/minikube/releases/${{ env.MINIKUBE_VERSION }}/minikube-linux-amd64 |
| 56 | + chmod +x minikube |
| 57 | + sudo mv minikube /usr/local/bin/ |
| 58 | +
|
| 59 | + - name: Start Minikube |
| 60 | + run: | |
| 61 | + minikube start --kubernetes-version=${{ env.KUBERNETES_VERSION }} --driver=docker --memory=4g --cpus=2 |
| 62 | +
|
| 63 | + - name: Verify Kubernetes cluster |
| 64 | + run: | |
| 65 | + kubectl cluster-info |
| 66 | + kubectl get nodes |
| 67 | + kubectl get pods -A |
| 68 | +
|
| 69 | + - name: Deploy NGINX Ingress Operator |
| 70 | + run: | |
| 71 | + # Deploy the operator using make deploy with specified version, edge otherwise |
| 72 | + make deploy IMG=nginx/nginx-ingress-operator:${{ env.OPERATOR_VERSION }} |
| 73 | + |
| 74 | + # Wait for the operator to be ready |
| 75 | + kubectl wait --for=condition=Available --timeout=300s deployment/nginx-ingress-operator-controller-manager -n nginx-ingress-operator-system |
| 76 | +
|
| 77 | + - name: Verify Operator Deployment |
| 78 | + run: | |
| 79 | + # Check operator deployment status |
| 80 | + kubectl get deployments -n nginx-ingress-operator-system |
| 81 | + kubectl get pods -n nginx-ingress-operator-system |
| 82 | + |
| 83 | + # Check operator logs |
| 84 | + kubectl logs -l control-plane=controller-manager -n nginx-ingress-operator-system --tail=50 |
| 85 | +
|
| 86 | + - name: Deploy Example NGINX Ingress Controller |
| 87 | + run: | |
| 88 | + # Create the namespace and NGINX Ingress Controller instance in namespace nginx-ingress |
| 89 | + kubectl create namespace nginx-ingress |
| 90 | + kubectl apply -f tests/nginx-ingress-controller-oss.yaml |
| 91 | + |
| 92 | + # Wait for the operator to process and install the Helm release |
| 93 | + echo "Waiting for operator to install Helm release..." |
| 94 | + sleep 30 |
| 95 | + |
| 96 | + # Check what deployments were actually created |
| 97 | + echo "Checking deployments in nginx-ingress namespace:" |
| 98 | + kubectl get deployments -n nginx-ingress |
| 99 | + |
| 100 | + # Find the actual deployment name |
| 101 | + DEPLOYMENT_NAME=$(kubectl get deployments -n nginx-ingress -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || echo "") |
| 102 | + |
| 103 | + if [ -z "$DEPLOYMENT_NAME" ]; then |
| 104 | + echo "No deployment found, waiting longer..." |
| 105 | + sleep 30 |
| 106 | + kubectl get deployments -n nginx-ingress |
| 107 | + DEPLOYMENT_NAME=$(kubectl get deployments -n nginx-ingress -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || echo "") |
| 108 | + fi |
| 109 | + |
| 110 | + if [ -n "$DEPLOYMENT_NAME" ]; then |
| 111 | + echo "Found deployment: $DEPLOYMENT_NAME" |
| 112 | + # Export for use in subsequent steps |
| 113 | + echo "DEPLOYMENT_NAME=$DEPLOYMENT_NAME" >> $GITHUB_ENV |
| 114 | + # Wait for the NGINX Ingress Controller to be ready |
| 115 | + kubectl wait --for=condition=Available --timeout=300s deployment/$DEPLOYMENT_NAME -n nginx-ingress |
| 116 | + else |
| 117 | + echo "Failed to find any deployment in nginx-ingress namespace" |
| 118 | + exit 1 |
| 119 | + fi |
| 120 | + - name: Verify NGINX Ingress Controller Deployment |
| 121 | + run: | |
| 122 | + # Check all resources in the nginx ingress controller namespace |
| 123 | + kubectl get all -n nginx-ingress |
| 124 | + |
| 125 | + # Check if the controller pod is running |
| 126 | + kubectl get pods -n nginx-ingress |
| 127 | + |
| 128 | + # Check the service |
| 129 | + kubectl get services -n nginx-ingress |
| 130 | + |
| 131 | + # Check ingress class |
| 132 | + kubectl get ingressclass |
| 133 | + |
| 134 | + # Verify all pods are ready in nginx-ingress namespace |
| 135 | + kubectl wait --for=condition=Ready --timeout=300s pod --all -n nginx-ingress |
| 136 | +
|
| 137 | + - name: Verify NGINX Configuration |
| 138 | + run: | |
| 139 | + echo "Testing NGINX configuration for deployment: $DEPLOYMENT_NAME" |
| 140 | + |
| 141 | + # Check NGINX configuration is valid |
| 142 | + kubectl exec -n nginx-ingress deployment/$DEPLOYMENT_NAME -- nginx -t |
| 143 | +
|
| 144 | + - name: Check Operator and Controller Logs |
| 145 | + if: always() |
| 146 | + run: | |
| 147 | + echo "=== Operator Logs ===" |
| 148 | + kubectl logs -l control-plane=controller-manager -n nginx-ingress-operator-system |
| 149 | + |
| 150 | + echo "=== NGINX Ingress Controller Logs ===" |
| 151 | + # Get logs from all pods in nginx-ingress namespace |
| 152 | + for pod in $(kubectl get pods -n nginx-ingress -o jsonpath='{.items[*].metadata.name}' 2>/dev/null || echo ""); do |
| 153 | + if [ -n "$pod" ]; then |
| 154 | + echo "--- Logs for pod: $pod ---" |
| 155 | + kubectl logs $pod -n nginx-ingress |
| 156 | + fi |
| 157 | + done |
0 commit comments