@@ -112,17 +112,25 @@ func testKubeApiserverContainer(oc *exutil.CLI, kubeconfig, masterName string) e
112112 return fmt .Errorf ("location for %s kubeconfig not found" , kubeconfig )
113113 }
114114
115- framework .Logf ("Copying oc binary from host to kube-apiserver container in master %q" , masterName )
116- out , err := oc .AsAdmin ().Run ("debug" ).Args ("node/" + masterName , "--" , "chroot" , "/host" , "/bin/bash" , "-euxo" , "pipefail" , "-c" ,
117- fmt .Sprintf (`oc --kubeconfig /etc/kubernetes/static-pod-resources/kube-apiserver-certs/secrets/node-kubeconfigs/localhost.kubeconfig -n openshift-kube-apiserver cp /usr/bin/oc kube-apiserver-%s:/tmp` , masterName )).Output ()
118- framework .Logf ("%s" , out )
119- if err != nil {
120- return fmt .Errorf ("%s" , out )
121- }
122-
123115 framework .Logf ("Verifying kubeconfig %q in kube-apiserver container in master %q" , kubeconfig , masterName )
124- out , err = oc .AsAdmin ().Run ("exec" ).Args ("-n" , "openshift-kube-apiserver" , "kube-apiserver-" + masterName , "--" , "/bin/bash" , "-euxo" , "pipefail" , "-c" ,
125- fmt .Sprintf (`/tmp/oc --kubeconfig "%s" get nodes` , kubeconfigPath )).Output ()
116+ // Use curl to verify the kubeconfig is present and functional, extracting
117+ // cert paths directly from the kubeconfig file. This avoids copying the oc
118+ // binary from the host into the container, which fails when the host OS
119+ // (e.g., RHCOS 10 with glibc 2.38) has a newer glibc than the container.
120+ out , err := oc .AsAdmin ().Run ("exec" ).Args ("-n" , "openshift-kube-apiserver" , "kube-apiserver-" + masterName , "--" , "/bin/bash" , "-euxo" , "pipefail" , "-c" ,
121+ fmt .Sprintf (`for k in server client-certificate client-key certificate-authority; do
122+ count=$(grep -Ec "^[[:space:]]*${k}:[[:space:]]+" "%[1]s")
123+ [ "$count" -eq 1 ] || { echo "expected exactly one ${k} in %[1]s, got $count" >&2; exit 1; }
124+ done
125+ server=$(grep '^[[:space:]]*server:' "%[1]s" | head -1 | awk '{print $2}')
126+ cert=$(grep '^[[:space:]]*client-certificate:' "%[1]s" | head -1 | awk '{print $2}')
127+ key=$(grep '^[[:space:]]*client-key:' "%[1]s" | head -1 | awk '{print $2}')
128+ ca=$(grep '^[[:space:]]*certificate-authority:' "%[1]s" | head -1 | awk '{print $2}')
129+ for v in server cert key ca; do
130+ eval "val=\$$v"
131+ [ -n "$val" ] || { echo "${v} field extraction failed from %[1]s" >&2; exit 1; }
132+ done
133+ curl -Ssf --connect-timeout 10 --max-time 45 --cert "$cert" --key "$key" --cacert "$ca" "${server}/api?timeout=32s"` , kubeconfigPath )).Output ()
126134 framework .Logf ("%s" , out )
127135 if err != nil {
128136 return fmt .Errorf ("%s" , out )
0 commit comments