In this blog post, we will cover the installation and experimentation of the Kubectl AI plugin(kubectl-ai), a plugin for Kubectl that combines the functionalities of Kubectl and OpenAI. This tool enables users to create and deploy Kubernetes manifests using OpenAI GPT.

Kubectl: It is a command-line tool used to interact with Kubernetes clusters. It is part of the Kubernetes distribution and allows users to deploy, inspect, and manage applications running on a Kubernetes cluster.

OpenAI GPT: It is a series of language models developed by OpenAI. These models are pre-trained on large datasets of text and then fine-tuned for specific natural languages processing tasks such as language translation, sentiment analysis, or question answering.

Requirements :

1. Kubernetes cluster

2. Linux terminal (My machine is Centos 8.5)

3. OpenAI API key (Take the )

Step 1: Install the Kubectl-ai plugin,

Download the latest binary from the below url,

https://github.com/sozercan/kubectl-ai/releases

Wget https://github.com/sozercan/kubectl-ai/releases/download/v0.0.6/kubectl-ai_linux_amd64.tar.gz

Extract the compressed file and give execute permission for kubectl-ai

tar -xvzf kubectl-ai_linux_amd64.tar.gz

Next generate the OpenAPI key from below url,

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


Add the OpenAPI key in the terminal environment variable which will be used by the Kubectl-ai plugin

export OPENAI_API_KEY=XXXXXXXXX

export OPENAI_DEPLOYMENT_NAME= <I will not set this as an environment variable, as I will be using the default model as, "gpt-3.5-turbo">

Refer here to see the supported models, https://github.com/sozercan/kubectl-ai

Step 2: Experiment with the plugin,

Through this plugin. we will experiment with the followings,

1. Create a new namespace "devopsart"

kubectl get namespace

./kubectl-ai "create a namespace "devopsart""

2. Deploy "WordPress" in the "devopsart" namespace with one replica

./kubectl-ai "create a wordpress deployment with 1 replica in devopsart namespace"

3. Increase the "Wordpress" replica from 1 to 3

./kubectl-ai "Increase wordpress deployment replica count to 3 in devopsart namespace"

Here is the list of resources under the "devopsart" namespace which is created using this plugin.

We can do a lot with the plugin based on our needs. Above, I have tried a few experiments.

That's all. We have installed and configured the kubectl-ai plugin and experimented with this plugin on the Kubernetes cluster. 


Post a Comment

Previous Post Next Post