Skip to content

Commit 4a822c0

Browse files
author
Max Azatian
committed
CI fix 8 | cert-gen IP fix
1 parent 66f1c18 commit 4a822c0

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

.github/workflows/tests.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ jobs:
6262
6363
# Simplify Zookeeper for CI
6464
yq eval '.services.zookeeper.environment.ZOOKEEPER_4LW_COMMANDS_WHITELIST = "ruok,srvr"' -i docker-compose.ci.yaml
65+
# Disable zookeeper healthcheck in CI (use service_started instead)
66+
yq eval 'del(.services.zookeeper.healthcheck)' -i docker-compose.ci.yaml
67+
# Make Kafka start as soon as Zookeeper starts (not healthy)
68+
yq eval '.services.kafka.depends_on.zookeeper.condition = "service_started"' -i docker-compose.ci.yaml
6569
6670
# For the cert-generator service
6771
# Check if extra_hosts exists, if not create it as a list

cert-generator/setup-k8s.sh

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -186,37 +186,32 @@ EOF
186186
K8S_PORT=$(echo "$K8S_SERVER" | grep -oE ':[0-9]+' | tr -d ':')
187187
K8S_PORT=${K8S_PORT:-6443}
188188

189-
# Test potential URLs to find one that works
190-
# Priority order: gateway IP, specific Docker IPs, host.docker.internal
189+
# Prefer loopback and gateway IPs first when running with host networking
191190
GATEWAY_IP=$(ip route | grep default | awk '{print $3}')
192-
POTENTIAL_IPS="${GATEWAY_IP} 172.18.0.1 172.17.0.1 host.docker.internal"
191+
POTENTIAL_IPS="127.0.0.1 ${GATEWAY_IP} 172.18.0.1 172.17.0.1 host.docker.internal"
193192

194193
echo "Environment info:"
195194
echo " K8S_PORT: ${K8S_PORT}"
196195
echo " Gateway IP: ${GATEWAY_IP:-none}"
197196
echo " Testing endpoints: ${POTENTIAL_IPS}"
198197

198+
CHOSEN_URL=""
199199
for IP in $POTENTIAL_IPS; do
200200
TEST_URL="https://${IP}:${K8S_PORT}"
201201
echo -n " Trying ${TEST_URL}... "
202-
if timeout 2 bash -c "echo > /dev/tcp/${IP}/${K8S_PORT}" 2>/dev/null; then
203-
K8S_SERVER="${TEST_URL}"
202+
if nc -z -w2 ${IP} ${K8S_PORT} 2>/dev/null; then
203+
CHOSEN_URL="${TEST_URL}"
204204
echo "✓ SUCCESS"
205205
break
206206
fi
207207
echo "✗ failed"
208208
done
209209

210-
# If we get here without K8S_SERVER being updated, no endpoint worked
211-
if echo "$K8S_SERVER" | grep -qE '127\.0\.0\.1|localhost'; then
212-
echo ""
213-
echo "ERROR: K8s API not accessible from container!"
214-
echo " Original server: ${K8S_SERVER}"
215-
echo " Tested IPs: ${POTENTIAL_IPS}"
216-
echo " Port: ${K8S_PORT}"
217-
echo ""
218-
echo "Ensure k3s/k8s is running and accessible from Docker containers"
219-
exit 1
210+
# If none of the alternative endpoints worked, keep the original server URL
211+
if [ -z "$CHOSEN_URL" ]; then
212+
echo "No alternative endpoint worked; keeping original K8S_SERVER: ${K8S_SERVER}"
213+
else
214+
K8S_SERVER="$CHOSEN_URL"
220215
fi
221216

222217
echo "Using K8S_SERVER: ${K8S_SERVER}"

0 commit comments

Comments
 (0)