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

enhance: container discovery via labels #2959

Merged

Conversation

LaurenceJJones
Copy link
Contributor

@LaurenceJJones LaurenceJJones commented Apr 23, 2024

Fix #2957

Implement container auto discovery via labels set on the container

How to setup:

Add acquisition example:

##/etc/crowdsec/acquis.d/docker.yaml
source: docker
use_container_labels: true

Then you can launch containers using the following labels:

docker run -d -p 80:80 -l crowdsec.enable=true -l crowdsec.labels.type=nginx nginx:alpine

Under the hood it will check if crowdsec.enable=true is set before trying to parse the labels. If no labels are provided it errors as we need to type variables for the parsers.

Copy link

@LaurenceJJones: There are no 'kind' label on this PR. You need a 'kind' label to generate the release automatically.

  • /kind feature
  • /kind enhancement
  • /kind refactoring
  • /kind fix
  • /kind chore
  • /kind dependencies
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

Copy link

@LaurenceJJones: There are no area labels on this PR. You can add as many areas as you see fit.

  • /area agent
  • /area local-api
  • /area cscli
  • /area appsec
  • /area security
  • /area configuration
Details

I am a bot created to help the crowdsecurity developers manage community feedback and contributions. You can check out my manifest file to understand my behavior and what I can do. If you want to use this for your project, you can check out the BirthdayResearch/oss-governance-bot repository.

@LaurenceJJones
Copy link
Contributor Author

/kind enhancement
/area agent

@codecov-commenter
Copy link

codecov-commenter commented Apr 23, 2024

Codecov Report

Attention: Patch coverage is 43.52941% with 48 lines in your changes are missing coverage. Please review.

Project coverage is 38.80%. Comparing base (defa076) to head (f81af59).
Report is 23 commits behind head on master.

Files Patch % Lines
pkg/acquisition/modules/docker/docker.go 14.28% 46 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           master    #2959       +/-   ##
===========================================
+ Coverage   27.54%   38.80%   +11.26%     
===========================================
  Files         398      402        +4     
  Lines       57917    58322      +405     
===========================================
+ Hits        15953    22634     +6681     
+ Misses      40025    33195     -6830     
- Partials     1939     2493      +554     
Flag Coverage Δ
bats 30.15% <0.00%> (?)
unit-linux 34.84% <42.02%> (-0.23%) ⬇️
unit-windows 25.58% <43.52%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@LaurenceJJones
Copy link
Contributor Author

Updated config option to be use_container_labels since we already do auto discovery this is more explicit of what the option does

@LaurenceJJones LaurenceJJones changed the title wip: docker discovery enhance: container discovery via labels Apr 23, 2024
@LaurenceJJones
Copy link
Contributor Author

Linked to #1435

@LaurenceJJones LaurenceJJones added this to the 1.6.2 milestone Apr 23, 2024
pkg/acquisition/modules/docker/docker.go Outdated Show resolved Hide resolved
pkg/acquisition/modules/docker/docker.go Outdated Show resolved Hide resolved
pkg/acquisition/modules/docker/docker.go Outdated Show resolved Hide resolved
@LaurenceJJones LaurenceJJones merged commit 9088f31 into crowdsecurity:master May 24, 2024
15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/agent kind/enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[docker] auto-discovery
3 participants