代码拉取完成,页面将自动刷新
package dockermonitor
import (
"git.cloud.top/DSec/trireme-lib/common"
"git.cloud.top/DSec/trireme-lib/monitor/constants"
"git.cloud.top/DSec/trireme-lib/policy"
"go.uber.org/zap"
)
// getPausePUID returns puid of pause container.
func getPausePUID(extensions policy.ExtendedMap) string {
if extensions == nil {
return ""
}
if puid, ok := extensions.Get(constants.DockerHostPUID); ok {
zap.L().Debug("puid of pause container is", zap.String("puid", puid))
return puid
}
return ""
}
// PolicyExtensions retrieves policy extensions
func policyExtensions(runtime policy.RuntimeReader) (extensions policy.ExtendedMap) {
if runtime == nil {
return nil
}
if runtime.Options().PolicyExtensions == nil {
return nil
}
if extensions, ok := runtime.Options().PolicyExtensions.(policy.ExtendedMap); ok {
return extensions
}
return nil
}
// IsHostNetworkContainer returns true if container has hostnetwork set
// to true or is linked to container with hostnetwork set to true.
func isHostNetworkContainer(runtime policy.RuntimeReader) bool {
return runtime.PUType() == common.LinuxProcessPU || (getPausePUID(policyExtensions(runtime)) != "")
}
// IsKubernetesContainer checks if the container is in K8s.
func isKubernetesContainer(labels map[string]string) bool {
if _, ok := labels[constants.K8sPodNamespace]; ok {
return true
}
return false
}
// KubePodIdentifier returns identifier for K8s pod.
func kubePodIdentifier(labels map[string]string) string {
if !isKubernetesContainer(labels) {
return ""
}
podName := ""
podNamespace := ""
podNamespace, ok := labels[constants.K8sPodNamespace]
if !ok {
podNamespace = ""
}
podName, ok = labels[constants.K8sPodName]
if !ok {
podName = ""
}
if podName == "" || podNamespace == "" {
zap.L().Warn("K8s pod does not have podname/podnamespace labels")
return ""
}
return podNamespace + "/" + podName
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。