Skip to content

Commit 899b2b7

Browse files
committed
update: odh-cli across code base
- update Makefile for the final image - update README with usage and image Signed-off-by: Wen Zhou <wenzhou@redhat.com>
1 parent 7d65e7f commit 899b2b7

File tree

5 files changed

+135
-95
lines changed

5 files changed

+135
-95
lines changed

Dockerfile

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,34 +67,22 @@ RUN python3 -m pip install --no-cache-dir \
6767
'kubernetes>=28.1.0' \
6868
'PyYAML>=6.0'
6969

70-
# Install kubectl with multi-arch support (latest stable version)
71-
RUN set -e; \
72-
ARCH=${TARGETARCH:-amd64}; \
73-
case "$ARCH" in \
74-
amd64) KUBE_ARCH="amd64" ;; \
75-
arm64) KUBE_ARCH="arm64" ;; \
76-
*) echo "Unsupported architecture: $ARCH" >&2; exit 1 ;; \
77-
esac; \
78-
echo "Installing kubectl for architecture: $KUBE_ARCH"; \
79-
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/${KUBE_ARCH}/kubectl"; \
80-
chmod +x kubectl; \
81-
mv kubectl /usr/local/bin/kubectl
82-
83-
# Install OpenShift CLI (oc) with multi-arch support (stable version)
70+
# Install OpenShift CLI (oc) and kubectl with multi-arch support
8471
RUN set -e; \
8572
ARCH=${TARGETARCH:-amd64}; \
8673
case "$ARCH" in \
8774
amd64) OC_ARCH="amd64" ;; \
8875
arm64) OC_ARCH="arm64" ;; \
8976
*) echo "Unsupported architecture: $ARCH" >&2; exit 1 ;; \
9077
esac; \
91-
echo "Installing oc for architecture: $OC_ARCH"; \
78+
echo "Installing oc and kubectl for architecture: $OC_ARCH"; \
9279
curl -fsSL -o openshift-client.tar.gz \
93-
"https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable-4.17/openshift-client-linux-${OC_ARCH}-rhel9.tar.gz"; \
80+
"https://mirror.openshift.com/pub/openshift-v4/clients/ocp/stable-4.19/openshift-client-linux-${OC_ARCH}-rhel9.tar.gz"; \
9481
tar -xzf openshift-client.tar.gz; \
95-
chmod +x oc; \
82+
chmod +x oc kubectl; \
9683
mv oc /usr/local/bin/oc; \
97-
rm -f openshift-client.tar.gz kubectl README.md
84+
mv kubectl /usr/local/bin/kubectl; \
85+
rm -f openshift-client.tar.gz README.md
9886

9987
# Install yq with multi-arch support (stable version)
10088
RUN set -e; \
@@ -111,18 +99,19 @@ RUN set -e; \
11199
chmod +x /usr/local/bin/yq
112100

113101
# Copy binary from builder (cross-compiled for target platform)
114-
COPY --from=builder /workspace/bin/kubectl-odh /opt/rhai-cli/bin/rhai-cli
102+
COPY --from=builder /workspace/bin/odh-cli /opt/odh-cli/bin/odh-cli
115103

116-
# Add rhai-cli to PATH
117-
ENV PATH="/opt/rhai-cli/bin:${PATH}"
104+
# Add odh-cli to PATH
105+
ENV PATH="/opt/odh-cli/bin:${PATH}"
118106

119107
# Copy upgrade helpers from builder
120108
COPY --from=builder /opt/rhai-upgrade-helpers /opt/rhai-upgrade-helpers
121109

122110
# Create backup directory for upgrade artifacts (world-writable with sticky bit
123111
# so arbitrary UIDs can create subdirectories without permission errors)
112+
# This is path is created by https://github.com/red-hat-data-services/rhoai-upgrade-helpers
124113
RUN mkdir -p /tmp/rhoai-upgrade-backup && chmod 1777 /tmp/rhoai-upgrade-backup
125114

126-
# Set entrypoint to rhai-cli binary
115+
# Set entrypoint to odh-cli binary
127116
# Users can override with --entrypoint /bin/bash for interactive debugging
128-
ENTRYPOINT ["/opt/rhai-cli/bin/rhai-cli"]
117+
ENTRYPOINT ["/opt/odh-cli/bin/odh-cli"]

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# kubectl-odh CLI Makefile
1+
# odh-cli Makefile
22

33
# Binary name
4-
BINARY_NAME=bin/kubectl-odh
4+
BINARY_NAME=bin/odh-cli
55

66
# Version information
77
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
@@ -18,7 +18,7 @@ LINT_TIMEOUT := 10m
1818

1919
# Container registry configuration
2020
CONTAINER_REGISTRY ?= quay.io
21-
CONTAINER_REPO ?= $(CONTAINER_REGISTRY)/rhoai/rhoai-upgrade-helpers-rhel9
21+
CONTAINER_REPO ?= $(CONTAINER_REGISTRY)/opendatahub-io/odh-cli-rhel9
2222
CONTAINER_PLATFORMS ?= linux/amd64,linux/arm64
2323
CONTAINER_TAGS ?= $(VERSION)
2424

@@ -122,7 +122,7 @@ publish: build-image
122122
.PHONY: help
123123
help:
124124
@echo "Available targets:"
125-
@echo " build - Build the kubectl-odh binary"
125+
@echo " build - Build the odh-cli binary"
126126
@echo " build-image - Build container image without pushing (creates local manifest)"
127127
@echo " publish - Build and push container image using Podman manifest"
128128
@echo " run - Run the doctor command"

README.md

Lines changed: 117 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,113 +1,165 @@
11
# odh-cli
22

3-
CLI tool for RHOAI (Red Hat OpenShift AI) for interacting with RHOAI deployments on Kubernetes.
3+
CLI tool for ODH/RHOAI (Red Hat OpenShift AI) for interacting with ODH/RHOAI deployments on Kubernetes.
4+
5+
## Available Subcommands
6+
7+
- **`odh-cli lint`** - Validate cluster configuration and assess upgrade readiness
8+
- **`odh-cli version`** - Display CLI version information
49

510
## Quick Start
611

712
### Using Containers
813

9-
Run the CLI using the pre-built container image:
14+
Run the CLI using the pre-built container image. Set your container runtime (podman or docker):
1015

11-
**Podman:**
1216
```bash
13-
podman run --rm -ti \
14-
-v $KUBECONFIG:/kubeconfig \
15-
quay.io/rhoai/rhoai-upgrade-helpers-rhel9:dev lint --target-version 3.3.0
16-
```
17+
# Use podman or docker
18+
CONTAINER_TOOL=podman # or 'docker'
1719

18-
**Docker:**
19-
```bash
20-
docker run --rm -ti \
20+
# Run lint command
21+
$CONTAINER_TOOL run --rm -ti \
2122
-v $KUBECONFIG:/kubeconfig \
22-
quay.io/rhoai/rhoai-upgrade-helpers-rhel9:dev lint --target-version 3.3.0
23+
quay.io/rhoai/odh-cli-rhel9:dev lint --target-version 3.3.0
2324
```
2425

2526
The container has `KUBECONFIG=/kubeconfig` set by default, so you just need to mount your kubeconfig to that path.
2627

27-
> **SELinux:** On systems with SELinux enabled (Fedora, RHEL, CentOS), add `:Z` to the volume mount:
28+
> **Note:** If `KUBECONFIG` is not set, use the default path:
2829
> ```bash
29-
> # Podman
30-
> podman run --rm -ti \
30+
> $CONTAINER_TOOL run --rm -ti \
31+
> -v ~/.kube/config:/kubeconfig \
32+
> quay.io/rhoai/odh-cli-rhel9:dev lint --target-version 3.3.0
33+
> ```
34+
35+
> **SELinux:** On SELinux systems (Fedora, RHEL, CentOS), add `:Z` to volume mounts:
36+
> ```bash
37+
> # With KUBECONFIG set
38+
> $CONTAINER_TOOL run --rm -ti \
3139
> -v $KUBECONFIG:/kubeconfig:Z \
32-
> quay.io/rhoai/rhoai-upgrade-helpers-rhel9:dev lint --target-version 3.3.0
40+
> quay.io/rhoai/odh-cli-rhel9:dev lint --target-version 3.3.0
3341
>
34-
> # Docker
35-
> docker run --rm -ti \
36-
> -v $KUBECONFIG:/kubeconfig:Z \
37-
> quay.io/rhoai/rhoai-upgrade-helpers-rhel9:dev lint --target-version 3.3.0
42+
> # With default kubeconfig path
43+
> $CONTAINER_TOOL run --rm -ti \
44+
> -v ~/.kube/config:/kubeconfig:Z \
45+
> quay.io/rhoai/odh-cli-rhel9:dev lint --target-version 3.3.0
3846
> ```
3947
48+
**Working with Multiple Clusters:**
49+
50+
If your kubeconfig contains multiple cluster contexts, the CLI uses the `current-context`. You have two options:
51+
52+
**Option 1: Switch context before running (Recommended)**
53+
54+
```bash
55+
# Switch to desired cluster
56+
kubectl config use-context <context-name>
57+
58+
# Run the CLI (uses new context-name)
59+
$CONTAINER_TOOL run --rm -ti \
60+
-v ~/.kube/config:/kubeconfig \
61+
quay.io/rhoai/odh-cli-rhel9:dev lint --target-version 3.3.0
62+
```
63+
64+
**Option 2: Set context with --context flag**
65+
66+
```bash
67+
$CONTAINER_TOOL run --rm -ti \
68+
-v ~/.kube/config:/kubeconfig:Z \
69+
quay.io/rhoai/odh-cli-rhel9:dev lint --target-version 3.3.0 \
70+
--context <context-name>
71+
```
72+
4073
**Available Tags:**
41-
- `:latest` - Latest stable release
42-
- `:dev` - Latest development build from main branch (updated on every push)
43-
- `:vX.Y.Z` - Specific version (e.g., `:v1.2.3`)
74+
- `:dev` - Latest development build from main branch
75+
- `:rhoai-X.Y-ea.Z` - Specific version (e.g., `:rhoai-3.4-ea.1`)
4476

45-
> **Note:** The images are OCI-compliant and work with both Podman and Docker. Examples for both are provided below.
77+
> **Note:** The images are OCI-compliant and work with both Podman and Docker.
4678
47-
**Shell Access:**
79+
**Interactive Shell Access:**
4880

49-
The container also bundles migration tools and CLI utilities that can be used directly from a shell session:
81+
For interactive debugging and running upgrade helper scripts:
5082

51-
**Podman:**
83+
**Step 1: Login to cluster (on your host)**
5284
```bash
53-
podman run -it --rm \
54-
-v $KUBECONFIG:/kubeconfig \
55-
--entrypoint /bin/bash \
56-
quay.io/rhoai/rhoai-upgrade-helpers-rhel9:dev
85+
# Login on your cluster which should update ~/.kube/config
86+
oc login --token=sha256~xxxx --server=https://api.my-cluster.example.com:6443
5787
```
5888

59-
**Docker:**
89+
**Step 2: Shell into container**
6090
```bash
61-
docker run -it --rm \
62-
-v $KUBECONFIG:/kubeconfig \
91+
# Mount the kubeconfig that was created by oc login
92+
$CONTAINER_TOOL run -it --rm \
93+
-v ~/.kube/config:/kubeconfig \
6394
--entrypoint /bin/bash \
64-
quay.io/rhoai/rhoai-upgrade-helpers-rhel9:dev
95+
quay.io/rhoai/odh-cli-rhel9:dev
6596
```
6697

98+
**Step 3: Inside container - you're already authenticated**
99+
67100
Available tools:
68-
- `rhai-cli`
69-
- `kubectl` (latest stable)
70-
- `oc` (latest stable)
71-
- `jq`
72-
- `wget`
73-
- `curl`
74-
- `tar`
75-
- `gzip`
76-
- `bash`
77-
78-
Example usage:
79-
```bash
80-
oc login --token=sha256~xxxx --server=https://api.my-cluster.p3.openshiftapps.com:6443
101+
- `odh-cli` - The CLI tool (at `/opt/odh-cli/bin/odh-cli`)
102+
- `kubectl` / `oc` - Kubernetes/OpenShift client tools from OCP 4.19
103+
- Upgrade helper scripts at `/opt/rhai-upgrade-helpers`
104+
- Standard utilities: `jq`, `yq`, `python3`, `wget`, `curl`, `tar`, `gzip`, `bash`
81105

82-
kubectl get pods -n opendatahub
106+
Example workflow:
107+
```bash
108+
# Verify connection
83109
oc get dsci
84110

85-
rhai-cli lint --target-version 3.3.0
111+
# Run lint command
112+
odh-cli lint --target-version 3.3.0
113+
114+
# Example: Run upgrade helper script
115+
cd /opt/rhai-upgrade-helpers
116+
./ray/ray_cluster_migration.py backup
86117
```
87118

88-
The `rhai-cli` binary is located at `/opt/rhai-cli/bin/rhai-cli` (already on `PATH`).
89-
Upgrade helper scripts are located at `/opt/rhai-upgrade-helpers`.
119+
**Using Upgrade Helper Scripts:**
90120

91-
**Token Authentication:**
121+
The lint command identifies upgrade issues and provides remediation steps that reference upgrade helper scripts. Follow this workflow:
92122

93-
For environments where you have a token and server URL instead of a kubeconfig file:
123+
**Step 1: Run lint to identify issues**
124+
```bash
125+
$CONTAINER_TOOL run --rm -ti \
126+
-v ~/.kube/config:/kubeconfig \
127+
quay.io/rhoai/odh-cli-rhel9:dev lint --target-version 3.3.0
128+
```
94129

95-
**Podman:**
130+
**Step 2: Review remediation guidance**
131+
132+
Lint output shows which helper scripts to run:
133+
```
134+
CHECK: Ray workloads migration
135+
REMEDIATION: Run ray_cluster_migration.py from rhoai-upgrade-helpers repository
136+
```
137+
138+
**Step 3: Run helper scripts in shell mode**
139+
140+
Shell into the container with backup directory mounted:
96141
```bash
97-
podman run --rm -ti \
98-
quay.io/rhoai/rhoai-upgrade-helpers-rhel9:dev \
99-
lint \
100-
--target-version 3.3.0 \
101-
--token=sha256~xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \
102-
--server=https://api.my-cluster.p3.openshiftapps.com:6443
142+
$CONTAINER_TOOL run -it --rm \
143+
-v ~/.kube/config:/kubeconfig:Z \
144+
-v ./backup:/tmp/rhoai-upgrade-backup:Z \
145+
--entrypoint /bin/bash quay.io/rhoai/odh-cli-rhel9:dev
146+
147+
# Inside container - run the recommended script
148+
cd /opt/rhai-upgrade-helpers
149+
./ray/ray_cluster_migration.py backup
150+
./trustyai/backup-metrics.sh
103151
```
104152

105-
**Docker:**
153+
Scripts write backups to `/tmp/rhoai-upgrade-backup/<component>/` which persists to `./backup/` on your localhost via the volume mount.
154+
155+
**Token Authentication:**
156+
157+
For environments with token and server URL (no kubeconfig file):
158+
106159
```bash
107-
docker run --rm -ti \
108-
quay.io/rhoai/rhoai-upgrade-helpers-rhel9:dev \
109-
lint \
110-
--target-version 3.3.0 \
160+
$CONTAINER_TOOL run --rm -ti \
161+
quay.io/rhoai/odh-cli-rhel9:dev \
162+
lint --target-version 3.3.0 \
111163
--token=sha256~xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx \
112164
--server=https://api.my-cluster.p3.openshiftapps.com:6443
113165
```
@@ -120,4 +172,3 @@ For detailed documentation, see:
120172
- [Development Guide](docs/development.md)
121173
- [Lint Architecture](docs/lint/architecture.md)
122174
- [Writing Lint Checks](docs/lint/writing-checks.md)
123-

cmd/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ func main() {
1515
flags := genericclioptions.NewConfigFlags(true).WithDeprecatedPasswordFlag()
1616

1717
cmd := &cobra.Command{
18-
Use: "kubectl-odh",
18+
Use: "odh-cli",
1919
Short: "kubectl plugin for ODH/RHOAI",
2020
}
2121

cmd/version/version.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ func AddCommand(root *cobra.Command, _ *genericclioptions.ConfigFlags) {
4444
default:
4545
_, err := fmt.Fprintf(
4646
cmd.OutOrStdout(),
47-
"kubectl-odh version %s (commit: %s, built: %s)\n",
47+
"odh-cli version %s (commit: %s, built: %s)\n",
4848
version.GetVersion(),
4949
version.GetCommit(),
5050
version.GetDate(),

0 commit comments

Comments
 (0)