본문 바로가기
Kubernetes (k8s)

[k8s] k8sgpt -- 쿠버네티스와 ChatGPT?

by moveho 2023. 6. 1.

https://medium.com/techbeatly/chatgpt-for-your-kubernetes-cluster-k8sgpt-649f2cad1bd5

https://github.com/k8sgpt-ai/k8sgpt

 

다음 글을 참조하며 테스트를 진행해보았다.

kevin@k8s-master:~/k8sgpt$ brew tap k8sgpt-ai/k8sgpt
kevin@k8s-master:~/k8sgpt$ brew install k8sgpt
==> Installing k8sgpt-ai/k8sgpt/k8sgpt dependency: isl
==> Pouring isl--0.26.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/isl/0.26: 74 files, 9.8MB
==> Installing k8sgpt-ai/k8sgpt/k8sgpt dependency: mpfr
==> Pouring mpfr--4.2.0-p9.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/mpfr/4.2.0-p9: 31 files, 3.9MB
==> Installing k8sgpt-ai/k8sgpt/k8sgpt dependency: xz
==> Pouring xz--5.4.3.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/xz/5.4.3: 312 files, 3.8MB
==> Installing k8sgpt-ai/k8sgpt/k8sgpt dependency: zstd
==> Pouring zstd--1.5.5.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/zstd/1.5.5: 31 files, 3.2MB
==> Installing k8sgpt-ai/k8sgpt/k8sgpt dependency: binutils
==> Pouring binutils--2.40.x86_64_linux.bottle.tar.gz
🍺  /home/linuxbrew/.linuxbrew/Cellar/binutils/2.40: 4,698 files, 462.4MB
==> Installing k8sgpt-ai/k8sgpt/k8sgpt dependency: gcc
==> Pouring gcc--13.1.0.x86_64_linux.bottle.tar.gz

 

 

kevin@k8s-master:~/k8sgpt$ k8sgpt
Kubernetes debugging powered by AI

Usage:
  k8sgpt [command]

Available Commands:
  analyze     This command will find problems within your Kubernetes cluster
  auth        Authenticate with your chosen backend
  cache       For working with the cache the results of an analysis
  completion  Generate the autocompletion script for the specified shell
  filters     Manage filters for analyzing Kubernetes resources
  generate    Generate Key for your chosen backend (opens browser)
  help        Help about any command
  integration Intergrate another tool into K8sGPT
  serve       Runs k8sgpt as a server
  version     Print the version number of k8sgpt

Flags:
      --config string        config file (default is $HOME/.k8sgpt.yaml)
  -h, --help                 help for k8sgpt
      --kubeconfig string    Path to a kubeconfig. Only required if out-of-cluster.
      --kubecontext string   Kubernetes context to use. Only required if out-of-cluster.

 

kevin@k8s-master:~/k8sgpt$ k8sgpt generate


Opening: https://beta.openai.com/account/api-keys to generate a key for openai

Please copy the generated key and run `k8sgpt auth` to add it to your config file




https://beta.openai.com/account/api-keys
해당 주소로 접근

https://beta.openai.com/account/api-keys

해당 주소로 접근합니다.

다음과 같이 새로운 secret을 생성합니다.

kevin@k8s-master:~/k8sgpt$ k8sgpt auth add *********************키 입력
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
Enter openai Key: openai added to the AI backend provider list

kevin@k8s-master:~$ k8sgpt auth add --password ******************
openai added to the AI backend provider list

 

[EXAMPLE]

kevin@k8s-master:~$ k8sgpt analyze --explain --filter=Pod --namespace=default
AI Provider: openai

No problems detected


kevin@k8s-master:~$ k8sgpt analyze --explain --filter=Pod --namespace=kube-system
   0% |                                                                                  | (0/1, 0 it/hr) [0s:0s]
Error: exhausted API quota for AI provider openai: error, status code: 429, message: You exceeded your current quota, please check your plan and billing details.

유료 결제가 필요한 것 같다.

사용량을 초과했다고 나온다.. 유료결제나 업데이트가 필요할거 같다.

댓글