Skip to content
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
26 changes: 9 additions & 17 deletions e2e/provider/coredns.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ spec:
app: coredns
spec:
hostNetwork: true
dnsPolicy: Default
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: coredns
image: coredns/coredns:1.13.1
Expand All @@ -52,23 +52,15 @@ spec:
name: dns-tcp
protocol: TCP
livenessProbe:
httpGet:
path: /health
port: 8080
scheme: HTTP
initialDelaySeconds: 60
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 5
readinessProbe:
httpGet:
path: /ready
port: 8181
scheme: HTTP
tcpSocket:
port: 5353
initialDelaySeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 5
periodSeconds: 10
readinessProbe:
tcpSocket:
port: 5353
initialDelaySeconds: 5
periodSeconds: 5
volumes:
- name: config-volume
configMap:
Expand Down
82 changes: 47 additions & 35 deletions scripts/e2e-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,20 @@ curl -Lo ./kind https://kind.sigs.k8s.io/dl/v${KIND_VERSION}/kind-linux-amd64
chmod +x ./kind
sudo mv ./kind /usr/local/bin/kind

# Cleanup function
cleanup() {
echo "Cleaning up..."
kind delete cluster 2>/dev/null || true
}

# Create kind cluster
echo "Creating kind cluster..."
kind delete cluster 2>/dev/null || true
kind create cluster

# Set trap to cleanup on script exit
trap cleanup EXIT

# Install kubectl
echo "Installing kubectl..."
curl -LO "https://dl.k8s.io/release/v${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
Expand Down Expand Up @@ -48,6 +58,18 @@ echo "Using image reference: $EXTERNAL_DNS_IMAGE"
echo "Applying etcd"
kubectl apply -f e2e/provider/etcd.yaml

# wait for etcd to be ready
echo "Waiting for etcd to be ready..."
kubectl wait --for=condition=ready --timeout=120s pod -l app=etcd

# apply coredns deployment
echo "Applying CoreDNS"
kubectl apply -f e2e/provider/coredns.yaml

# wait for coredns to be ready
echo "Waiting for CoreDNS to be ready..."
kubectl wait --for=condition=available --timeout=120s deployment/coredns

# Build a DNS testing image with dig
echo "Building DNS test image with dig..."
docker build -t dns-test:v1 -f - . <<EOF
Expand Down Expand Up @@ -78,6 +100,7 @@ spec:
template:
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
containers:
- name: external-dns
args:
Expand Down Expand Up @@ -128,10 +151,6 @@ rm -rf "$TEMP_KUSTOMIZE_DIR"
echo "Applying Kubernetes service..."
kubectl apply -f e2e

# Wait for convergence
echo "Waiting for convergence (90 seconds)..."
sleep 90 # normal loop is 60 seconds, this is enough and should not cause flakes

# Check that the records are present
echo "Checking services again..."
kubectl get svc -owide
Expand All @@ -144,10 +163,10 @@ echo "Testing DNS server functionality..."
NODE_IP=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}')
echo "Node IP: $NODE_IP"

# Test our DNS server with dig
echo "Testing DNS server with dig..."
# Test our DNS server with dig, with retry logic
echo "Testing DNS server with dig (with retries)..."

# Create DNS test job that uses dig to query our DNS server
# Create DNS test job that uses dig to query our DNS server with retries
cat <<EOF | kubectl apply -f -
apiVersion: batch/v1
kind: Job
Expand All @@ -156,7 +175,7 @@ metadata:
labels:
app: dns-server-test
spec:
backoffLimit: 3
backoffLimit: 0
template:
metadata:
labels:
Expand All @@ -172,24 +191,28 @@ spec:
- -c
- |
echo "Testing DNS server at $NODE_IP:5353"
echo "=== Testing DNS server with dig (retrying for up to 180s) ==="
MAX_ATTEMPTS=18
ATTEMPT=1
while [ \$ATTEMPT -le \$MAX_ATTEMPTS ]; do
echo "Attempt \$ATTEMPT/\$MAX_ATTEMPTS: Querying externaldns-e2e.external.dns A record"
RESULT=\$(dig @$NODE_IP -p 5353 externaldns-e2e.external.dns A +short +timeout=5 2>/dev/null)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe something like

dig @coredns.default.svc.cluster.local

If we are using coredns

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could validate, where the records added to etcd, something like

kubectl exec -it etcd-0 -- etcdctl get /skydns/dns/external --prefix --keys-only

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure how this would add? Maybe you say it to reduce possible flakyness? I did it just with dig originally to make a test that was as close as possible to users 🤔

Copy link
Copy Markdown
Member

@ivankatliarchuk ivankatliarchuk Mar 2, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, not a big difference. Is goot too go as is.

For dig @coredns.default.svc.cluster.local (service DNS) the only difference with NODE_IP

  • Tests the actual path -> reflects how real workloads inside the cluster resolve DNS, which is what external-dns is supposed to serve

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok cool, I think I understand your point of view now, but the change would also add a bit of complexity. I’ll merge like this, so we have working tests again.

if echo "\$RESULT" | grep -qE '^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$'; then
echo "DNS query successful: \$RESULT"
exit 0
fi
echo "DNS query returned empty result, retrying in 10s..."
sleep 10
ATTEMPT=\$((ATTEMPT + 1))
done
echo "DNS query failed after \$MAX_ATTEMPTS attempts"
exit 1

echo "=== Testing DNS server with dig ==="
echo "Querying: externaldns-e2e.external.dns A record"
if dig @$NODE_IP -p 5353 externaldns-e2e.external.dns A +short +timeout=5; then
echo "DNS query successful"
exit 0
else
echo "DNS query failed"
exit 1
fi

echo "DNS server tests completed"
exit 0
EOF

# Wait for the job to complete
echo "Waiting for DNS server test job to complete..."
kubectl wait --for=condition=complete --timeout=90s job/dns-server-test-job || true
kubectl wait --for=condition=complete --timeout=240s job/dns-server-test-job || true

# Check job status and get results
echo "DNS server test job results:"
Expand All @@ -211,17 +234,6 @@ kubectl delete job dns-server-test-job

echo "End-to-end test completed!"

# Cleanup function
cleanup() {
echo "Cleaning up..."
if [ ! -z "$EXTERNAL_DNS_PID" ]; then
kill $EXTERNAL_DNS_PID 2>/dev/null || true
fi
if [ ! -z "$LOCAL_PROVIDER_PID" ]; then
kill $LOCAL_PROVIDER_PID 2>/dev/null || true
fi
kind delete cluster 2>/dev/null || true
}

# Set trap to cleanup on script exit
trap cleanup EXIT
if [ "$TEST_PASSED" != "true" ]; then
exit 1
fi
Loading