ISSUE-200: Replace oc with kubectl for standard Kubernetes operations#205
Conversation
oc is only needed for OpenShift-specific subcommands (oc adm release info/new, oc adm policy). For standard Kubernetes operations like get nodes/pods, kubectl is sufficient and avoids an unnecessary dependency on the OpenShift CLI in this upstream/OKD project. Also removes the unnecessary kubectl-to-oc symlink in the DEB install script. The symlink was a workaround for scripts that used oc for standard Kubernetes operations on Debian where oc is not available. Now that those scripts use kubectl directly, the workaround is no longer needed. Closes microshift-io#200 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> pre-commit.check-secrets: ENABLED
0649cd7 to
59a8797
Compare
📝 WalkthroughWalkthroughReplaced usages of the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai perform full review |
|
✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/cluster_manager.sh (1)
388-388: Add--kubeconfigsocluster_statusreliably works.kubectl looks for a config file in
$HOME/.kubeby default; withoutKUBECONFIGset or--kubeconfigpassed, it falls back to~/.kube/config.podman exec -idoesn't source profile scripts, so if~/.kube/configdoesn't exist inside the container this silently falls through to"Unable to retrieve cluster status"every time. The MicroShift kubeconfig at/var/lib/microshift/resources/kubeadmin/kubeconfigis guaranteed present once the service is ready (per project learnings) and is the right path for cluster-wide queries — pass it explicitly.🛠️ Suggested fix
- sudo podman exec -i "${first_container}" kubectl get nodes,pods -A -o wide 2>/dev/null || echo "Unable to retrieve cluster status" + sudo podman exec -i "${first_container}" kubectl get nodes,pods -A -o wide \ + --kubeconfig /var/lib/microshift/resources/kubeadmin/kubeconfig 2>/dev/null || echo "Unable to retrieve cluster status"Based on learnings: "the file
/var/lib/microshift/resources/kubeadmin/kubeconfig(without a node name) is guaranteed to exist if MicroShift has started and is ready … This generic kubeconfig path is appropriate for cluster-wide operations like querying cluster status."🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/cluster_manager.sh` at line 388, The kubectl invocation inside the podman exec (the line using "${first_container}" that runs kubectl get nodes,pods -A -o wide) should explicitly pass --kubeconfig /var/lib/microshift/resources/kubeadmin/kubeconfig so it doesn't rely on ~/.kube/config inside the container; update that command to include the --kubeconfig flag pointing to that path and keep the existing stderr redirection and fallback echo unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@src/quickstart.sh`:
- Line 110: The printed kubectl hint currently omits a kubeconfig, so running
the suggested command inside the podman exec will fail; update the echo in
quickstart.sh that prints "sudo podman exec -it microshift-okd kubectl get pods
-A" to include either the explicit kubeconfig flag (e.g., --kubeconfig
/var/lib/microshift/resources/kubeadmin/kubeconfig) or mention exporting
KUBECONFIG before the podman exec; modify the echo string (the one producing the
kubectl hint) so it includes the chosen kubeconfig approach to ensure kubectl
can find the cluster credentials.
---
Nitpick comments:
In `@src/cluster_manager.sh`:
- Line 388: The kubectl invocation inside the podman exec (the line using
"${first_container}" that runs kubectl get nodes,pods -A -o wide) should
explicitly pass --kubeconfig /var/lib/microshift/resources/kubeadmin/kubeconfig
so it doesn't rely on ~/.kube/config inside the container; update that command
to include the --kubeconfig flag pointing to that path and keep the existing
stderr redirection and fallback echo unchanged.
Summary
ocwithkubectlfor standard Kubernetes operations (get nodes,get pods -A) across scripts and documentationoconly where OpenShift-specific subcommands are required (oc adm release info/new,oc adm policy add-scc-to-group)Changed files
src/cluster_manager.shoc get nodes,pods→kubectl get nodes,podssrc/quickrpm.shoc get pods -A→kubectl get pods -A(usage text)src/quickstart.shoc get pods -A→kubectl get pods -A(usage text)docs/run-bootc.mdoc get nodes/pods→kubectl get nodes/podsdocs/run.mdoc get pods -A→kubectl get pods -A(2 occurrences)src/etcd/README.mdoc get nodes/pods→kubectl get nodes/pods(2 occurrences)Unchanged (OpenShift-specific, no kubectl equivalent)
src/image/prebuild.sh—oc adm release infosrc/okd/build_images.sh—oc adm release new,oc adm release infosrc/cncf/run_sonobuoy_tests.sh—oc adm policy add-scc-to-groupsrc/deb/install.sh—kubectl → ocsymlink (still needed for build-timeoc admcommands)Test plan
shellcheckpasses on modified scriptskubectlcommands work inside bootc container (kubectlis bundled with MicroShift)Closes #200
🤖 Generated with Claude Code
Summary by CodeRabbit
Documentation
Chores