Skip to content

Commit

Permalink
Merge branch 'master' into dynamic-label-selector
Browse files Browse the repository at this point in the history
  • Loading branch information
seeker89 authored Dec 20, 2018
2 parents 6f0dab4 + 0060f82 commit 083b4ef
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name ?= goldpinger
version ?= 1.0.3
version ?= 1.1.0
bin ?= goldpinger
pkg ?= "github.com/bloomberg/goldpinger"
tag = $(name):$(version)
Expand Down
15 changes: 12 additions & 3 deletions pkg/goldpinger/k8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,24 @@ package goldpinger

import (
"log"

"io/ioutil"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

func getNamespace() string {
b, err := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
if err != nil {
log.Println("Unable to determine namespace: ", err.Error())
return ""
}
namespace := string(b)
return namespace
}

// GetAllPods returns a map of Pod IP to Host IP based on a label selector defined in config
func GetAllPods() map[string]string {

timer := GetLabeledKubernetesCallsTimer()
pods, err := GoldpingerConfig.KubernetesClient.CoreV1().Pods("").List(metav1.ListOptions{LabelSelector: GoldpingerConfig.LabelSelector})
pods, err := GoldpingerConfig.KubernetesClient.CoreV1().Pods(namespace).List(metav1.ListOptions{LabelSelector: GoldpingerConfig.LabelSelector})
if err != nil {
log.Println("Error getting pods for selector: ", err.Error())
CountError("kubernetes_api")
Expand Down

0 comments on commit 083b4ef

Please sign in to comment.