|
1 | | -# 1. Build the Docker Image |
| 1 | +# Running kubectl-ai in a Docker Container |
2 | 2 |
|
3 | | -First, clone the `kubectl-ai` repository and build the Docker image from the source code. |
| 3 | +## 1. Build the Docker Image |
| 4 | + |
| 5 | +First, clone the `kubectl-ai` repository and build the Docker image from the |
| 6 | +source code. |
4 | 7 |
|
5 | 8 | ```bash |
6 | 9 | git clone https://github.com/GoogleCloudPlatform/kubectl-ai.git |
7 | 10 | cd kubectl-ai |
8 | 11 | docker build -t kubectl-ai:latest -f images/kubectl-ai/Dockerfile . |
9 | 12 | ``` |
10 | 13 |
|
11 | | -# 2. Running against a GKE cluster |
12 | | -To access a GKE cluster, `kubectl-ai` needs two configurations from your local machine: **Google Cloud credentials** and a **Kubernetes config file**. |
| 14 | +## 2. Running against a GKE cluster |
| 15 | + |
| 16 | +To access a GKE cluster, `kubectl-ai` needs two configurations from your local |
| 17 | +machine: **Google Cloud credentials** and a **Kubernetes config file**. |
13 | 18 |
|
14 | | -## Create Google Cloud Credentials |
| 19 | +### Create Google Cloud Credentials |
15 | 20 |
|
16 | | -First, create Application Default Credentials [(ADC)](https://cloud.google.com/docs/authentication/application-default-credentials). `kubectl` uses these credentials to authenticate with your GKE cluster. |
| 21 | +First, create Application Default Credentials |
| 22 | +[(ADC)](https://cloud.google.com/docs/authentication/application-default-credentials). |
| 23 | +`kubectl` uses these credentials to authenticate with your GKE cluster. |
17 | 24 |
|
18 | 25 | ```bash |
19 | 26 | gcloud auth application-default login |
20 | 27 | ``` |
21 | 28 |
|
22 | 29 | This command saves your credentials into the `~/.config/gcloud` directory. |
23 | 30 |
|
24 | | -## Configure `kubectl` |
| 31 | +### Configure `kubectl` |
25 | 32 |
|
26 | | -Next, generate the `kubeconfig` file. This file tells `kubectl` which cluster to connect to and to use your ADC credentials for authentication. |
| 33 | +Next, generate the `kubeconfig` file. This file tells `kubectl` which cluster |
| 34 | +to connect to and to use your ADC credentials for authentication. |
27 | 35 |
|
28 | 36 | ```bash |
29 | 37 | gcloud container clusters get-credentials <cluster-name> --location <location> |
30 | 38 | ``` |
31 | 39 |
|
32 | 40 | This updates the configuration file at `~/.kube/config`. |
33 | 41 |
|
34 | | -# 3. Running the Container |
| 42 | +## 3. Running the Container |
35 | 43 |
|
36 | | -Finally, mount both configuration directories into the `kubectl-ai` container when you run it. |
37 | | -This example shows how to run `kubectl-ai` with a web interface, mounting all necessary credentials and providing a Gemini API key. |
| 44 | +Finally, mount both configuration directories into the `kubectl-ai` container |
| 45 | +when you run it. This example shows how to run `kubectl-ai` with a web |
| 46 | +interface, mounting all necessary credentials and providing a Gemini API key. |
38 | 47 |
|
39 | 48 | ```bash |
40 | 49 | export GEMINI_API_KEY="your_api_key_here" |
41 | | -docker run --rm -it -p 8080:8080 -v ~/.kube:/root/.kube -v ~/.config/gcloud:/root/.config/gcloud -e GEMINI_API_KEY kubectl-ai:latest --ui-listen-address 0.0.0.0:8080 --ui-type web |
| 50 | +docker run --rm -it -p 8080:8080 \ |
| 51 | + -v ~/.kube:/root/.kube \ |
| 52 | + -v ~/.config/gcloud:/root/.config/gcloud \ |
| 53 | + -e GEMINI_API_KEY \ |
| 54 | + kubectl-ai:latest \ |
| 55 | + --ui-listen-address 0.0.0.0:8080 \ |
| 56 | + --ui-type web |
42 | 57 | ``` |
43 | 58 |
|
44 | | -Alternativley with the default terminal ui: |
| 59 | +Alternatively with the default terminal ui: |
45 | 60 |
|
46 | 61 | ```bash |
47 | 62 | export GEMINI_API_KEY="your_api_key_here" |
48 | | -docker run --rm -it -v ~/.kube:/root/.kube -v ~/.config/gcloud:/root/.config/gcloud -e GEMINI_API_KEY kubectl-ai:latest |
| 63 | +docker run --rm -it \ |
| 64 | + -v ~/.kube:/root/.kube \ |
| 65 | + -v ~/.config/gcloud:/root/.config/gcloud \ |
| 66 | + -e GEMINI_API_KEY \ |
| 67 | + kubectl-ai:latest |
49 | 68 | ``` |
0 commit comments