AI Kubernetes

kubectl-aiでマニフェストを作成しよう

はじめに

kubectlにもマニフェストを作成してくれるプラグインが登場した。

GitHub - sozercan/kubectl-ai: ✨ Kubectl plugin for OpenAI GPT
GitHub - sozercan/kubectl-ai: ✨ Kubectl plugin for OpenAI GPT

✨ Kubectl plugin for OpenAI GPT. Contribute to sozercan/kubectl-ai development by creating an accoun ...

github.com

利用方法

いたって簡単です。

ダウンロードしたプラグインを/usr/local/binのコピーします。

キーを設定します。

export OPENAI_API_KEY=<your OpenAI key>
export OPENAI_DEPLOYMENT_NAME=<your OpenAI deployment/model name. defaults to "gpt-3.5-turbo">

 

あとはプラグインとして実行します。

root@DESKTOP-FI2UMJO:~# kubectl ai "create an nginx deployment with 3 replicas"
✨ Attempting to apply the following manifest:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
✔ Don't Apply
root@DESKTOP-FI2UMJO:~# kubectl ai "nginxをreplace 3つに展開する"
✨ Attempting to apply the following manifest:
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        ports:
        - containerPort: 80
Use the arrow keys to navigate: ↓ ↑ → ←
? Would you like to apply this? [Apply/Don't Apply]:
  ▸ Apply
    Don't Apply

Applyまで実行してくれるようです。

まとめ

ChatGPTでConfig作る系はどんどん増えてくるでしょう。効率化の波がすごい。

-AI, Kubernetes
-,