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

Update docs v1.5.2 #268

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion docs/css/extra.css
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,12 @@
font-weight: bold;
opacity: 1;
color: white;
}
}

.md-typeset__table {
min-width: 100%;
}

.md-typeset table:not([class]) {
display: table;
}
2 changes: 1 addition & 1 deletion docs/dev-guide/testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ The repository includes a suite of system tests that will do the following:
- run KubeHound using the file collector to create a working graph database
- query the graph database to ensure all expected vertices and edges have been created correctly

The cluster setup and running instances can be found under [test/setup](./test/setup/)
The cluster setup and running instances can be found under [test/setup](https://github.com/DataDog/KubeHound/tree/main/test/setup)

If you need to manually access the system test environment with kubectl and other commands, you'll need to set (assuming you are at the root dir):

Expand Down
51 changes: 51 additions & 0 deletions docs/khaas/advanced-configuration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Advanced configuration

This section covering all the flags available to use KubeHound. If you don't want to specify the bucket every time, you can set it up in your local config file (`./kubehound.yaml` or `$HOME/.config/kubehound.yaml`). See [getting started with KHaaS](./getting-started.md)
Minosity-VR marked this conversation as resolved.
Show resolved Hide resolved

## Manual collection

In order to use `kubehound` with KHaaS, you need to specify the api endpoint you want to use:

- `--khaas-server` from the inline flags (by default `127.0.0.1:9000`)

Since this is not likely to change in your environment, we advise you to use the local config file. By default KubeHound will look for `./kubehound.yaml` or `$HOME/.config/kubehound.yaml`. As example here we set the default endpoint with disabled SSL.
Minosity-VR marked this conversation as resolved.
Show resolved Hide resolved

## Dump and ingest

In order to use the collector with KHaaS you need to specify the cloud location you want to dump the k8s resources:
jt-dd marked this conversation as resolved.
Show resolved Hide resolved

- `--bucket_url` from the inline flags (i.e. `s3://<your_bucket>`). There is no default value for security reason.
- `--region` from the inline flags (i.e. `us-east-1`) to set the region to retrieve the configuration (only for s3).

!!! warning

The `kubehound` binary needs to have push access to your cloud storage provider.

To dump and ingest the current k8s cluster, you just need to run the following command (i.e. using an AWS config):

```bash
kubehound dump remote --khaas-server 127.0.0.1:9000 --insecure --bucket_url s3://<your_bucket> --region us-east-1
```

The last command will:

- **dump the k8s resources** to the cloud storage provider.
- send a grpc call to **run the ingestion on the KHaaS** grpc endpoint.

!!! note

The ingestion will dump the current cluster being setup, if you want to skip the interactive mode, just specify `-y` or `--non-interactive`

### Manual ingestion

If you want to rehydrate (reingesting all the latest clusters dumps), you can use the `ingest` command to run it.

```bash
kubehound ingest remote --khaas-server 127.0.0.1:9000 --insecure
```

You can also specify a specific dump by using the `--cluster` and `run_id` flags.

```bash
kubehound ingest remote --khaas-server 127.0.0.1:9000 --insecure --cluster my-cluster-1 --run_id 01htdgjj34mcmrrksw4bjy2e94
```
71 changes: 71 additions & 0 deletions docs/khaas/deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Deploying KHaaS - Ingestor stack

!!! warning "deprecated"

The `kubehound-ingestor` has been deprecated since **v1.5.0** and renamed to `kubehound-binary`.

## Docker deployment

To run the KubeHound as a Service with `docker` just use the following [compose files](https://github.com/DataDog/KubeHound/tree/main/deployments/kubehound):

```bash
cd ./deployments/kubehound
docker compose -f docker-compose.yaml -f docker-compose.release.yaml -f docker-compose.release.ingestor.yaml up -d
```

By default the endpoints are only exposed locally:

- `127.0.0.1:9000` for ingestor endpoint.
- `127.0.0.1:8888` for the UI.

!!! warning

You should change the default password by editing `NOTEBOOK_PASSWORD=<your_password>` in the `docker-compose.yaml`

## k8s deployment

To run the KubeHound as a Service on Kubernetes just use the following [helm files](https://github.com/DataDog/KubeHound/tree/main/deployments/k8s):

```bash
cd ./deployments/k8s
helm install khaas khaas --namespace khaas --create-namespace
```

If it succeeded you should see the deployment listed:

```bash
$ helm ls -A
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION
khaas khaas 1 2024-07-30 19:04:37.0575 +0200 CEST deployed kubehound-0.0.1
```

!!! Note

This is an example to deploy KubeHound as a Service in k8s cluster, but you will need to adapt it to your own environment.

## k8s collector

When deploying the collector inside a k8s cluster, we need to configure one of the two variable:

- `KH_K8S_CLUSTER_NAME_ENV_PTR`: variable indicating env var to use from the k8s cluster/pod to setup the name of the targetted k8s cluster
Minosity-VR marked this conversation as resolved.
Show resolved Hide resolved
- `KH_K8S_CLUSTER_NAME`: variable indicating the name of the targetted k8s cluster

!!! Note

`KH_K8S_CLUSTER_NAME_ENV_PTR` will overwrite the `KH_K8S_CLUSTER_NAME` env var.

### RBAC requirements

In order for the collector to work it needs access to the k8s API and the following k8s ClusterRole:

| apiGroups | resources | verb |
| ------------------------- | ------------------------------------------------------------ | ----------- |
| rbac.authorization.k8s.io | roles<br>rolebindings<br>clusterroles<br>clusterrolebindings | get<br>list |
| | pods<br>nodes<br> | get<br>list |
| discovery.k8s.io | endpointslices | get<br>list |

The definition of the k8s RBAC can find here:

- [clusterRole](https://github.com/DataDog/KubeHound/tree/main/deployments/k8s/khaas/templates/cluster_role.yaml)
- [clusterRoleBinding](https://github.com/DataDog/KubeHound/tree/main/deployments/k8s/khaas/templates/cluster_role_binding.yaml)
- [serviceAccount](https://github.com/DataDog/KubeHound/tree/main/deployments/k8s/khaas/templates/service_account.yaml)
57 changes: 57 additions & 0 deletions docs/khaas/getting-started.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# KubeHound as a Service (KHaaS)

KHaaS enables you to use KubeHound in a distributive way. It is being splitted in 2 main categories:
jt-dd marked this conversation as resolved.
Show resolved Hide resolved

- The ingestor stack which includes the `graphdb`, `storedb`, `UI` and `grpc endpoint`.
- The collector (the kubehound binary) which will dump and send the k8s resources to the KHaaS `grpc endpoint`.

[![](../images/khaas-architecture.png)](../images/khaas-architecture.png)

!!! note

You need to deploy the data storage you want to use ([AWS s3 in our example](https://github.com/DataDog/KubeHound/tree/main/deployments/terraform)).

## Automatic collection

KHaaS has been created to deployed inside a kubernetes cluster. This way you can set through Kubernetes `CronJob` daily dumps of your infrastucture. To configure and deploy it, please refer to the [deployment](deployment.md) section.
jt-dd marked this conversation as resolved.
Show resolved Hide resolved

## Manual collection

In order to use `kubehound` with KHaaS, you need to specify the api endpoint you want to use. Since this is not likely to change in your environment, we advise you to use the local config file. By default KubeHound will look for `./kubehound.yaml` or `$HOME/.config/kubehound.yaml`. As example here we set the default endpoint with disabled SSL.
jt-dd marked this conversation as resolved.
Show resolved Hide resolved

```yaml
ingestor:
blob:
bucket_url: "" # (i.e.: s3://your-bucket)
region: "us-east-1" # (i.e.: us-east-1)
api:
endpoint: "127.0.0.1:9000"
insecure: true
```
Minosity-VR marked this conversation as resolved.
Show resolved Hide resolved

!!! note

You can use [kubehound-reference.yaml](https://github.com/DataDog/KubeHound/blob/main/configs/etc/kubehound-reference.yaml) as an example which list every options.

Once everything is configured you just run the following, it will:

- **dump the k8s resources** and push it compressed to the cloud storage provider.
- send a grpc call to **run the ingestion on the KHaaS** grpc endpoint.

```bash
kubehound dump remote
```

## Manual ingestion

If you want to rehydrate (reingesting all the latest clusters dumps), you can use the `ingest` command to run it.

```bash
kubehound ingest remote
```

You can also specify a specific dump by using the `--cluster` and `run_id` flags.

```bash
kubehound ingest remote --cluster my-cluster-1 --run_id 01htdgjj34mcmrrksw4bjy2e94
```
Minosity-VR marked this conversation as resolved.
Show resolved Hide resolved
53 changes: 28 additions & 25 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ theme:
logo: ./logo.png
favicon: ./logo.png
palette:
- scheme: default
primary: light blue
toggle:
icon: material/toggle-switch-off-outline
name: Switch to dark mode
- scheme: slate
primary: light blue
toggle:
icon: material/toggle-switch
name: Switch to light mode
- scheme: default
primary: light blue
toggle:
icon: material/toggle-switch-off-outline
name: Switch to dark mode
- scheme: slate
primary: light blue
toggle:
icon: material/toggle-switch
name: Switch to light mode
features:
- navigation.expand
- navigation.indexes
Expand All @@ -30,19 +30,19 @@ theme:
- navigation.tabs.sticky
- content.code.copy
icon:
admonition:
note: octicons/tag-16
abstract: octicons/checklist-16
info: octicons/info-16
tip: octicons/squirrel-16
success: octicons/check-16
question: octicons/question-16
warning: octicons/alert-16
failure: octicons/x-circle-16
danger: octicons/zap-16
bug: octicons/bug-16
example: octicons/beaker-16
quote: octicons/quote-16
admonition:
note: octicons/tag-16
abstract: octicons/checklist-16
info: octicons/info-16
tip: octicons/squirrel-16
success: octicons/check-16
question: octicons/question-16
warning: octicons/alert-16
failure: octicons/x-circle-16
danger: octicons/zap-16
bug: octicons/bug-16
example: octicons/beaker-16
quote: octicons/quote-16
use_directory_urls: true
extra_javascript:
- path: js/tablesort.js #TODO not working
Expand All @@ -67,7 +67,7 @@ markdown_extensions:
- footnotes
- markdown_captions
- pymdownx.tabbed:
alternate_style: true
alternate_style: true
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
Expand All @@ -85,8 +85,11 @@ nav:
- Getting Started: user-guide/getting-started.md
- Advanced config: user-guide/advanced-configuration.md
- Local Common Operations: user-guide/common-operations.md
- KubeHound as a Service: user-guide/khaas-101.md
- Troubleshooting: user-guide/troubleshooting.md
- KubeHound as a Serivce:
- Getting Started: khaas/getting-started.md
- Advanced config: khaas/advanced-configuration.md
- Deployment: khaas/deployment.md
- Developer Guide:
- Getting Started: dev-guide/getting-started.md
- Testing: dev-guide/testing.md
Expand Down
Loading