https://github.com/blackducksoftware/cerebros
https://github.com/blackducksoftware/cerebros
docker golang kubernetes python security security-tools
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/blackducksoftware/cerebros
- Owner: blackducksoftware
- License: mit
- Created: 2020-01-24T13:48:00.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-25T01:46:37.000Z (over 3 years ago)
- Last Synced: 2025-08-15T07:43:43.133Z (11 months ago)
- Topics: docker, golang, kubernetes, python, security, security-tools
- Language: Go
- Size: 2.95 MB
- Stars: 0
- Watchers: 4
- Forks: 0
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# cerebros
## Go
```
cd go
```
### Project structure
`cmd/`: various executables, these shouldn't contain much code -- they're basically just entrypoints. Each directory should have a `.go` file as the entrypoint, a `conf.json` as an example configuration file, and a `Dockerfile` to build an image.
`pkg/`: where the vast majority of the code is! Functions, classes, etc. goes here.
`hack/deploy*`: scripts for deploying groups of containers on Kubernetes, including:
- Blackduck image scanning
- Polaris scanning
- Polaris load generation, data seeding, scans, and prometheus metrics
`Makefile`: helps you build and test everything.
### Build an image
```
make polaris-cli
```
### Test
```
make vet
make test
```
### Format
```
make fmt
```
### Metrics
Add prometheus metrics to everything! It's very easy, check out [these metrics](https://github.com/blackducksoftware/cerebros/blob/master/go/pkg/kube/metrics.go) for an example:
- figure out how to model your metrics -- do you want gauges, counters, or histograms?
- instantiate your metrics objects *paying attention to labels* -- labels provided at instantiation have to match labels used at collection, otherwise prometheus will get upset
- [write a unit test to verify that the metrics instantiate and can be used successfully](https://github.com/blackducksoftware/cerebros/blob/master/go/pkg/kube/metrics_test.go)
- set up an http server and serve the prometheus metrics -- this allows the prometheus master to scrape your metrics
```
// Prometheus and http setup
prometheus.Unregister(prometheus.NewProcessCollector(prometheus.ProcessCollectorOpts{}))
prometheus.Unregister(prometheus.NewGoCollector())
http.Handle("/metrics", promhttp.Handler())
addr := fmt.Sprintf(":%d", config.Port)
go func() {
log.Infof("starting HTTP server on port %d", config.Port)
http.ListenAndServe(addr, nil)
}()
```
To collect metrics from your running container, you'll need to:
- [run a prometheus master](https://github.com/blackducksoftware/cerebros/blob/474307bf0a2108a060cca93ed34a5a44288155aa/go/hack/deploy-polaris-load-generator/deploy.sh#L8)
- [add metadata annotations to your pods](https://github.com/blackducksoftware/cerebros/blob/474307bf0a2108a060cca93ed34a5a44288155aa/go/hack/deploy-polaris-load-generator/polaris-cli.yaml#L16-L19)
## Python
TODO