Last active
August 8, 2023 01:33
-
-
Save 100daysofdevops/117907ef93a2e3a4f254d2c5221a38cd to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#Installation in mac or in different version https://github.com/k8sgpt-ai/k8sgpt | |
brew tap k8sgpt-ai/k8sgpt | |
brew install k8sgpt | |
# Verify the version | |
k8sgpt version | |
#Checking Help | |
k8sgpt --help | |
#Support for providers(OpenAI, Azure OpenAI, LocalAI, FakeAI) https://docs.k8sgpt.ai/reference/providers/backend/ | |
# To use OpenAI you'll need an OpenAI token for authentication purposes. To generate a token use | |
k8sgpt generate | |
# To set the token in K8sGPT, use the following command: | |
k8sgpt auth new | |
# To add a backend such as openai https://github.com/k8sgpt-ai/k8sgpt/issues/528 | |
k8sgpt auth add -b openai -m gpt-3.5-turbo | |
# To list the providers | |
k8sgpt auth list | |
# Simulating the ErrImagePull pull error | |
kubectl create -f https://raw.githubusercontent.com/100daysofdevops/kubernetes_debugging/main/Imagepullbackoff.yaml | |
# Run the following command to analyze issues within your cluster using OpenAI: | |
k8sgpt analyze | |
# If you want k8sgpt to explain problem to you | |
k8sgpt analyze --explain | |
# if you want to anonymize data before sending it to the AI backend | |
k8sgpt analyze --anonymize | |
# To manage filters that are used to analyze Kubernetes resources | |
k8sgpt filters list | |
# If you want to add additional functionality to k8sgpt you can do it via integration(Currently it only support trivy) | |
k8sgpt integration list | |
# To activate an integration | |
k8sgpt integration activate trivy | |
# Now we have the filter enabled you can use it | |
k8sgpt analyze --filter=VulnerabilityReport | |
# To install the operator https://docs.k8sgpt.ai/getting-started/in-cluster-operator/ | |
helm repo add k8sgpt https://charts.k8sgpt.ai/ | |
helm repo update | |
helm install release k8sgpt/k8sgpt-operator -n k8sgpt-operator-system --create-namespace | |
helm install release k8sgpt/k8sgpt-operator -n k8sgpt-operator-system --create-namespace --values values.yaml | |
# To create dashboard for prometheus and grafana | |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts | |
helm repo update | |
helm install prom prometheus-community/kube-prometheus-stack -n k8sgpt-operator-system --set prometheus.prometheusSpec.serviceMonitorSelectorNilUsesHelmValues=false | |
#Deploying an OpenAI secret | |
export OPENAI_TOKEN=" " | |
kubectl create secret generic k8sgpt-sample-secret --from-literal=openai-api-key=$OPENAI_TOKEN -n k8sgpt-operator-system | |
# Deploying a K8sGPT resource | |
kubectl apply -f - << EOF | |
apiVersion: core.k8sgpt.ai/v1alpha1 | |
kind: K8sGPT | |
metadata: | |
name: k8sgpt-sample | |
namespace: k8sgpt-operator-system | |
spec: | |
ai: | |
enabled: true | |
model: gpt-3.5-turbo | |
backend: openai | |
secret: | |
name: k8sgpt-sample-secret | |
key: openai-api-key | |
# anonymized: false | |
# language: english | |
noCache: false | |
version: v0.3.8 | |
# filters: | |
# - Ingress | |
# sink: | |
# type: slack | |
# webhook: <webhook-url> | |
# extraOptions: | |
# backstage: | |
# enabled: true | |
EOF | |
# Port forwarding Prometheus and Grafana to access it on localhost | |
kubectl port-forward service/prometheus-operated -n k8sgpt-operator-system 9000:9090 | |
kubectl port-forward service/prom-grafana -n k8sgpt-operator-system 3000:80 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment