APC 技術ブログ

株式会社エーピーコミュニケーションズの技術ブログです。

株式会社 エーピーコミュニケーションズの技術ブログです。

K8sGPTのAI ProviderにAzure OpenAI Serviceが使えるようになりましたよ

はじめに

こんにちは、ACS事業部の谷合です。
以前トラブルシュートの際にAIの力を借りれるK8sGPTなるツールをご紹介しました。

techblog.ap-com.co.jp

紹介当時はまだツールとしては基本的な分析機能しか持っていませんでしたが、現在開発も進んできており、かなりの数の機能追加もされています。
個人的に追加されて幸せになった機能は以下のものがあります。

弊社はMicrosoft社とのパートナーであり、Azure OpenAI Serviceを使ったAI関連の案件も受けています。そこで、社内でも活発に会話が繰り広げられているAzure OpenAI ServiceをProviderとして追加し、K8sGPTを動かしてみたいと思います。

Provider追加

前提

  • Azure OpenAI Serviceリソースが作成されていること
  • Azure OpenAI Serviceリソースにモデルがデプロイされていること
  • 今回のモデルはgpt-35-turbo (version 0301)

Azure OpenAI Serviceリソース作成手順は以下のドキュメントをご確認ください learn.microsoft.com

Azure OpenAI Serviceリソース情報確認

キーとエンドポイント確認

Azure OpenAI Serviceリソースの左ペインの「キーとエンドポイント」を押下することで、以下のように確認可能です。
キーはマスクされていますが、右の「クリップボードにコピー」を押下することでコピーが可能です。
後ほど使うので、どちらも控えておいてください。

デプロイ モデル確認

Azure OpenAI Serviceリソースの左ペインの「デプロイ モデル」を押下することで、以下のように確認可能です。
キーとエンドポイント同様に、モデル デプロイ名およびモデル名も控えておいて下さい。

Provider追加

以下ドキュメントのAzure OpenAIの章を参考に作業を行います。

まず、ドキュメント通りにProviderを追加します。 事前に控えておいたAzure OpenAi Serviceの情報を使い、以下コマンドを実行します。

$ k8sgpt auth new --backend azureopenai --baseurl https://xxxxxxxxxx.openai.azure.com/ --engine test-k8sgpt-model --model gpt-35-turbo
Enter azureopenai Key: ←エンドポイントキー
azureopenai added to the AI backend provider list

上記コマンドを実行すると、以下のconfigファイルが作成されます。
K8sGPTの設定情報は、Linuxであれば、~/.config/k8sgpt/k8sgpt.yaml にあります。

ai:
    providers:
        - name: azureopenai
          model: gpt-3.5-turbo
          password: xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
          baseurl: https://xxxxxxxxxx.openai.azure.com/
          engine: test-k8sgpt-model

kubeconfig: ""
kubecontext: ""

問題なくAzure OpenAI Serviceでの分析ができてますね。

$ k8sgpt analyze --explain --backend azureopenai
 100% |██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| (2/2, 36 it/min)        

0 default/test(test)
- Error: Back-off pulling image "wrongimage"
The container is unable to download the required image "wrongimage". 

Solution: 
- Check if the image name is correct 
- Check if the image exists in the repository 
- Check if there are any network issues that may be preventing the download 
- Check if the required credentials are provided to access the repository 
- Restart the deployment or pod to trigger a fresh download of the image.
1 default/test(test)
- Error: Service has no endpoints, expected label run=wronglabel
The service is unable to find any corresponding endpoints with the specified label "run=wronglabel". 

Solution: Check the label selector on the service and ensure that the pods with the same label are running in the cluster. Also, verify that the label values are correctly spelled and match the corresponding pod labels.

さいごに

Azure OpenAI ServiceをProviderとすることで、さまざまなAIモデルをバックエンドすることが可能となります。
お使いのAIモデルでKubernetesを分析したいといった要望があれば、是非Azure OpenAI Serviceとの統合を行ってみてください!!

ACS事業部のご紹介

私達ACS事業部はAzure・AKSなどのクラウドネイティブ技術を活用した内製化のご支援をしております。
www.ap-com.co.jp また、一緒に働いていただける仲間も募集中です!
今年もまだまだ組織規模拡大中なので、ご興味持っていただけましたらぜひお声がけください。 www.ap-com.co.jp

本記事の投稿者: 谷合純也
AKS/ACAをメインにインフラ系のご支援を担当しています。
junya0530さんの記事一覧 | Zenn