Skip to content

Commit 77f5777

Browse files
feat: collecting workload cluster pod logs
1 parent 6574043 commit 77f5777

File tree

1 file changed

+82
-1
lines changed

1 file changed

+82
-1
lines changed

.github/workflows/e2e.yml

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,88 @@ jobs:
165165
echo "Collecting cluster events..."
166166
kubectl get events -A --sort-by='.lastTimestamp' > bootstrap-pod-logs/events.txt 2>&1 || true
167167
echo "✓ Saved events.txt"
168-
168+
169+
# Get all clusters
170+
echo "Getting list of workload clusters..."
171+
kubectl get clusters -A > bootstrap-pod-logs/clusters.txt 2>&1 || true
172+
173+
# Collect logs from workload cluster (where konnector-agent actually runs)
174+
echo "===== Collecting logs from WORKLOAD CLUSTER ====="
175+
mkdir -p bootstrap-pod-logs/workload-cluster
176+
177+
# Find the workload cluster name (starts with "quick-start")
178+
WORKLOAD_CLUSTER=$(kubectl get clusters -A -o jsonpath='{.items[?(@.metadata.name contains "quick-start")].metadata.name}' 2>/dev/null | head -n 1)
179+
WORKLOAD_NAMESPACE=$(kubectl get clusters -A -o jsonpath='{.items[?(@.metadata.name contains "quick-start")].metadata.namespace}' 2>/dev/null | head -n 1)
180+
181+
if [[ -n "$WORKLOAD_CLUSTER" && -n "$WORKLOAD_NAMESPACE" ]]; then
182+
echo "Found workload cluster: $WORKLOAD_CLUSTER in namespace $WORKLOAD_NAMESPACE"
183+
184+
# Get workload cluster kubeconfig from secret
185+
echo "Retrieving workload cluster kubeconfig..."
186+
if kubectl get secret -n "$WORKLOAD_NAMESPACE" "${WORKLOAD_CLUSTER}-kubeconfig" -o jsonpath='{.data.value}' 2>/dev/null | base64 -d > bootstrap-pod-logs/workload-cluster/kubeconfig.yaml; then
187+
export WORKLOAD_KUBECONFIG="${PWD}/bootstrap-pod-logs/workload-cluster/kubeconfig.yaml"
188+
echo "✓ Retrieved workload cluster kubeconfig"
189+
190+
# Test connectivity
191+
if kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" cluster-info &> bootstrap-pod-logs/workload-cluster/cluster-info.txt; then
192+
echo "✓ Can connect to workload cluster"
193+
194+
# Get all pods in ntnx-system namespace
195+
echo "Getting pods in ntnx-system namespace..."
196+
kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" get pods -n ntnx-system -o wide > bootstrap-pod-logs/workload-cluster/ntnx-system-pods.txt 2>&1 || true
197+
198+
# Get konnector-agent pod descriptions (THIS IS WHAT YOU WANT!)
199+
echo "Getting konnector-agent pod descriptions..."
200+
kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" describe pods -n ntnx-system -l app.kubernetes.io/name=konnector-agent > bootstrap-pod-logs/workload-cluster/konnector-agent-describe.txt 2>&1 || true
201+
202+
# Get konnector-agent pod logs
203+
echo "Getting konnector-agent pod logs..."
204+
for pod in $(kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" get pods -n ntnx-system -l app.kubernetes.io/name=konnector-agent -o name 2>/dev/null); do
205+
pod_name=$(basename "$pod")
206+
echo " Getting logs for $pod_name..."
207+
kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" logs -n ntnx-system "$pod_name" --all-containers=true --tail=1000 > "bootstrap-pod-logs/workload-cluster/${pod_name}.log" 2>&1 || true
208+
kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" logs -n ntnx-system "$pod_name" --all-containers=true --previous --tail=500 > "bootstrap-pod-logs/workload-cluster/${pod_name}-previous.log" 2>&1 || true
209+
done
210+
211+
# Get hook pod descriptions and logs (hook-preinstall is what fails)
212+
echo "Getting hook pod information..."
213+
kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" get pods -n ntnx-system | grep hook > bootstrap-pod-logs/workload-cluster/hook-pods.txt 2>&1 || true
214+
215+
for hook_pod in hook-preinstall hook-postinstall; do
216+
if kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" get pod -n ntnx-system "$hook_pod" &>/dev/null; then
217+
echo " Found $hook_pod, collecting info..."
218+
kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" describe pod -n ntnx-system "$hook_pod" > "bootstrap-pod-logs/workload-cluster/${hook_pod}-describe.txt" 2>&1 || true
219+
kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" logs -n ntnx-system "$hook_pod" --all-containers=true --tail=1000 > "bootstrap-pod-logs/workload-cluster/${hook_pod}.log" 2>&1 || true
220+
fi
221+
done
222+
223+
# Get konnector-agent secret info (without credentials)
224+
echo "Getting konnector-agent secret info..."
225+
if kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" get secret -n ntnx-system konnector-agent &>/dev/null; then
226+
kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" get secret -n ntnx-system konnector-agent -o yaml | grep -v "password\|credential" > bootstrap-pod-logs/workload-cluster/konnector-agent-secret.yaml 2>&1 || true
227+
echo "Secret keys present:" > bootstrap-pod-logs/workload-cluster/konnector-agent-secret-keys.txt
228+
kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" get secret -n ntnx-system konnector-agent -o jsonpath='{.data}' | grep -o '"[^"]*":' | tr -d '":' >> bootstrap-pod-logs/workload-cluster/konnector-agent-secret-keys.txt 2>&1 || true
229+
fi
230+
231+
# Get workload cluster events
232+
echo "Getting workload cluster events..."
233+
kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" get events -n ntnx-system --sort-by='.lastTimestamp' > bootstrap-pod-logs/workload-cluster/events.txt 2>&1 || true
234+
235+
# Get all namespaces in workload cluster
236+
kubectl --kubeconfig="$WORKLOAD_KUBECONFIG" get namespaces > bootstrap-pod-logs/workload-cluster/namespaces.txt 2>&1 || true
237+
238+
echo "✓ Workload cluster logs collected successfully"
239+
else
240+
echo "✗ Cannot connect to workload cluster"
241+
cat bootstrap-pod-logs/workload-cluster/cluster-info.txt
242+
fi
243+
else
244+
echo "✗ Failed to retrieve workload cluster kubeconfig"
245+
fi
246+
else
247+
echo "No workload cluster found (this is normal if cluster creation failed early)"
248+
fi
249+
169250
echo "===== ✓ Log collection completed successfully ====="
170251
ls -lh bootstrap-pod-logs/
171252
else

0 commit comments

Comments
 (0)