generated from cloudoperators/repository-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(scanner): Change logic of creating entities (#309)
* First commit * Wip * Revert f04feab * Wip * Wip * Wip * Wip * Wip * Wip * Change naming * Add concurrency * Add READMEs * Automatic application of license header * Fix #309 (comment) * Fix #discussion_r1808503568 * Fix #309 (comment) * Fix #309 (comment) * Automatic application of license header * Fix #309 (comment) * Refactoring * Update dependencies * Fix logic for ExtractImageInfo * Add unit tests for ExtractImageInfo * Automatic application of license header * Clean-up --------- Co-authored-by: License Bot <[email protected]> Co-authored-by: Michael Reimsbach <[email protected]>
- Loading branch information
1 parent
f423cf9
commit d26a8fb
Showing
19 changed files
with
959 additions
and
219 deletions.
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.