Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for un-orchestrated containerd containers #1813

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

itsCheithanya
Copy link
Contributor

@itsCheithanya itsCheithanya commented Jul 22, 2024

Purpose of PR?:
When it comes to unorchestrated or non-kubernetes containers, right now KubeArmor works the best only with Docker runtime but not for containerd runtime,this PR fixes the issue related to monitoring and enforcement of containerd containers

Fixes #1426

Does this PR introduce a breaking change?
No

Apply this policy to a contianerd container

apiVersion: security.kubearmor.com/v1
kind: KubeArmorPolicy
metadata:
  name: ksp-block-policy
spec:
  severity: 3
  selector:
    matchLabels:
      kubearmor.io/container.name: nerdctl-nginx-jul-21
  process:
    matchPaths:
    - path: /usr/bin/ls
    - path: /usr/bin/sleep
    - path: /usr/bin/curl
  action:
    Block

It blocks showing enforcement
image

Checklist:

  • Bug fix. Fixes Un-orchestrated KubeArmor: No telemetry when using containerd as a runtime #1426
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • PR Title follows the convention of <type>(<scope>): <subject>
  • Commit has unit tests
  • Commit has integration tests

@Prateeknandle
Copy link
Collaborator

Prateeknandle commented Jul 24, 2024

Thanks for the PR @itsCheithanya
can you please attach an ss for alerts and telemetry data, have you fixed that as well?

@itsCheithanya
Copy link
Contributor Author

itsCheithanya commented Jul 24, 2024

Thanks for the PR @itsCheithanya can you please attach an ss for alerts and telemetry data, have you fixed that as well?

image
image
Sure @Prateeknandle

Copy link
Member

@daemon1024 daemon1024 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To be verified before review:

What happens when the same container name exists in 2 namespaces. How will the policy enforcement work.

@itsCheithanya
Copy link
Contributor Author

itsCheithanya commented Aug 13, 2024

To be verified before review:

What happens when the same container name exists in 2 namespaces. How will the policy enforcement work.

enforcement works for both as well,Is it the expected bheaviour?
image
image

@@ -110,7 +114,27 @@ func NewContainerdHandler() *ContainerdHandler {
ch.docker = namespaces.WithNamespace(context.Background(), "moby")

// containerd namespace
ch.containerd = namespaces.WithNamespace(context.Background(), "k8s.io")
client, err := containerd.New(socketPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the namespaces API client over the existing gRPC connection instead of creating a full-fledged client? We do the same for Containers and Tasks.
Ref - https://pkg.go.dev/github.com/containerd/containerd/[email protected]/services/namespaces/v1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay sure will do that

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have made the changes @DelusionalOptimist

@PrimalPimmy
Copy link
Member

PrimalPimmy commented Sep 9, 2024

It seems alerts telemetry is not working for containers via karmor logs 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Un-orchestrated KubeArmor: No telemetry when using containerd as a runtime
5 participants