generated from cloudoperators/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat(scanner): Change logic of creating entities #309
Merged
drochow
merged 26 commits into
main
from
dorneanu/issue-278/Change-logic-of-entity-creation
Oct 22, 2024
Merged
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
74e8088
First commit
dorneanu 29fbaab
Wip
dorneanu 8e13dbd
Revert https://github.com/cloudoperators/heureka/commit/f04feabc6b815β¦
dorneanu 871ef0f
Wip
dorneanu e2f50e6
Wip
dorneanu 24a73a6
Wip
dorneanu 950c8ee
Wip
dorneanu 993f5be
Wip
dorneanu 9ebdc0a
Wip
dorneanu d776667
Change naming
dorneanu e51ead7
Add concurrency
dorneanu adc9d36
Add READMEs
dorneanu 1b402b9
Automatic application of license header
b12bf4b
Fix https://github.com/cloudoperators/heureka/pull/309#discussion_r18β¦
dorneanu 369fa18
Fix #discussion_r1808503568
dorneanu e1525f8
Fix https://github.com/cloudoperators/heureka/pull/309#discussion_r18β¦
dorneanu 3c9503f
Fix https://github.com/cloudoperators/heureka/pull/309#discussion_r18β¦
dorneanu d665ad1
Automatic application of license header
33b65ed
Fix https://github.com/cloudoperators/heureka/pull/309#discussion_r18β¦
dorneanu bc5b719
Refactoring
dorneanu c5e5669
Update dependencies
dorneanu 5e87931
Fix logic for ExtractImageInfo
dorneanu cd9f8a0
Add unit tests for ExtractImageInfo
dorneanu 57c8839
Automatic application of license header
d0da03b
Merge branch 'main' into dorneanu/issue-278/Change-logic-of-entity-crβ¦
MR2011 0e669ba
Clean-up
dorneanu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Kubernetes Assets Scanner | ||
|
||
The Kubernetes Assets Scanner is a tool designed to scan and collect information about services, pods, and containers running in a Kubernetes cluster. It processes the collected data and reports findings to a GraphQL API (presumably Heureka). | ||
|
||
## Prerequisites | ||
|
||
- Go 1.15 or later | ||
- Access to a Kubernetes cluster | ||
- Heureka system for reporting findings | ||
|
||
## Installation | ||
|
||
1. Clone the repository: | ||
``` | ||
git clone https://github.com/cloudoperators/heureka.git | ||
cd scanners/k8s-assets | ||
``` | ||
|
||
2. Install dependencies: | ||
``` | ||
go mod tidy | ||
``` | ||
|
||
## Configuration | ||
|
||
The scanner is configured using environment variables. Set the following variables before running the scanner: | ||
|
||
- `HEUREKA_LOG_LEVEL`: Set the log level (default: "debug") | ||
- `HEUREKA_KUBE_CONFIG_PATH`: Path to kubeconfig file (default: "~/.kube/config") | ||
- `HEUREKA_KUBE_CONFIG_CONTEXT`: Kubernetes context to use | ||
- `HEUREKA_KUBE_CONFIG_TYPE`: Type of Kubernetes config (default: "oidc") | ||
- `HEUREKA_SUPPORT_GROUP_LABEL`: Label for support group (default: "ccloud/support-group") | ||
- `HEUREKA_SERVICE_NAME_LABEL`: Label for service name (default: "ccloud/service") | ||
- `HEUREKA_SCANNER_TIMEOUT`: Timeout for the scanner (default: "30m") | ||
- `HEUREKA_HEUREKA_URL`: URL of the Heureka system for reporting findings | ||
- `HEUREKA_CLUSTER_NAME`: Name of the cluster being scanned | ||
- `HEUREKA_CLUSTER_REGION`: Region of the cluster being scanned | ||
|
||
Example: | ||
|
||
```bash | ||
export HEUREKA_LOG_LEVEL=debug | ||
export HEUREKA_KUBE_CONFIG_PATH=~/.kube/config | ||
export HEUREKA_KUBE_CONFIG_CONTEXT=my-cluster-context | ||
export HEUREKA_KUBE_CONFIG_TYPE=oidc | ||
export HEUREKA_SUPPORT_GROUP_LABEL=ccloud/support-group | ||
export HEUREKA_SERVICE_NAME_LABEL=ccloud/service | ||
export HEUREKA_SCANNER_TIMEOUT=30m | ||
export HEUREKA_HEUREKA_URL=https://heureka.example.com | ||
export HEUREKA_CLUSTER_NAME=my-cluster | ||
export HEUREKA_CLUSTER_REGION=us-west-1 | ||
``` | ||
|
||
## Usage | ||
|
||
To run the Kubernetes Assets Scanner: | ||
|
||
```bash | ||
go run main.go | ||
``` | ||
|
||
The scanner will start processing namespaces, services, pods, and containers, and report findings to the configured Heureka system. |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
mutation CreateComponent($input: ComponentInput!) { | ||
# @genqlient(typename: "Component") | ||
createComponent ( | ||
input: $input | ||
) { | ||
id | ||
name | ||
type | ||
} | ||
} |
5 changes: 3 additions & 2 deletions
5
scanner/k8s-assets/client/query/componentversion_create.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
# SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and Greenhouse contributors | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
mutation CreateComponentVersion ($input: ComponentVersionInput!) { | ||
mutation CreateComponentVersion($input: ComponentVersionInput!) { | ||
# @genqlient(typename: "ComponentVersion") | ||
createComponentVersion ( | ||
input: $input | ||
) { | ||
id | ||
version | ||
componentId | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we expecting certain labels on the Kubernetes pods?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We do but its configurable no?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? "expecting certain labels" should also be part of the README?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, this is referring back to the fact that we build support groups from certain labels / annotations on the kubernetes resources