Revert "Revert "Merge pull request #2285 from weaveworks/mike/k8s-ns-in-container-view""

This reverts commit d55c528fe2.
This commit is contained in:
Mike Lang
2017-03-20 10:05:10 -07:00
parent 923dfd385f
commit da8b8d5095
2 changed files with 28 additions and 11 deletions
+13 -2
View File
@@ -10,6 +10,10 @@ import (
"github.com/weaveworks/scope/report"
)
const (
k8sNamespaceLabel = "io.kubernetes.pod.namespace"
)
// PreciousNodeRenderer ensures a node is never filtered out by decorators
type PreciousNodeRenderer struct {
PreciousNodeID string
@@ -281,7 +285,7 @@ func IsApplication(n report.Node) bool {
if roleLabel == "system" {
return false
}
namespace, _ := n.Latest.Lookup(docker.LabelPrefix + "io.kubernetes.pod.namespace")
namespace, _ := n.Latest.Lookup(docker.LabelPrefix + k8sNamespaceLabel)
if namespace == "kube-system" {
return false
}
@@ -320,7 +324,14 @@ func IsNotPseudo(n report.Node) bool {
// IsNamespace checks if the node is a pod/service in the specified namespace
func IsNamespace(namespace string) FilterFunc {
return func(n report.Node) bool {
gotNamespace, _ := n.Latest.Lookup(kubernetes.Namespace)
tryKeys := []string{kubernetes.Namespace, docker.LabelPrefix + k8sNamespaceLabel}
gotNamespace := ""
for _, key := range tryKeys {
if value, ok := n.Latest.Lookup(key); ok {
gotNamespace = value
break
}
}
return namespace == gotNamespace
}
}