Skip to main content

A utility to generate kubeconfig for AKS clusters in bulk across one or multiple subscriptions

Project description

akskubeconfig

A utility to generate a kubeconfig file for all AKS clusters in one or more Azure subscriptions.

Why

Managing and updating a Kubernetes configuration file for AKS clusters can be a nightmare when you manage multiple clusters across multiple subscriptions. This tool aims to simplify the process by generating a kubeconfig file for all AKS clusters that you have access to in all subscriptions that you have access to.

While checking all subscriptions is default behavior, you can also specify a list of subscriptions to check. This can be useful if you have access to a large number of subscriptions and only want to check a subset of them.

It also supports generating that kubeconfig file using a number of different authentication flows, including:

  • Default (using the default authentication flow)
  • Device Flow (using the device flow authentication flow)
  • Interactive (using the interactive web browser authentication flow)
  • Service Principal Secret (using a service principal secret to authenticate)
  • Service Principal PFX (using a service principal pfx certificate to authenticate)
  • Managed Identity (using a managed identity to authenticate)
  • Managed Identity ID (using a managed identity to authenticate)
  • Azure CLI (using the Azure CLI to authenticate)
  • Workload Identity (using a workload identity to authenticate)

This can be useful for a number of reasons, such as generating a bulk kubeconfig file on-the-fly for CI/CD pipelines, or for generating a kubeconfig file for a specific cluster in a specific subscription.

Installation

akskubeconfig is implemented in Python. Assuming you have a Python interpreter and pip installed you should be able to install with:

pip install akskubeconfig

This has not yet been widely tested and is currently in a works on my machine state.

Usage

The simplest usage is to just run the tool and specify an output file for it to write to:

akskubeconfig -o ~/.kube/config

This will generate a set of schemas in a schemas directory. The tool provides a number of options to modify the output:

akskubeconfig --help
usage: akskubeconfig [-h] [-v] [-s SUBSCRIPTIONS] [--client-id CLIENT_ID] [--tenant-id TENANT_ID] [--client-secret CLIENT_SECRET] [--certificate-path CERTIFICATE_PATH] [--server-id SERVER_ID]
                     [--environment ENVIRONMENT] [--default | --device-flow | --interactive | --sp-secret | --sp-pfx | --managed-identity | --managed-identity-id | --az-cli | --workload-identity]
                     [--json | --yaml] [-m MAX_THREADS] [-o OUTFILE] [--cluster-name CLUSTER_NAME]

options:
  -h, --help            show this help message and exit
  -v, --verbose         Increase output verbosity
  -s, --subscriptions SUBSCRIPTIONS
                        A comma separated list of subscription to use. If omitted, all subscriptions will be checked.
  --client-id CLIENT_ID
                        Override the client id to write into the kubeconfig. Only applicable if required by the selected authentication flow.
  --tenant-id TENANT_ID
                        Override the tenant id to write into the kubeconfig. Only applicable if required by the selected authentication flow.
  --client-secret CLIENT_SECRET
                        Override the client secret to write into the kubeconfig. Only applicable if required by the selected authentication flow.
  --certificate-path CERTIFICATE_PATH
                        Override the certificate path to write into the kubeconfig. Only applicable if required by the selected authentication flow.
  --server-id SERVER_ID
                        Override the server id to write into the kubeconfig.
  --environment ENVIRONMENT
                        Override the environment to write into the kubeconfig.
  --default             Use the default flow authenticate within the generated kubeconfig (default)
  --device-flow         Use device flow to authenticate within the generated kubeconfig
  --interactive         Use the interactive web browser flow to authenticate within the generated kubeconfig
  --sp-secret           Use a service principal secret to authenticate within the generated kubeconfig
  --sp-pfx              Use a service principal pfx certificate to authenticate within the generated kubeconfig
  --managed-identity    Use a managed identity to authenticate within the generated kubeconfig
  --managed-identity-id
                        Use a managed identity to authenticate within the generated kubeconfig
  --az-cli              Use the Azure CLI to authenticate within the generated kubeconfig
  --workload-identity   Use a workload identity to authenticate within the generated kubeconfig
  --json                Output as JSON
  --yaml                Output as YAML (default)
  -m, --max-threads MAX_THREADS
                        Maximum number of threads to use
  -o, --outfile OUTFILE
                        Output file
  --cluster-name CLUSTER_NAME
                        Name of the specific cluster to target (required when using --specific-cluster)

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

akskubeconfig-1.0.40.tar.gz (20.7 kB view details)

Uploaded Source

Built Distribution

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

akskubeconfig-1.0.40-py3-none-any.whl (23.6 kB view details)

Uploaded Python 3

File details

Details for the file akskubeconfig-1.0.40.tar.gz.

File metadata

  • Download URL: akskubeconfig-1.0.40.tar.gz
  • Upload date:
  • Size: 20.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.7 Linux/5.15.0-1092-azure

File hashes

Hashes for akskubeconfig-1.0.40.tar.gz
Algorithm Hash digest
SHA256 c5b0888a01bff999d7f805de3a0bf96b973c87e2464614acd3570fdbf4539856
MD5 3f6a3cfba9ff5b68c183d9fe48fc2c29
BLAKE2b-256 9e911b5bcc8b2bc6592682309295891599fddd56c8d00e3c7fdbfa87e3372c02

See more details on using hashes here.

File details

Details for the file akskubeconfig-1.0.40-py3-none-any.whl.

File metadata

  • Download URL: akskubeconfig-1.0.40-py3-none-any.whl
  • Upload date:
  • Size: 23.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.4 CPython/3.13.7 Linux/5.15.0-1092-azure

File hashes

Hashes for akskubeconfig-1.0.40-py3-none-any.whl
Algorithm Hash digest
SHA256 7a029f0fe380286371e49500b0590cdc4a5324eb4a96ed5157758a3c9952f02d
MD5 550dc81c665234f53db3d3acbb8e7a8d
BLAKE2b-256 474dc8bb497e1dec58444ca9aadea07c5760c1e7d145ace7000634a0eed36d67

See more details on using hashes here.

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