kube-copilot


Namekube-copilot JSON
Version 0.1.27 PyPI version JSON
download
home_pagehttps://github.com/feiskyer/kube-copilot
SummaryKubernetes Copilot
upload_time2024-05-06 09:22:49
maintainerNone
docs_urlNone
authorPengfei Ni
requires_python<4,>=3.11
licenseNone
keywords kubernetes copilot openai chatgpt
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Kubernetes Copilot

Kubernetes Copilot powered by OpenAI.

Features:

- Automate Kubernetes cluster operations using ChatGPT (GPT-4 or GPT-3.5).
- Diagnose and analyze the potential issues for Kubernetes workloads.
- Generate the Kubernetes manifests based on the provided prompt instructions.
- Utilize native kubectl and trivy commands for Kubernetes cluster access and security vulnerability scanning.
- Access the web and perform Google searches without leaving the terminal.

## Install

### Run in Kubernetes

**Option 1: Web UI with Helm (recommended)**

```sh
# Option 1: OpenAI
export OPENAI_API_KEY="<replace-this>"
helm install kube-copilot kube-copilot \
  --repo https://feisky.xyz/kube-copilot \
  --set openai.apiModel=gpt-4 \
  --set openai.apiKey=$OPENAI_API_KEY

# Option 2: Azure OpenAI Service
export AZURE_OPENAI_API_KEY="<replace-this>"
export AZURE_OPENAI_ENDPOINT="<replace-this>"
helm install kube-copilot kube-copilot \
  --repo https://feisky.xyz/kube-copilot \
  --set openai.apiModel=gpt-4 \
  --set openai.apiKey=$AZURE_OPENAI_API_KEY \
  --set openai.apiBase=$AZURE_OPENAI_ENDPOINT

# Forwarding requests to the service
kubectl port-forward service/kube-copilot 8080:80
echo "Visit http://127.0.0.1:8080 to use the copilot"
```

**Option 2: CLI with kubectl**

```sh
kubectl run -it --rm copilot \
  --env="OPENAI_API_KEY=$OPENAI_API_KEY" \
  --restart=Never \
  --image=ghcr.io/feiskyer/kube-copilot \
  -- execute --verbose 'What Pods are using max memory in the cluster'

kubectl run -it --rm copilot \
  --env="AZURE_OPENAI_API_KEY=$AZURE_OPENAI_API_KEY" \
  --env="AZURE_OPENAI_ENDPOINT=$AZURE_OPENAI_ENDPOINT" \
  --restart=Never \
  --image=ghcr.io/feiskyer/kube-copilot \
  -- execute --verbose 'What Pods are using max memory in the cluster'
```

Refer [kubernetes.md](kubernetes.md) for more detailed steps.

### Local Install

Install the copilot with pip command below:

```sh
pip install kube-copilot
```

**Setup:**

- Ensure [`kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/) is installed on the local machine and the kubeconfig file is configured for Kubernetes cluster access.
- Install [`trivy`](https://github.com/aquasecurity/trivy) to assess container image security issues (for the `audit` command).
- Set the OpenAI [API key](https://platform.openai.com/account/api-keys) as the `OPENAI_API_KEY` environment variable to enable ChatGPT functionality.
  - For [Azure OpenAI service](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/quickstart?tabs=command-line&pivots=rest-api#retrieve-key-and-endpoint), also set `OPENAI_API_TYPE=azure` and `OPENAI_API_BASE=https://<replace-this>.openai.azure.com/`.
- Google search is disabled by default. To enable it, set `GOOGLE_API_KEY` and `GOOGLE_CSE_ID` (obtain from [here](https://cloud.google.com/docs/authentication/api-keys?visit_id=638154888929258210-4085587461) and [here](http://www.google.com/cse/)).

## How to use web UI

![image-20230707191237629](assets/preview.jpg)

## How to use CLI

Running directly in the terminal:

```sh
Usage: kube-copilot [OPTIONS] COMMAND [ARGS]...

  Kubernetes Copilot powered by OpenAI

Options:
  --version  Show the version and exit.
  --help     Show this message and exit.

Commands:
  analyze   analyze issues for a given resource
  audit     audit security issues for a Pod
  diagnose  diagnose problems for a Pod
  execute   execute operations based on prompt instructions
  generate  generate Kubernetes manifests
```

### Audit Security Issues for Pod

`kube-copilot audit POD [NAMESPACE]` will audit security issues for a Pod:

```sh
Usage: kube-copilot audit [OPTIONS] POD [NAMESPACE]

  audit security issues for a Pod

Options:
  --verbose      Enable verbose information of copilot execution steps
  --model MODEL  OpenAI model to use for copilot execution, default is gpt-4
  --help         Show this message and exit.
```

### Diagnose Problems for Pod

`kube-copilot diagnose POD [NAMESPACE]` will diagnose problems for a Pod:

```sh
Usage: kube-copilot diagnose [OPTIONS] POD [NAMESPACE]

  diagnose problems for a Pod

Options:
  --verbose      Enable verbose information of copilot execution steps
  --model MODEL  OpenAI model to use for copilot execution, default is gpt-4
  --help         Show this message and exit.
```

### Analyze Potential Issues for k8s Object

`kube-copilot analyze RESOURCE NAME [NAMESPACE]` will analyze potential issues for the given resource object:

```sh
Usage: kube-copilot analyze [OPTIONS] RESOURCE NAME [NAMESPACE]

  analyze issues for a given resource

Options:
  --verbose     Enable verbose information of copilot execution steps
  --model TEXT  OpenAI model to use for copilot execution, default is gpt-4
  --help        Show this message and exit.
```

### Execute Operations Based on Prompt Instructions

`kube-copilot execute INSTRUCTIONS` will execute operations based on prompt instructions.
It could also be used to ask any questions.

```sh
Usage: kube-copilot execute [OPTIONS] INSTRUCTIONS

  execute operations based on prompt instructions

Options:
  --verbose      Enable verbose information of copilot execution steps
  --model MODEL  OpenAI model to use for copilot execution, default is gpt-4
  --help         Show this message and exit.
```

### Generate Kubernetes Manifests

Use the `kube-copilot generate` command to create Kubernetes manifests based on
the provided prompt instructions. After generating the manifests, you will be
prompted to confirm whether you want to apply them.

```sh
Usage: kube-copilot generate [OPTIONS] INSTRUCTIONS

  generate Kubernetes manifests

Options:
  --verbose     Enable verbose information of copilot execution steps
  --model TEXT  OpenAI model to use for copilot execution, default is gpt-4
  --help        Show this message and exit.
```

## Contribution

The project is opensource at github [feiskyer/kube-copilot](https://github.com/feiskyer/kube-copilot) with Apache License.

If you would like to contribute to the project, please follow these guidelines:

1. Fork the repository and clone it to your local machine.
2. Create a new branch for your changes.
3. Make your changes and commit them with a descriptive commit message.
4. Push your changes to your forked repository.
5. Open a pull request to the main repository.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/feiskyer/kube-copilot",
    "name": "kube-copilot",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4,>=3.11",
    "maintainer_email": null,
    "keywords": "kubernetes, copilot, openai, chatgpt",
    "author": "Pengfei Ni",
    "author_email": "feiskyer@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/d2/64/f91a44022a22c20e93598380ca34650f5f8600d21c25987cd402cdbc472e/kube_copilot-0.1.27.tar.gz",
    "platform": null,
    "description": "# Kubernetes Copilot\n\nKubernetes Copilot powered by OpenAI.\n\nFeatures:\n\n- Automate Kubernetes cluster operations using ChatGPT (GPT-4 or GPT-3.5).\n- Diagnose and analyze the potential issues for Kubernetes workloads.\n- Generate the Kubernetes manifests based on the provided prompt instructions.\n- Utilize native kubectl and trivy commands for Kubernetes cluster access and security vulnerability scanning.\n- Access the web and perform Google searches without leaving the terminal.\n\n## Install\n\n### Run in Kubernetes\n\n**Option 1: Web UI with Helm (recommended)**\n\n```sh\n# Option 1: OpenAI\nexport OPENAI_API_KEY=\"<replace-this>\"\nhelm install kube-copilot kube-copilot \\\n  --repo https://feisky.xyz/kube-copilot \\\n  --set openai.apiModel=gpt-4 \\\n  --set openai.apiKey=$OPENAI_API_KEY\n\n# Option 2: Azure OpenAI Service\nexport AZURE_OPENAI_API_KEY=\"<replace-this>\"\nexport AZURE_OPENAI_ENDPOINT=\"<replace-this>\"\nhelm install kube-copilot kube-copilot \\\n  --repo https://feisky.xyz/kube-copilot \\\n  --set openai.apiModel=gpt-4 \\\n  --set openai.apiKey=$AZURE_OPENAI_API_KEY \\\n  --set openai.apiBase=$AZURE_OPENAI_ENDPOINT\n\n# Forwarding requests to the service\nkubectl port-forward service/kube-copilot 8080:80\necho \"Visit http://127.0.0.1:8080 to use the copilot\"\n```\n\n**Option 2: CLI with kubectl**\n\n```sh\nkubectl run -it --rm copilot \\\n  --env=\"OPENAI_API_KEY=$OPENAI_API_KEY\" \\\n  --restart=Never \\\n  --image=ghcr.io/feiskyer/kube-copilot \\\n  -- execute --verbose 'What Pods are using max memory in the cluster'\n\nkubectl run -it --rm copilot \\\n  --env=\"AZURE_OPENAI_API_KEY=$AZURE_OPENAI_API_KEY\" \\\n  --env=\"AZURE_OPENAI_ENDPOINT=$AZURE_OPENAI_ENDPOINT\" \\\n  --restart=Never \\\n  --image=ghcr.io/feiskyer/kube-copilot \\\n  -- execute --verbose 'What Pods are using max memory in the cluster'\n```\n\nRefer [kubernetes.md](kubernetes.md) for more detailed steps.\n\n### Local Install\n\nInstall the copilot with pip command below:\n\n```sh\npip install kube-copilot\n```\n\n**Setup:**\n\n- Ensure [`kubectl`](https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/) is installed on the local machine and the kubeconfig file is configured for Kubernetes cluster access.\n- Install [`trivy`](https://github.com/aquasecurity/trivy) to assess container image security issues (for the `audit` command).\n- Set the OpenAI [API key](https://platform.openai.com/account/api-keys) as the `OPENAI_API_KEY` environment variable to enable ChatGPT functionality.\n  - For [Azure OpenAI service](https://learn.microsoft.com/en-us/azure/cognitive-services/openai/quickstart?tabs=command-line&pivots=rest-api#retrieve-key-and-endpoint), also set `OPENAI_API_TYPE=azure` and `OPENAI_API_BASE=https://<replace-this>.openai.azure.com/`.\n- Google search is disabled by default. To enable it, set `GOOGLE_API_KEY` and `GOOGLE_CSE_ID` (obtain from [here](https://cloud.google.com/docs/authentication/api-keys?visit_id=638154888929258210-4085587461) and [here](http://www.google.com/cse/)).\n\n## How to use web UI\n\n![image-20230707191237629](assets/preview.jpg)\n\n## How to use CLI\n\nRunning directly in the terminal:\n\n```sh\nUsage: kube-copilot [OPTIONS] COMMAND [ARGS]...\n\n  Kubernetes Copilot powered by OpenAI\n\nOptions:\n  --version  Show the version and exit.\n  --help     Show this message and exit.\n\nCommands:\n  analyze   analyze issues for a given resource\n  audit     audit security issues for a Pod\n  diagnose  diagnose problems for a Pod\n  execute   execute operations based on prompt instructions\n  generate  generate Kubernetes manifests\n```\n\n### Audit Security Issues for Pod\n\n`kube-copilot audit POD [NAMESPACE]` will audit security issues for a Pod:\n\n```sh\nUsage: kube-copilot audit [OPTIONS] POD [NAMESPACE]\n\n  audit security issues for a Pod\n\nOptions:\n  --verbose      Enable verbose information of copilot execution steps\n  --model MODEL  OpenAI model to use for copilot execution, default is gpt-4\n  --help         Show this message and exit.\n```\n\n### Diagnose Problems for Pod\n\n`kube-copilot diagnose POD [NAMESPACE]` will diagnose problems for a Pod:\n\n```sh\nUsage: kube-copilot diagnose [OPTIONS] POD [NAMESPACE]\n\n  diagnose problems for a Pod\n\nOptions:\n  --verbose      Enable verbose information of copilot execution steps\n  --model MODEL  OpenAI model to use for copilot execution, default is gpt-4\n  --help         Show this message and exit.\n```\n\n### Analyze Potential Issues for k8s Object\n\n`kube-copilot analyze RESOURCE NAME [NAMESPACE]` will analyze potential issues for the given resource object:\n\n```sh\nUsage: kube-copilot analyze [OPTIONS] RESOURCE NAME [NAMESPACE]\n\n  analyze issues for a given resource\n\nOptions:\n  --verbose     Enable verbose information of copilot execution steps\n  --model TEXT  OpenAI model to use for copilot execution, default is gpt-4\n  --help        Show this message and exit.\n```\n\n### Execute Operations Based on Prompt Instructions\n\n`kube-copilot execute INSTRUCTIONS` will execute operations based on prompt instructions.\nIt could also be used to ask any questions.\n\n```sh\nUsage: kube-copilot execute [OPTIONS] INSTRUCTIONS\n\n  execute operations based on prompt instructions\n\nOptions:\n  --verbose      Enable verbose information of copilot execution steps\n  --model MODEL  OpenAI model to use for copilot execution, default is gpt-4\n  --help         Show this message and exit.\n```\n\n### Generate Kubernetes Manifests\n\nUse the `kube-copilot generate` command to create Kubernetes manifests based on\nthe provided prompt instructions. After generating the manifests, you will be\nprompted to confirm whether you want to apply them.\n\n```sh\nUsage: kube-copilot generate [OPTIONS] INSTRUCTIONS\n\n  generate Kubernetes manifests\n\nOptions:\n  --verbose     Enable verbose information of copilot execution steps\n  --model TEXT  OpenAI model to use for copilot execution, default is gpt-4\n  --help        Show this message and exit.\n```\n\n## Contribution\n\nThe project is opensource at github [feiskyer/kube-copilot](https://github.com/feiskyer/kube-copilot) with Apache License.\n\nIf you would like to contribute to the project, please follow these guidelines:\n\n1. Fork the repository and clone it to your local machine.\n2. Create a new branch for your changes.\n3. Make your changes and commit them with a descriptive commit message.\n4. Push your changes to your forked repository.\n5. Open a pull request to the main repository.\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Kubernetes Copilot",
    "version": "0.1.27",
    "project_urls": {
        "Homepage": "https://github.com/feiskyer/kube-copilot",
        "Repository": "https://github.com/feiskyer/kube-copilot"
    },
    "split_keywords": [
        "kubernetes",
        " copilot",
        " openai",
        " chatgpt"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "07c4239d087dd45bc53c03dc0d3094d14d53653964c4491672ab475a2f618d9e",
                "md5": "ffce7f7013a23bdc9a2680761b7178d5",
                "sha256": "a9a118617ac0f516a2bd85853fed67d4951a7b51f98e849b62ba04cd751d7bcb"
            },
            "downloads": -1,
            "filename": "kube_copilot-0.1.27-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ffce7f7013a23bdc9a2680761b7178d5",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.11",
            "size": 22012,
            "upload_time": "2024-05-06T09:22:46",
            "upload_time_iso_8601": "2024-05-06T09:22:46.743519Z",
            "url": "https://files.pythonhosted.org/packages/07/c4/239d087dd45bc53c03dc0d3094d14d53653964c4491672ab475a2f618d9e/kube_copilot-0.1.27-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "d264f91a44022a22c20e93598380ca34650f5f8600d21c25987cd402cdbc472e",
                "md5": "53a58ca49516480acbdd677ebdcec98d",
                "sha256": "c9497e5f13b43200284c7a2f73bd9ebd89aa470adab21056eb1672d72dd527dd"
            },
            "downloads": -1,
            "filename": "kube_copilot-0.1.27.tar.gz",
            "has_sig": false,
            "md5_digest": "53a58ca49516480acbdd677ebdcec98d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.11",
            "size": 20776,
            "upload_time": "2024-05-06T09:22:49",
            "upload_time_iso_8601": "2024-05-06T09:22:49.007153Z",
            "url": "https://files.pythonhosted.org/packages/d2/64/f91a44022a22c20e93598380ca34650f5f8600d21c25987cd402cdbc472e/kube_copilot-0.1.27.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-06 09:22:49",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "feiskyer",
    "github_project": "kube-copilot",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "kube-copilot"
}
        
Elapsed time: 0.25800s