Skip to main content

Fetch AKS kubeconfig and merge into ~/.kube/config by alias

Project description

azaks-conn

Fetch AKS kubeconfig and merge into ~/.kube/config by alias

Install

pip install azaks-conn

The package installs two console scripts that point at the same Typer app:

Command Use when
azaks-conn Long form, friendly for scripts
aksc Short alias for interactive shell use

Usage

aksc --help
aksc --version

Four commands cover the alias lifecycle:

Command Purpose
aksc connect CLUSTER [--alias NAME] [--resource-group RG] [--subscription SUB] [--admin] [--overwrite] Fetch AKS credentials and merge into ~/.kube/config under the given alias.
aksc list Rich-table inventory of aksc-managed aliases (with provenance metadata).
aksc verify ALIAS [--timeout N] Probe the alias's API server via kubectl cluster-info.
aksc rm ALIAS [--force] Remove the alias from ~/.kube/config, the snapshot directory, and the state file.

State lives in two places under ~/.kube/azaks-conn/:

  • <alias> — a single-context kubeconfig snapshot for each managed alias (mode 0600).
  • .aliases.json — JSON metadata (cluster, RG, subscription, admin flag, timestamp), used by list and verify.

Security model

aksc connect shells out to az aks get-credentials. By default this fetches an Entra ID (AAD) integrated kubeconfig: actual authentication still flows through kubelogin and your Azure identity, and cluster RBAC applies.

The --admin flag passes through to az aks get-credentials --admin, which returns a cluster-admin certificate in the kubeconfig. This bypasses Entra ID and RBAC entirely — anyone with the file is cluster-admin until the certificate expires (typically months).

aksc makes admin contexts visually obvious so they aren't accidentally shared, committed, or left lying around:

  • aksc connect --admin prints a yellow warning: line citing the bypass.
  • aksc list flags the alias with a red ADMIN marker in the Admin column.
  • aksc verify <admin-alias> reprints the warning after each probe.
  • Both the merged entry in ~/.kube/config and the per-alias snapshot under ~/.kube/azaks-conn/ are written with mode 0600.

Guidance:

  • Prefer the default (AAD) flow whenever possible.
  • Only use --admin for cluster bootstrap / break-glass work.
  • Treat any --admin kubeconfig as a high-privilege secret — do not check it into source control, share it over chat, or copy it to shared hosts.
  • aksc rm <admin-alias> is the fastest way to revoke local access; for full revocation, rotate the cluster admin credentials in Azure.

Development

git clone https://github.com/NaeemH/azaks-conn.git
cd azaks-conn
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
pre-commit install

# Run the standard checks
ruff check . && ruff format --check .
mypy src
pytest -q

Release

Releases are tag-driven. Bump src/azaks_conn/__about__.py, commit, then:

git tag v0.2.1
git push origin v0.2.1

.github/workflows/release.yml builds the sdist + wheel and publishes to PyPI via Trusted Publishers (OIDC) — no API tokens involved.

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

azaks_conn-0.2.1.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

azaks_conn-0.2.1-py3-none-any.whl (15.8 kB view details)

Uploaded Python 3

File details

Details for the file azaks_conn-0.2.1.tar.gz.

File metadata

  • Download URL: azaks_conn-0.2.1.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for azaks_conn-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a5068f8795f42dd8542720355b28bc8b489d7bdedacba72fe6fae338b1907160
MD5 ab45c5cd2ba44ff429cb315b212d9beb
BLAKE2b-256 9b881fbc47276cb442a1bead1d1f5bf7d1c9c97bc441535ce9516a608251ebae

See more details on using hashes here.

Provenance

The following attestation bundles were made for azaks_conn-0.2.1.tar.gz:

Publisher: release.yml on NaeemH/azaks-conn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file azaks_conn-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: azaks_conn-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 15.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for azaks_conn-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5583dd8e46b7cda32a2abb3bbf7853bb04429faed7989ae51e65acc7b33960cd
MD5 7aa5acc5921721aefaeee385952b0f71
BLAKE2b-256 447017da2c325ea34dd185773ab26fa9d4d551fa8739940369d6eaeb34c39913

See more details on using hashes here.

Provenance

The following attestation bundles were made for azaks_conn-0.2.1-py3-none-any.whl:

Publisher: release.yml on NaeemH/azaks-conn

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page