Skip to content

Comments

Refactor kubeconfig: provider/consumer split, kubeconfig_generator, tests#1457

Open
anniegracehu wants to merge 1 commit intocloud-ark:masterfrom
anniegracehu:annie/provider_kubeconfig
Open

Refactor kubeconfig: provider/consumer split, kubeconfig_generator, tests#1457
anniegracehu wants to merge 1 commit intocloud-ark:masterfrom
anniegracehu:annie/provider_kubeconfig

Conversation

@anniegracehu
Copy link
Collaborator

Summary

Refactors kubeconfig generation with a clear provider/consumer split, adds a new kubeconfig_generator implementation, and introduces tests.

Changes

  • kubeconfig_generator.py – New entry point with provider/consumer RBAC inlined for easier installation
  • kubeconfig_helpers.py – Shared logic (SA creation, token extraction, kubeconfig build)
  • provider-kubeconfig.py – Actually create namespace when missing (was re-running kubectl get ns instead of kubectl create ns)
  • tests/test_kubeconfig_generator.py – Tests for kubeconfig structure, CLI parity, provider/consumer split, and integration equivalence (provider and consumer)

Design

  • provider-kubeconfig.py stays as the main script for backward compatibility
  • kubeconfig_generator.py is the refactored implementation; can be used as an alternative
  • Integration tests run both implementations against a live cluster and compare ClusterRole rules

Testing

python -m unittest tests.test_kubeconfig_generator -v

With cluster (minikube):

KUBECONFIG=~/.kube/config python -m unittest tests.test_kubeconfig_generator -v

- Add kubeconfig_generator.py and kubeconfig_helpers.py
- provider-kubeconfig: fix namespace create bug, add -p permissionfile
- Unit tests for build_kubeconfig_dict, CLI parity, provider/consumer split
- Integration tests for provider and consumer equivalence (skipped without cluster)
get_ns = "kubectl get ns " + namespace + kubeconfigString
out, err = run_command(get_ns)
if 'not found' in (out or '') or 'not found' in (err or ''):
run_command("kubectl create ns " + namespace + kubeconfigString)
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch.

@anniegracehu anniegracehu self-assigned this Feb 17, 2026
@anniegracehu anniegracehu marked this pull request as ready for review February 17, 2026 20:11
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.

2 participants