Skip to content

Commit 2eccfcf

Browse files
authored
fix: working documentation for running with docker (#429)
1 parent e2b5758 commit 2eccfcf

File tree

3 files changed

+57
-12
lines changed

3 files changed

+57
-12
lines changed

CONTAINER.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# 1. Build the Docker Image
2+
3+
First, clone the `kubectl-ai` repository and build the Docker image from the source code.
4+
5+
```bash
6+
git clone https://github.com/GoogleCloudPlatform/kubectl-ai.git
7+
cd kubectl-ai
8+
docker build -t kubectl-ai:latest -f images/kubectl-ai/Dockerfile .
9+
```
10+
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**.
13+
14+
## Create Google Cloud Credentials
15+
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.
17+
18+
```bash
19+
gcloud auth application-default login
20+
```
21+
22+
This command saves your credentials into the `~/.config/gcloud` directory.
23+
24+
## Configure `kubectl`
25+
26+
Next, generate the `kubeconfig` file. This file tells `kubectl` which cluster to connect to and to use your ADC credentials for authentication.
27+
28+
```bash
29+
gcloud container clusters get-credentials <cluster-name> --location <location>
30+
```
31+
32+
This updates the configuration file at `~/.kube/config`.
33+
34+
# 3. Running the Container
35+
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.
38+
39+
```bash
40+
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
42+
```
43+
44+
Alternativley with the default terminal ui:
45+
46+
```bash
47+
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
49+
```

README.md

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -311,26 +311,22 @@ docker build -t kubectl-ai:latest -f images/kubectl-ai/Dockerfile .
311311
```
312312

313313
#### Step 2: Connect to Your GKE Cluster
314-
Grab credentails for your cluster using the following commands
314+
Set up application default credentials and connect to your GKE cluster.
315315
```bash
316-
gcloud auth login
316+
gcloud auth application-default login # If in a gcloud shell this is not necessary
317317
gcloud container clusters get-credentials <cluster-name> --zone <zone>
318318
```
319319

320320
#### Step 3: Run the kubectl-ai container
321-
Below is a sample command that can be used to launch the container with a locally hosted web-ui. Be sure to replace the placeholder values with your specific Google Cloud project ID and location.
321+
Below is a sample command that can be used to launch the container with a locally hosted web-ui. Be sure to replace the placeholder values with your specific Google Cloud project ID and location. Note you
322+
do not need to mount the gcloud config directory if you're on a cloudshell machine.
322323

323324
```bash
324-
docker run --rm -it \
325-
-p 8080:8080 \
326-
-v ~/.kube:/root/.kube:ro \
327-
-v ~/.config/gcloud:/root/.config/gcloud
328-
kubectl-ai:latest \
329-
--llm-provider vertexai \
330-
--ui-listen-address 0.0.0.0:8080 \
331-
--ui-type web
325+
docker run --rm -it -p 8080:8080 -v ~/.kube:/root/.kube -v ~/.config/gcloud:/root/.config/gcloud -e GOOGLE_CLOUD_LOCATION=us-central1 -e GOOGLE_CLOUD_PROJECT=my-gcp-project kubectl-ai:latest --llm-provider vertexai --ui-listen-address 0.0.0.0:8080 --ui-type web
332326
```
333327

328+
For more info about running from the container image see [CONTAINER.md](CONTAINER.md)
329+
334330
## MCP Client Mode
335331

336332
> **Note:** MCP Client Mode is available in `kubectl-ai` version v0.0.12 and onwards.

images/kubectl-ai/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
ARG GO_VERSION="1.24.3"
22
ARG GCLOUD_CLI_VERSION="530.0.0-stable"
33

4-
FROM golang:${GO_VERSION}-bookworm as builder
4+
FROM golang:${GO_VERSION}-bookworm AS builder
55

66
WORKDIR /src
77
COPY go.mod go.sum ./

0 commit comments

Comments
 (0)