kubernetes: detect more 'pause' containers

Dockershim has added a label `io.kubernetes.docker.type` for at least
four years, where the pause container is of type `podsandbox`.  This
should be more reliable than trying to keep up with everyone's name
for the pause container.
This commit is contained in:
Bryan Boreham
2020-01-15 10:26:10 +00:00
parent 1f51495e59
commit 92b8a489e7
2 changed files with 8 additions and 0 deletions

View File

@@ -248,6 +248,10 @@ func (r *Reporter) podEvent(e Event, pod Pod) {
}
func isPauseContainer(n report.Node, rpt report.Report) bool {
k8sContainerType, _ := n.Latest.Lookup(report.DockerLabelPrefix + "io.kubernetes.docker.type")
if k8sContainerType == "podsandbox" { // this label is added by dockershim
return true
}
containerImageIDs, ok := n.Parents.Lookup(report.ContainerImage)
if !ok {
return false

View File

@@ -245,6 +245,10 @@ func IsApplication(n report.Node) bool {
if _, ok := systemImagePrefixes[imagePrefix]; ok || report.IsPauseImageName(imagePrefix) {
return false
}
k8sContainerType, _ := n.Latest.Lookup(report.DockerLabelPrefix + "io.kubernetes.docker.type")
if k8sContainerType == "podsandbox" { // another way to detect "pause container"
return false
}
roleLabel, _ := n.Latest.Lookup(report.DockerLabelPrefix + "works.weave.role")
if roleLabel == "system" {
return false