Skip to main content

GKE Workload Identity Analyzer

Project description

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.serviceAccountName configured
  • 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.workloadIdentityUser on the GSA
  • GSA IAM roles in the project

Prerequisites

  • gcloud cli installed and configured
  • Application Default Credentials generated using gcloud
  • kubectl installed and configured with cluster access
  • current kubectl context pointing to the relevant cluster
  • python 3 and pip installed
  • python requirements installed: pip install -r requirements.txt

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
  -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

  • Add build and release assets

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

wi-analyzer-0.1.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

wi_analyzer-0.1.0-py3-none-any.whl (6.5 kB view details)

Uploaded Python 3

File details

Details for the file wi-analyzer-0.1.0.tar.gz.

File metadata

  • Download URL: wi-analyzer-0.1.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for wi-analyzer-0.1.0.tar.gz
Algorithm Hash digest
SHA256 842084a631be82371dc02a35bcf6f78a51a5e6e976c18a264b27876e139bdefb
MD5 8076b2119691479566666c245412005a
BLAKE2b-256 f8f30b013a35de3497521c3a9f8897669e4193e3f4154e6121a786e3c387767b

See more details on using hashes here.

File details

Details for the file wi_analyzer-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: wi_analyzer-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.10.7

File hashes

Hashes for wi_analyzer-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 044a54efbe8116631a6331c5070241aa91b01ac015376ad7ec847de6f9498bde
MD5 521d36496e971d0fcb74526db5ef817f
BLAKE2b-256 cab6db5c8845c1ad044b043e94b2cabe34f45a5c5b974902e8c40b683bc615af

See more details on using hashes here.

Supported by

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