이 프로젝트는 OpenAi GPT를 사용하여 Kubernetes를 생성하고 적용하는 kubectl 플러그인입니다.
저의 주요 동기는 Dev/Test를 할 때 무작위 행사를 찾고 수집하는 것을 피하는 것입니다.
brew Tap에 추가하고 다음과 같이 설치하십시오.
brew tap sozercan/kubectl-ai https://github.com/sozercan/kubectl-ai
brew install kubectl-ai krew Index에 추가하고 다음과 같이 설치하십시오.
kubectl krew index add kubectl-ai https://github.com/sozercan/kubectl-ai
kubectl krew install kubectl-ai/kubectl-aiGithub 릴리스에서 바이너리를 다운로드하십시오.
이것을 kubectl 플러그인으로 사용하려면 kubectl-ai binary를 PATH 로 복사하십시오. 그렇지 않은 경우 바이너리 독립형을 사용할 수도 있습니다.
kubectl-ai 유효한 Kubernetes 구성과 다음 중 하나가 필요합니다.
OpenAi, Azure OpenAi 또는 OpenAI API 호환 엔드 포인트의 경우 다음 환경 변수를 사용할 수 있습니다.
export OPENAI_API_KEY= < your OpenAI key >
export OPENAI_DEPLOYMENT_NAME= < your OpenAI deployment/model name. defaults to " gpt-3.5-turbo-0301 " >
export OPENAI_ENDPOINT= < your OpenAI endpoint, like " https://my-aoi-endpoint.openai.azure.com " or " http://localhost:8080/v1 " > OPENAI_ENDPOINT 변수가 설정되면 엔드 포인트를 사용합니다. 그렇지 않으면 OpenAI API를 사용합니다.
Azure OpenAi 서비스는 다음과 같은 특정 문자를 허용하지 않습니다 . 배포 이름에서. 결과적으로, kubectl-ai Azure를 위해 gpt-3.5-turbo gpt-35-turbo 로 자동으로 교체합니다. 그러나 Azure OpenAi 배포 이름을 모델 이름과 완전히 다른 경우 AZURE_OPENAI_MAP 환경 변수를 설정하여 모델 이름을 Azure OpenAI 배포 이름에 매핑 할 수 있습니다. 예를 들어:
export AZURE_OPENAI_MAP= " gpt-3.5-turbo=my-deployment "OpenAI API 액세스가없는 경우 GPU없이 로컬 컴퓨터에서 Aikit을 사용하여 로컬 OpenAI API 호환 엔드 포인트를 설정할 수 있습니다! 자세한 내용은 Aikit Documentaton을 참조하십시오.
docker run -d --rm -p 8080:8080 ghcr.io/sozercan/llama3.1:8b
export OPENAI_ENDPOINT= " http://localhost:8080/v1 "
export OPENAI_DEPLOYMENT_NAME= " llama-3.1-8b-instruct "
export OPENAI_API_KEY= " n/a " 위와 같은 환경을 설정 한 후 평소와 같이 kubectl-ai 사용할 수 있습니다.
--require-confirmation 플래그 또는 REQUIRE_CONFIRMATION 환경 변수는 매니페스트를 적용하기 전에 사용자에게 확인을 프롬프트하도록 설정할 수 있습니다. 기본값은 참으로.
--temperature 플래그 또는 TEMPERATURE 환경 변수는 0과 1 사이로 설정할 수 있습니다. 온도가 높으면 창의적인 완료가됩니다. 온도가 낮을수록 결정 론적 완료가 발생합니다. 기본값은 0까지.
--use-k8s-api flag 또는 USE_K8S_API 환경 변수는 kubernetes openapi 사양을 사용하여 매니페스트를 생성하도록 설정할 수 있습니다. 이로 인해 CRD (구성된 클러스터에있는 경우)를 포함하여 매우 정확한 완료가 발생합니다. 이 설정은 더 많은 OpenAI API 호출을 사용하며 0613 이상 모델에서만 사용할 수있는 기능 호출이 필요합니다. 기본값으로 거짓. 그러나 이것은 정확성과 완전성에 권장됩니다.
--k8s-openapi-url 플래그 또는 K8S_OPENAPI_URL 환경 변수는 사용자 정의 Kubernetes OpenApi Spec URL을 사용하도록 설정할 수 있습니다. --use-k8s-api 설정된 경우에만 사용됩니다. 기본적으로 kubectl-ai 구성된 Kubernetes API 서버를 사용 하여이 설정이 구성되지 않는 한 사양을 가져옵니다. 기본 Kubernetes OpenAPI 사양을 사용하거나 CRD (Custom Resource Deferents)가 포함 된 완료에 대한 사용자 정의 사양을 생성 할 수 있습니다. kubectl get --raw /openapi/v2 > swagger.json 사용하여 사용자 정의 OpenApi 사양을 생성 할 수 있습니다.
Kubectl ai는 파이프 입력 및 출력과 함께 사용할 수 있습니다. 예를 들어:
$ cat foo-deployment.yaml | kubectl ai " change replicas to 5 " --raw | kubectl apply -f -$ cat foo-deployment.yaml | kubectl ai " change replicas to 5 " --raw > my-deployment-updated.yaml 외부 편집기를 사용하여 생성 된 Manifest를 편집하려면 --raw 플래그와 파이프를 선택한 편집기에 설정할 수 있습니다. 예를 들어:
# Visual Studio Code
$ kubectl ai " create a foo namespace " --raw | code -
# Vim
$ kubectl ai " create a foo namespace " --raw | vim -$ kubectl ai " create an nginx deployment with 3 replicas "
Attempting to apply the following manifest:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
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 ? [Reprompt/Apply/Don ' t Apply]:
+ Reprompt
▸ Apply
Don ' t Apply...
Reprompt: update to 5 replicas and port 8080
Attempting to apply the following manifest:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 5
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 8080
Use the arrow keys to navigate: ↓ ↑ → ←
? Would you like to apply this ? [Reprompt/Apply/Don ' t Apply]:
+ Reprompt
▸ Apply
Don ' t Apply$ kubectl ai " create a foo namespace then create nginx pod in that namespace "
Attempting to apply the following manifest:
apiVersion: v1
kind: Namespace
metadata:
name: foo
---
apiVersion: v1
kind: Pod
metadata:
name: nginx
namespace: foo
spec:
containers:
- name: nginx
image: nginx:latest
Use the arrow keys to navigate: ↓ ↑ → ←
? Would you like to apply this ? [Reprompt/Apply/Don ' t Apply]:
+ Reprompt
▸ Apply
Don ' t Apply--require-confirmation 플래그 $ kubectl ai " create a service with type LoadBalancer with selector as 'app:nginx' " --require-confirmation=false
Attempting to apply the following manifest:
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- port: 80
targetPort: 80
type: LoadBalancer플러그인은 클러스터의 현재 상태를 알지 못하므로 항상 전체 매니페스트를 생성합니다.