GKE Workload Identity Analyzer
This script takes a Pod name (running in the current context) and performs checks to ensure that Workload Identity is properly configured.
Performed checks
- Workload Identity enabled on the GKE cluster
- Pod has
.spec.serviceAccountNameconfigured - KSA (configured in previous step) exists
- KSA is annotated correctly with a GSA
- GSA (configured in previous step) exists in the project
- KSA has
roles/iam.workloadIdentityUseron the GSA - GSA IAM roles in the project
Prerequisites
gcloudcli installed and configured- Application Default Credentials generated using gcloud
kubectlinstalled and configured with cluster access- current kubectl context pointing to the relevant cluster
- python 3 and pip installed
- if running from source, python requirements installed:
pip install -r requirements.txt
Installation
This package is published to PyPI and can be installed using pip:
pip install wi-analyzer
Necessary project access
The script can be run by a user with the Viewer role in the project.
Alternatively, the user will need enough GKE cluster access to read Pods and ServiceAccounts, plus the following IAM permissions:
- container.clusters.get
- iam.serviceAccounts.get
- iam.serviceAccounts.getIamPolicy
- resourcemanager.projects.getIamPolicy
If the GSA is in a different GCP project than the GKE cluster, you'll need the last 3 permissions on that project instead.
Using the tool
$ wi-analyzer --help
usage: wi-analyzer [-h] [-n NAMESPACE] [-d] pod
GKE Workload Identity Analyzer
positional arguments:
pod Kubernetes Pod name to check
options:
-h, --help show this help message and exit
-n NAMESPACE, --namespace NAMESPACE
Kubernetes Namespace to run in
-p PROJECT, --project PROJECT
GCP Project holding the cluster
-l LOCATION, --location LOCATION
The GCP location of the cluster
-c CLUSTER, --cluster CLUSTER
The name of the cluster
-d, --debug Enable debug logging
Configure your current context to point at the cluster where the workload is running.
Either configure the relevant namespace for the current context or pass the namespace name using the -n flag.
Pass a pod name to check - it can be part of a Deployment, Job, StatefulSet, etc, but it has to be running already.
TODO
- Support Fleet Workload Identity (GKE WI for Anthos)
Metadata
Release files for wi-analyzer 0.1.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| wi-analyzer-0.1.3.tar.gz | 10.6 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| wi_analyzer-0.1.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 19.1 kB
Release files / wi-analyzer-0.1.3.tar.gz
| Download URL | wi-analyzer-0.1.3.tar.gz |
|---|---|
| Size | 10.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
14b82a539a9b9fcefd875c6b96f5c2b2693d8f219a8f05feb8176e87346a3fa4
|
|
BLAKE2b-256 checksum How to use checksums |
f508bfa018b03095e7ba1c489cf346a7e1121275d5b81df164b1ac75821aa02c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Release files / wi_analyzer-0.1.3-py3-none-any.whl
| Download URL | wi_analyzer-0.1.3-py3-none-any.whl |
|---|---|
| Size | 8.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
084bec9ff140b2b632bad0c60ee4640fbb4ad101a1091601465da618ad058927
|
|
BLAKE2b-256 checksum How to use checksums |
0c22f2743c3bbc862662807c17dc46a2d0f2cb21b992221a2e8d5590b4a29049
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.10.9
|
Security for wi-analyzer 0.1.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.