Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/goldpinger/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ var GoldpingerConfig = struct {
DisplayNodeName bool `long:"display-nodename" description:"Display nodename other than podname in UI (defaults is podname)." env:"DISPLAY_NODENAME"`
KubernetesClient *kubernetes.Clientset

UseReadiness bool `long:"use-readiness" description:"Use readiness probes to determine if a pod is ready (defaults to false which relies just on running)." env:"USE_READINESS"`

DnsHosts []string `long:"host-to-resolve" description:"A host to attempt dns resolve on (space delimited)" env:"HOSTS_TO_RESOLVE" env-delim:" "`
TCPTargets []string `long:"tcp-targets" description:"A list of external targets(<host>:<port> or <ip>:<port>) to attempt a TCP check on (space delimited)" env:"TCP_TARGETS" env-delim:" "`
HTTPTargets []string `long:"http-targets" description:"A list of external targets(<http or https>://<url>) to attempt an HTTP{S} check on. A 200 HTTP code is considered successful.(space delimited)" env:"HTTP_TARGETS" env-delim:" "`
Expand Down
17 changes: 17 additions & 0 deletions pkg/goldpinger/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,17 @@ func getPodNodeName(p v1.Pod) string {
return p.Name
}

// isReady is equivalent to k8s.io/kubectl/pkg/util/podutils.IsPodReady" but that brings us up a go version
// if we don't mind those dependencies could replace.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

going to latest dependencies brough it go 1.24 in go mod assume you'd want that as seperate change.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seperate pr created.

func isReady(pod *v1.Pod) bool {
for _, cond := range pod.Status.Conditions {
if cond.Type == v1.PodReady && cond.Status == v1.ConditionTrue {
return true
}
}
return false
}

// GetAllPods returns a mapping from a pod name to a pointer to a GoldpingerPod(s)
func GetAllPods() map[string]*GoldpingerPod {
timer := GetLabeledKubernetesCallsTimer()
Expand All @@ -122,6 +133,12 @@ func GetAllPods() map[string]*GoldpingerPod {

podMap := make(map[string]*GoldpingerPod)
for _, pod := range pods.Items {
if GoldpingerConfig.UseReadiness {
if !isReady(&pod) {
continue
}
}

podMap[pod.Name] = &GoldpingerPod{
Name: getPodNodeName(pod),
PodIP: getPodIP(pod),
Expand Down