k8s.io/kubernetes@v1.29.3/test/e2e/framework/node/ssh.go (about) 1 /* 2 Copyright 2019 The Kubernetes Authors. 3 4 Licensed under the Apache License, Version 2.0 (the "License"); 5 you may not use this file except in compliance with the License. 6 You may obtain a copy of the License at 7 8 http://www.apache.org/licenses/LICENSE-2.0 9 10 Unless required by applicable law or agreed to in writing, software 11 distributed under the License is distributed on an "AS IS" BASIS, 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 See the License for the specific language governing permissions and 14 limitations under the License. 15 */ 16 17 package node 18 19 import ( 20 "context" 21 "time" 22 23 "k8s.io/apimachinery/pkg/util/wait" 24 "k8s.io/kubernetes/test/e2e/framework" 25 e2ekubectl "k8s.io/kubernetes/test/e2e/framework/kubectl" 26 ) 27 28 // WaitForSSHTunnels waits for establishing SSH tunnel to busybox pod. 29 func WaitForSSHTunnels(ctx context.Context, namespace string) { 30 framework.Logf("Waiting for SSH tunnels to establish") 31 e2ekubectl.RunKubectl(namespace, "run", "ssh-tunnel-test", 32 "--image=busybox", 33 "--restart=Never", 34 "--command", "--", 35 "echo", "Hello") 36 defer e2ekubectl.RunKubectl(namespace, "delete", "pod", "ssh-tunnel-test") 37 38 // allow up to a minute for new ssh tunnels to establish 39 wait.PollUntilContextTimeout(ctx, 5*time.Second, time.Minute, true, func(ctx context.Context) (bool, error) { 40 _, err := e2ekubectl.RunKubectl(namespace, "logs", "ssh-tunnel-test") 41 return err == nil, nil 42 }) 43 }