Skip to main content

No project description provided

Project description

PyPI version License: MIT

tokeks

A zero-dependency Python library for getting the Kubernetes token of a AWS EKS cluster.

No AWS CLI, third-party client or library (boto3, botocore, etc.) required.

Installation

pip install tokeks

Usage prerequisites

Assign your credentials to environment variables:

export AWS_ACCESS_KEY_ID="..."
export AWS_SECRET_ACCESS_KEY="..."

Library usage

from tokeks import Tokeks
tokeks = Tokeks(
    access_key_id=os.environ['AWS_ACCESS_KEY_ID'],
    secret_access_key=os.environ['AWS_SECRET_ACCESS_KEY'],
    region_id='YOUR_REGION_ID',
    cluster_id='YOUR_CLUSTER_ID')
token = tokeks.get_token()

CLI usage

  1. Go to project directory

  2. Run script:

TOKEN=$(./getekstoken us-west-1 cluster-1)
  1. Verify Kubernetes API access:
APISERVER=...
curl -X GET $APISERVER/api --header "Authorization: Bearer $TOKEN" --insecure

If the response is something like:

{
  "kind": "APIVersions", 
  "versions": [
    "v1"
  ],
  "serverAddressByClientCIDRs": [
    {
      "clientCIDR": "0.0.0.0/0",
      "serverAddress": "..."
    }  
  ]
}

(and does not contain "Unauthorized"), you're good to go!

Inspired by:

  1. API Authorization from Outside a Cluster
  2. eks-token

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

tokeks-0.1.1-py3-none-any.whl (4.9 kB view hashes)

Uploaded Python 3

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