Skip to content

Commit

Permalink
Merge pull request #24 from k8sgpt-ai/feat/operator-getting-started
Browse files Browse the repository at this point in the history
feat: operator getting started
  • Loading branch information
AlexsJones committed Apr 27, 2023
2 parents eca5fe1 + f327df7 commit 2240617
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 0 deletions.
88 changes: 88 additions & 0 deletions docs/getting-started/in-cluster-operator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
# K8sGPT Operator

## Prerequisites

- To begin you will require a Kubernetes cluster available and `KUBECONFIG` set.
- You will also need to install helm v3. [See the Helm documentation for more information](https://helm.sh/docs/intro/install/).

## Operator Installation

To install the operator, run the following command:

```bash
helm repo add k8sgpt https://charts.k8sgpt.ai/
helm install release k8sgpt/k8sgpt-operator
```

This will install the Operator into the cluster, which will await a `K8sGPT` resource before anything happens.

## Deploying an OpenAI secret

Whilst there are multiple backends supported ( OpenAI, Azure OpenAI and Local ), in this example we'll use OpenAI.

This means you will need to install your token as a secret into the cluster.

For example:

```bash
kubectl create secret generic k8sgpt-sample-secret --from-literal=openai-api-key=$OPENAI_TOKEN -n default
```

## Deploying a K8sGPT resource

To deploy a K8sGPT resource, you will need to create a YAML file with the following contents:

```yaml
kubectl apply -f - << EOF
apiVersion: core.k8sgpt.ai/v1alpha1
kind: K8sGPT
metadata:
name: k8sgpt-sample
spec:
namespace: default
model: gpt-3.5-turbo
backend: openai
noCache: false
version: v0.2.7
enableAI: true
secret:
name: k8sgpt-sample-secret
key: openai-api-key
EOF
```

### Regarding out of cluster traffic to AI backends

In the above example `enableAI` is set to `true`.
This option allows the cluster deployment to use the `backend` to filter and improve the responses to the user.
Those responses will appear as `details` within the `Result` custom resources that are created.

The default backend in this example is [OpenAI](https://openai.com/) and allows for additional details to be generated and solutions provided for issues.
If you wish to disable out-of-cluster communication and any Artifical Intelligence processing through models, simply set `enableAI` to `false`.

_It should also be noted that `localai` is supported and in-cluster models will be supported in the near future_

## Viewing the results

Once the initial scans have completed after several minutes, you will be presented with results custom resources.

```bash
❯ kubectl get results -o json | jq .
{
"apiVersion": "v1",
"items": [
{
"apiVersion": "core.k8sgpt.ai/v1alpha1",
"kind": "Result",
"metadata": {
"creationTimestamp": "2023-04-26T09:45:02Z",
"generation": 1,
"name": "placementoperatorsystemplacementoperatorcontrollermanagermetricsservice",
"namespace": "default",
"resourceVersion": "108371",
"uid": "f0edd4de-92b6-4de2-ac86-5bb2b2da9736"
},
"spec": {
"details": "The error message means that the service in Kubernetes doesn't have any associated endpoints, which should have been labeled with \"control-plane=controller-manager\". \n\nTo solve this issue, you need to add the \"control-plane=controller-manager\" label to the endpoint that matches the service. Once the endpoint is labeled correctly, Kubernetes can associate it with the service, and the error should be resolved.",
...
```
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ nav:
- Overview: index.md
- Getting Started Guide: getting-started/getting-started.md
- Installation: getting-started/installation.md
- In-Cluster Operator: getting-started/in-cluster-operator.md
- Tutorials:
- Overview: tutorials/index.md
- Content Collection: tutorials/content-collection/content-collection.md
Expand Down

0 comments on commit 2240617

Please sign in to comment.