{"id":13471526,"url":"https://github.com/sozercan/kubectl-ai","last_synced_at":"2025-05-14T21:06:09.544Z","repository":{"id":143965915,"uuid":"615891862","full_name":"sozercan/kubectl-ai","owner":"sozercan","description":"✨ Kubectl plugin to create manifests with LLMs","archived":false,"fork":false,"pushed_at":"2025-01-27T22:00:14.000Z","size":249,"stargazers_count":1085,"open_issues_count":13,"forks_count":84,"subscribers_count":12,"default_branch":"main","last_synced_at":"2025-04-13T17:46:49.390Z","etag":null,"topics":["ai","chatgpt","gpt","gpt-4","hacktoberfest","k8s","kubectl","kubectl-plugins","kubernetes","llm","localllama","open-llm","openai","openai-api"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sozercan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-19T01:16:05.000Z","updated_at":"2025-04-09T07:46:51.000Z","dependencies_parsed_at":"2024-01-14T09:09:50.864Z","dependency_job_id":"1779ca53-4198-4549-872d-8a74af578d96","html_url":"https://github.com/sozercan/kubectl-ai","commit_stats":{"total_commits":92,"total_committers":10,"mean_commits":9.2,"dds":0.5543478260869565,"last_synced_commit":"e89cbdd3cda09fa6efff92453c67b6edc9ff3d4a"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sozercan%2Fkubectl-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sozercan%2Fkubectl-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sozercan%2Fkubectl-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sozercan%2Fkubectl-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sozercan","download_url":"https://codeload.github.com/sozercan/kubectl-ai/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254227611,"owners_count":22035669,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","chatgpt","gpt","gpt-4","hacktoberfest","k8s","kubectl","kubectl-plugins","kubernetes","llm","localllama","open-llm","openai","openai-api"],"created_at":"2024-07-31T16:00:46.230Z","updated_at":"2025-05-14T21:06:09.513Z","avatar_url":"https://github.com/sozercan.png","language":"Go","funding_links":[],"categories":["精选开源项目合集","Go","Extend ChatGPT Feature","Uncategorized","Browser-extensions","kubernetes","twitter","Addons, extensions, plug-ins for integrating LLM into third-party applications","ai"],"sub_categories":["GPT插件","Other","Uncategorized","Other user interfaces"],"readme":"# Kubectl OpenAI plugin ✨\n\nThis project is a `kubectl` plugin to generate and apply Kubernetes manifests using OpenAI GPT.\n\nMy main motivation is to avoid finding and collecting random manifests when dev/testing things.\n\n## Demo\n\n[![asciicast](https://asciinema.org/a/MEXrlAqUjo7DMnfoyQearpVQ7.svg)](https://asciinema.org/a/MEXrlAqUjo7DMnfoyQearpVQ7)\n\n## Installation\n\n### Homebrew\n\nAdd to `brew` tap and install with:\n\n```shell\nbrew tap sozercan/kubectl-ai https://github.com/sozercan/kubectl-ai\nbrew install kubectl-ai\n```\n\n### Krew\n\nAdd to `krew` index and install with:\n\n```shell\nkubectl krew index add kubectl-ai https://github.com/sozercan/kubectl-ai\nkubectl krew install kubectl-ai/kubectl-ai\n```\n\n### GitHub release\n- Download the binary from [GitHub releases](https://github.com/sozercan/kubectl-ai/releases).\n\n- If you want to use this as a [`kubectl` plugin](https://kubernetes.io/docs/tasks/extend-kubectl/kubectl-plugins/), then copy `kubectl-ai` binary to your `PATH`. If not, you can also use the binary standalone.\n\n## Usage\n\n### Prerequisites\n\n`kubectl-ai` requires a valid Kubernetes configuration and one of the following:\n\n- [OpenAI API key](https://platform.openai.com/overview)\n- [Azure OpenAI Service](https://aka.ms/azure-openai) API key and endpoint\n- [OpenAI API-compatible endpoint](#set-up-a-local-openai-api-compatible-endpoint) (such as [AIKit](https://github.com/sozercan/aikit) or [LocalAI](https://localai.io/))\n\nFor OpenAI, Azure OpenAI or OpenAI API compatible endpoint, you can use the following environment variables:\n\n```shell\nexport OPENAI_API_KEY=\u003cyour OpenAI key\u003e\nexport OPENAI_DEPLOYMENT_NAME=\u003cyour OpenAI deployment/model name. defaults to \"gpt-3.5-turbo-0301\"\u003e\nexport OPENAI_ENDPOINT=\u003cyour OpenAI endpoint, like \"https://my-aoi-endpoint.openai.azure.com\" or \"http://localhost:8080/v1\"\u003e\n```\n\nIf `OPENAI_ENDPOINT` variable is set, then it will use the endpoint. Otherwise, it will use OpenAI API.\n\nAzure OpenAI service does not allow certain characters, such as `.`, in the deployment name. Consequently, `kubectl-ai` will automatically replace `gpt-3.5-turbo` to `gpt-35-turbo` for Azure. However, if you use an Azure OpenAI deployment name completely different from the model name, you can set `AZURE_OPENAI_MAP` environment variable to map the model name to the Azure OpenAI deployment name. For example:\n\n```shell\nexport AZURE_OPENAI_MAP=\"gpt-3.5-turbo=my-deployment\"\n```\n\n### Set up a local OpenAI API-compatible endpoint\n\nIf you don't have OpenAI API access, you can set up a local OpenAI API-compatible endpoint using [AIKit](https://github.com/sozercan/aikit) on your local machine without any GPUs! For more information, see the [AIKit documentaton](https://sozercan.github.io/aikit/).\n\n```shell\ndocker run -d --rm -p 8080:8080 ghcr.io/sozercan/llama3.1:8b\nexport OPENAI_ENDPOINT=\"http://localhost:8080/v1\"\nexport OPENAI_DEPLOYMENT_NAME=\"llama-3.1-8b-instruct\"\nexport OPENAI_API_KEY=\"n/a\"\n```\n\nAfter setting up the environment like above, you can use `kubectl-ai` as usual.\n\n### Flags and environment variables\n\n- `--require-confirmation` flag or `REQUIRE_CONFIRMATION` environment variable can be set to prompt the user for confirmation before applying the manifest. Defaults to true.\n\n- `--temperature` flag or `TEMPERATURE` environment variable can be set between 0 and 1. Higher temperature will result in more creative completions. Lower temperature will result in more deterministic completions. Defaults to 0.\n\n- `--use-k8s-api` flag or `USE_K8S_API` environment variable can be set to use Kubernetes OpenAPI Spec to generate the manifest. This will result in very accurate completions including CRDs (if present in configured cluster). This setting will use more OpenAI API calls and it requires [function calling](https://openai.com/blog/function-calling-and-other-api-updates) which is available in `0613` or later models only. Defaults to false. However, this is recommended for accuracy and completeness.\n\n- `--k8s-openapi-url` flag or `K8S_OPENAPI_URL` environment variable can be set to use a custom Kubernetes OpenAPI Spec URL. This is only used if `--use-k8s-api` is set. By default, `kubectl-ai` will use the configured Kubernetes API Server to get the spec unless this setting is configured. You can use the [default Kubernetes OpenAPI Spec](https://raw.githubusercontent.com/kubernetes/kubernetes/master/api/openapi-spec/swagger.json) or generate a custom spec for completions that includes custom resource definitions (CRDs). You can generate custom OpenAPI Spec by using `kubectl get --raw /openapi/v2 \u003e swagger.json`.\n\n### Pipe Input and Output\n\nKubectl AI can be used with pipe input and output. For example:\n\n```shell\n$ cat foo-deployment.yaml | kubectl ai \"change replicas to 5\" --raw | kubectl apply -f -\n```\n\n#### Save to file\n\n```shell\n$ cat foo-deployment.yaml | kubectl ai \"change replicas to 5\" --raw \u003e my-deployment-updated.yaml\n```\n\n#### Use with external editors\n\nIf you want to use an external editor to edit the generated manifest, you can set the `--raw` flag and pipe to the editor of your choice. For example:\n\n```shell\n# Visual Studio Code\n$ kubectl ai \"create a foo namespace\" --raw | code -\n\n# Vim\n$ kubectl ai \"create a foo namespace\" --raw | vim -\n```\n\n## Examples\n\n### Creating objects with specific values\n\n```shell\n$ kubectl ai \"create an nginx deployment with 3 replicas\"\n✨ Attempting to apply the following manifest:\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: nginx-deployment\n  labels:\n    app: nginx\nspec:\n  replicas: 3\n  selector:\n    matchLabels:\n      app: nginx\n  template:\n    metadata:\n      labels:\n        app: nginx\n    spec:\n      containers:\n      - name: nginx\n        image: nginx:1.7.9\n        ports:\n        - containerPort: 80\nUse the arrow keys to navigate: ↓ ↑ → ←\n? Would you like to apply this? [Reprompt/Apply/Don't Apply]:\n+   Reprompt\n  ▸ Apply\n    Don't Apply\n```\n\n### Reprompt to refine your prompt\n\n```shell\n...\nReprompt: update to 5 replicas and port 8080\n✨ Attempting to apply the following manifest:\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n  name: nginx-deployment\n  labels:\n    app: nginx\nspec:\n  replicas: 5\n  selector:\n    matchLabels:\n      app: nginx\n  template:\n    metadata:\n      labels:\n        app: nginx\n    spec:\n      containers:\n      - name: nginx\n        image: nginx:1.7.9\n        ports:\n        - containerPort: 8080\nUse the arrow keys to navigate: ↓ ↑ → ←\n? Would you like to apply this? [Reprompt/Apply/Don't Apply]:\n+   Reprompt\n  ▸ Apply\n    Don't Apply\n```\n\n### Multiple objects\n\n```shell\n$ kubectl ai \"create a foo namespace then create nginx pod in that namespace\"\n✨ Attempting to apply the following manifest:\napiVersion: v1\nkind: Namespace\nmetadata:\n  name: foo\n---\napiVersion: v1\nkind: Pod\nmetadata:\n  name: nginx\n  namespace: foo\nspec:\n  containers:\n  - name: nginx\n    image: nginx:latest\nUse the arrow keys to navigate: ↓ ↑ → ←\n? Would you like to apply this? [Reprompt/Apply/Don't Apply]:\n+   Reprompt\n  ▸ Apply\n    Don't Apply\n```\n\n### Optional `--require-confirmation` flag\n\n```shell\n$ kubectl ai \"create a service with type LoadBalancer with selector as 'app:nginx'\" --require-confirmation=false\n✨ Attempting to apply the following manifest:\napiVersion: v1\nkind: Service\nmetadata:\n  name: nginx-service\nspec:\n  selector:\n    app: nginx\n  ports:\n  - port: 80\n    targetPort: 80\n  type: LoadBalancer\n```\n\n\u003e Please note that the plugin does not know the current state of the cluster (yet?), so it will always generate the full manifest.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsozercan%2Fkubectl-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsozercan%2Fkubectl-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsozercan%2Fkubectl-ai/lists"}