Skip to content

Commit

Permalink
feat: tutorial for custom analysis
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Jones <[email protected]>
  • Loading branch information
AlexsJones committed Jul 15, 2024
1 parent ab09204 commit fcdf5ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM squidfunk/mkdocs-material:8.3.9
FROM squidfunk/mkdocs-material:latest

## If you want to see exactly the same version as is published to GitHub pages
## use a private image for insiders, which requires authentication.
Expand All @@ -7,4 +7,4 @@ FROM squidfunk/mkdocs-material:8.3.9
# FROM ghcr.io/squidfunk/mkdocs-material-insiders

COPY requirements.txt .
RUN pip install -r requirements.txt
RUN pip install -r requirements.txt
10 changes: 9 additions & 1 deletion docs/tutorials/custom-analyzers.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
In this tutorial, we will learn how to create custom analyzers for K8sGPT.
We will create a custom analyzer that checks a Linux host for resource issues and provides recommendations.

[Full example code](https://github.com/k8sgpt-ai/go-custom-analyzer)

### Why?

There are usecases where you might want to create custom analyzers to check for specific issues in your environment. This would be in conjunction with the K8sGPT built-in analyzers.
Expand All @@ -14,7 +16,8 @@ For example, you may wish to scan the Kubernetes cluster nodes more deeply to un
- [Golang](https://golang.org/doc/install) go1.22 or higher


## Writing a simple analyzer

### Writing a simple analyzer

The K8sGPT CLI, operator and custom analyzers all use a GRPC API to communicate with each other. The API is defined in the [buf.build/k8sgpt-ai/k8sgpt](https://buf.build/k8sgpt-ai/k8sgpt/docs/main:schema.v1) repository. Buf is a tool that helps you manage Protobuf files. You can install it by following the instructions [here](https://docs.buf.build/installation).
Another advantage of buf is that when you import a Protobuf file, it will automatically download the dependencies for you. This is useful when you are working with Protobuf files that have dependencies on other Protobuf files. Additionally, you'll always be able to get the latest version of the Protobuf files.
Expand Down Expand Up @@ -167,3 +170,8 @@ To execute the analyzer we can run the following command:
```bash
k8sgpt analyze --custom-analysis
```

## What's next?
Now you've got the basics of how to write a custom analyzer, you can extend this to check for other issues on your hosts or in your Kubernetes cluster. You can also create more complex analyzers that check for multiple issues and provide more detailed recommendations.

2 changes: 2 additions & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ nav:
- Overview: tutorials/index.md
- Content Collection: tutorials/content-collection/content-collection.md
- K8sGPT Playground: tutorials/playground.md
- Custom Analyzers: tutorials/custom-analyzers.md
- Slack Integration: tutorials/slack-integration.md
- Reference:
- CLI:
- Overview: reference/cli/index.md
Expand Down

0 comments on commit fcdf5ba

Please sign in to comment.