Skip to content

ISSUE-200: Replace oc with kubectl for standard Kubernetes operations#205

Merged
ggiguash merged 1 commit into
microshift-io:mainfrom
agullon:replace-oc-with-kubectl
Feb 19, 2026
Merged

ISSUE-200: Replace oc with kubectl for standard Kubernetes operations#205
ggiguash merged 1 commit into
microshift-io:mainfrom
agullon:replace-oc-with-kubectl

Conversation

@agullon
Copy link
Copy Markdown
Contributor

@agullon agullon commented Feb 18, 2026

Summary

  • Replace oc with kubectl for standard Kubernetes operations (get nodes, get pods -A) across scripts and documentation
  • Keep oc only where OpenShift-specific subcommands are required (oc adm release info/new, oc adm policy add-scc-to-group)
  • Reduces unnecessary dependency on the OpenShift CLI for this upstream/OKD project

Changed files

File Change
src/cluster_manager.sh oc get nodes,podskubectl get nodes,pods
src/quickrpm.sh oc get pods -Akubectl get pods -A (usage text)
src/quickstart.sh oc get pods -Akubectl get pods -A (usage text)
docs/run-bootc.md oc get nodes/podskubectl get nodes/pods
docs/run.md oc get pods -Akubectl get pods -A (2 occurrences)
src/etcd/README.md oc get nodes/podskubectl get nodes/pods (2 occurrences)

Unchanged (OpenShift-specific, no kubectl equivalent)

  • src/image/prebuild.shoc adm release info
  • src/okd/build_images.shoc adm release new, oc adm release info
  • src/cncf/run_sonobuoy_tests.shoc adm policy add-scc-to-group
  • src/deb/install.shkubectl → oc symlink (still needed for build-time oc adm commands)

Test plan

  • Verify shellcheck passes on modified scripts
  • Verify kubectl commands work inside bootc container (kubectl is bundled with MicroShift)
  • Verify documentation instructions are accurate

Closes #200

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Documentation

    • Updated verification examples and README snippets to use kubectl for node and pod checks.
  • Chores

    • Adjusted installation and cluster status instructions to reference kubectl instead of oc across scripts and utilities.

@agullon agullon requested a review from a team as a code owner February 18, 2026 15:19
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
@agullon agullon force-pushed the replace-oc-with-kubectl branch from 0649cd7 to 59a8797 Compare February 18, 2026 15:23
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 18, 2026

📝 Walkthrough

Walkthrough

Replaced usages of the oc CLI with kubectl for standard Kubernetes operations in documentation and runtime scripts; removed the kubectl -> oc symlink creation from the DEB installer. OpenShift-specific oc subcommands were not changed.

Changes

Cohort / File(s) Summary
Documentation
docs/run-bootc.md, docs/run.md, src/etcd/README.md
Replaced oc with kubectl in verification examples (get nodes, get pods -A).
Runtime scripts & user messages
src/cluster_manager.sh, src/quickrpm.sh, src/quickstart.sh
Updated commands and printed verification instructions from oc to kubectl (cluster status and pods listings).
Installation
src/deb/install.sh
Removed creation of a symlink that aliased kubectl to oc in the installer.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: replacing oc with kubectl for standard Kubernetes operations across the codebase.
Linked Issues check ✅ Passed The PR comprehensively addresses all coding requirements from #200: replaced oc with kubectl in all specified files, removed the symlink from install.sh, and preserved oc for OpenShift-specific subcommands.
Out of Scope Changes check ✅ Passed All changes are directly scoped to #200 objectives. Modified files are exclusively those listed for oc-to-kubectl replacement with no unrelated alterations present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ggiguash
Copy link
Copy Markdown
Contributor

@coderabbitai perform full review

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Feb 19, 2026

@ggiguash I'll perform a full review of the changes in this PR.

✅ Actions performed

Full review triggered.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
src/cluster_manager.sh (1)

388-388: Add --kubeconfig so cluster_status reliably works.

kubectl looks for a config file in $HOME/.kube by default; without KUBECONFIG set or --kubeconfig passed, it falls back to ~/.kube/config. podman exec -i doesn't source profile scripts, so if ~/.kube/config doesn'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/kubeconfig is 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.

Comment thread src/quickstart.sh
@ggiguash ggiguash merged commit e7a126b into microshift-io:main Feb 19, 2026
17 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Replace oc with kubectl for standard Kubernetes operations

2 participants