Skip to content

Commit 9a858a3

Browse files
authored
add operator install workflow (#534)
1 parent 4d2dc06 commit 9a858a3

File tree

3 files changed

+187
-1
lines changed

3 files changed

+187
-1
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,10 +151,17 @@ jobs:
151151
- OpenShift {{openshift_version}} or newer.
152152
if: github.event_name != 'pull_request'
153153

154+
e2e-test:
155+
name: Run E2E Tests # Deploy NGINX Ingress Operator and Nginx Ingress Controller
156+
uses: ./.github/workflows/e2e-test.yml
157+
needs: build
158+
with:
159+
operator_version: ${{ github.ref_type == 'tag' && needs.build.outputs.version || 'edge' }}
160+
154161
certify:
155162
name: Certify for Red Hat OpenShift
156163
runs-on: ubuntu-22.04
157-
needs: build
164+
needs: [build, e2e-test]
158165
if: ${{ github.ref_type == 'tag' }}
159166
steps:
160167
- name: Checkout Repository

.github/workflows/e2e-test.yml

Lines changed: 157 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,157 @@
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
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
apiVersion: charts.nginx.org/v1alpha1
2+
kind: NginxIngress
3+
metadata:
4+
name: my-nginx-ingress
5+
namespace: nginx-ingress
6+
spec:
7+
controller:
8+
defaultTLS:
9+
secret: ""
10+
enableCustomResources: true
11+
image:
12+
pullPolicy: Always
13+
repository: nginx/nginx-ingress
14+
tag: 5.1.0
15+
ingressClass:
16+
name: nginx
17+
kind: deployment
18+
nginxplus: false
19+
service:
20+
type: NodePort
21+
rbac:
22+
create: true

0 commit comments

Comments
 (0)