Skip to content

Commit

Permalink
Merge pull request kubearmor#1427 from daemon1024/fix-cri
Browse files Browse the repository at this point in the history
  • Loading branch information
DelusionalOptimist authored Sep 21, 2023
2 parents 72c6000 + f49f405 commit f770184
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 13 deletions.
6 changes: 3 additions & 3 deletions KubeArmor/core/kubeArmor.go
Original file line number Diff line number Diff line change
Expand Up @@ -512,15 +512,15 @@ func KubeArmor() {
}

// monitor containers
if strings.Contains(dm.Node.ContainerRuntimeVersion, "docker") {
if strings.Contains(dm.Node.ContainerRuntimeVersion, "docker") || strings.Contains(cfg.GlobalCfg.CRISocket, "docker") {
// update already deployed containers
dm.GetAlreadyDeployedDockerContainers()
// monitor docker events
go dm.MonitorDockerEvents()
} else if strings.Contains(dm.Node.ContainerRuntimeVersion, "containerd") {
} else if strings.Contains(dm.Node.ContainerRuntimeVersion, "containerd") || strings.Contains(cfg.GlobalCfg.CRISocket, "containerd") {
// monitor containerd events
go dm.MonitorContainerdEvents()
} else if strings.Contains(dm.Node.ContainerRuntimeVersion, "cri-o") {
} else if strings.Contains(dm.Node.ContainerRuntimeVersion, "cri-o") || strings.Contains(cfg.GlobalCfg.CRISocket, "cri-o") {
// monitor crio events
go dm.MonitorCrioEvents()
} else {
Expand Down
13 changes: 3 additions & 10 deletions KubeArmor/core/kubeUpdate.go
Original file line number Diff line number Diff line change
Expand Up @@ -583,16 +583,9 @@ func (dm *KubeArmorDaemon) WatchK8sPods() {
pod.ContainerImages = map[string]string{}
for _, container := range event.Object.Status.ContainerStatuses {
if len(container.ContainerID) > 0 {
if strings.HasPrefix(container.ContainerID, "docker://") {
containerID := strings.TrimPrefix(container.ContainerID, "docker://")
pod.Containers[containerID] = container.Name
pod.ContainerImages[containerID] = container.Image + kl.GetSHA256ofImage(container.ImageID)
} else if strings.HasPrefix(container.ContainerID, "containerd://") {
containerID := strings.TrimPrefix(container.ContainerID, "containerd://")
pod.Containers[containerID] = container.Name
pod.ContainerImages[containerID] = container.Image + kl.GetSHA256ofImage(container.ImageID)
} else if strings.HasPrefix(container.ContainerID, "cri-o://") {
containerID := strings.TrimPrefix(container.ContainerID, "cri-o://")
cid := strings.Split(container.ContainerID, "://")
if len(cid) == 2 { // always true because k8s spec defines format as '<type>://<container_id>'
containerID := cid[1]
pod.Containers[containerID] = container.Name
pod.ContainerImages[containerID] = container.Image + kl.GetSHA256ofImage(container.ImageID)
}
Expand Down

0 comments on commit f770184

Please sign in to comment.