I am creating a pod in k8 client go and making a watch to get notified for when the pod has completed so that i can read the logs of the pod. The watch interface doesnt seem to provide any events on the channel. Here is the code, how would I get notified that the pod status is now completed and is ready to read the logs
func readLogs(clientset *kubernetes.Clientset) {
// namespace := "default"
// label := "cithu"
var (
pod *v1.Pod
// watchface watch.Interface
err error
)
// returns a pod after creation
pod, err = createPod(clientset)
fmt.Println(pod.Name, pod.Status, err)
if watchface, err = clientset.CoreV1().Pods(namespace).Watch(metav1.ListOptions{
LabelSelector: pod.Name,
}); err != nil {
log.Fatalf(err.Error())
}
// How do I get notified when the pod.Status == completed
}
fmt.Println(p.Status.Phase)
does not showCOMPLETED
status when all containers stop in a pod likekubectl get pods -w
does. – Coach