...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package podchaos
17
18 import (
19 "context"
20 "time"
21
22 corev1 "k8s.io/api/core/v1"
23 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
24 "k8s.io/apimachinery/pkg/util/wait"
25 "k8s.io/client-go/kubernetes"
26 )
27
28 func waitPodRunning(name, namespace string, cli kubernetes.Interface) error {
29 return wait.Poll(5*time.Second, 5*time.Minute, func() (done bool, err error) {
30 pod, err := cli.CoreV1().Pods(namespace).Get(context.TODO(), name, metav1.GetOptions{})
31 if err != nil {
32 return false, nil
33 }
34 if pod.Status.Phase != corev1.PodRunning {
35 return false, nil
36 }
37 return true, nil
38 })
39 }
40