Skip to main content

H Y P E R K U B E - A secure Serverless API and kubectl plugin that stores and retrieve Kubernetes cluster credentials. Hyperkube leverages AWS Secrets Manager for storing credential information.

Project description

hyper-kube-config

Python Tests

PyPI version

hyper-kube-config - Provides a secure Serverless API to store and retrieve Kubernetes cluster config credentials. hyper-kube-config leverages AWS Secrets Manager for storing credential information. Included is a kubectl plugin to interface with hyperkube API.

You can also set cluster's status and retrieve this information. Useful in CI/CD pipelines when trying to pull access to particular cluters without needing to know their names, just their environments.

It requires a configuration file. See hyperkube-config.yaml.example for layout.

hyper-kube-config

Install hyperkube kubectl plugin

pip3 install hyper-kube-config 

Setup ~/hyperkube-config.yaml file

The default locations for the config file is ~/hyperkube-config.yaml. You can also place the config file at a different location and pass the location as a command line option -c <hyper-kube-config-location> or --config <hyper-kube-config-location>

Post cluster and creds to hyperkube store

kubectl hyperkube add --k8s-config ~/.kube/config

Remove cluster and creds

kubectl hyperkube remove --cluster-to-remove 'k8s-cluster-example.cloud' 

Get user creds and merge it with existing ~/.kube/config

# for single cluster
kubectl hyperkube get --cluster cloud-infra.cloud -m

Get user creds multiple clusters and merge them with existing ~/.kube/config

kubectl hyperkube get \
  --cluster cloud-infra.cloud \
  --cluster bar-cluster.cloud \
  --cluster baz-cluster.com -m

Get creds for all clusters and merge it with existing ~/.kube/config

kubectl hyperkube get-all -m

List clusters

kubectl hyperkube list

Store and Associate SSH PEM and CA private key with Cluster

Store SSH Pem

kubectl hyperkube add-pem --pem ~/.ssh/my-cluster.pem 

Get Stored SSH Pem

kubectl hyperkube get-pem --cluster my-cluster.net

Store Add CA Private Key

kubectl hyperkube add-ca-key --ca-key ca-key-file.key --cluser my-cluster.net

Set Cluster Status and/or Environment References

# Set arbitrary status string and environment reference for given cluster
kubectl hyperkube set-cluster-status --cluster my-cluster.net --status active --environment stage

Get Cluster Status for Environment

# Returns list of clusters that are active for prod environment
kubectl hyperkube get-cluster-status --status active --environment prod

Requirements

  • Serverless - Serverless Framework
  • serverless-python-requirements plugin. Uses Docker and Pip to package a newer vesion of Boto3 for AWS Lambda function use. AWS Lambda boto3 version by default doesn't have AWS Secrets Manager support for tags.
  • click - for hyperkube kubectl plugin
  • kubectl - version 1.12 or higher recommended for stable plugin support.

Deploying Serverless API

Choose authentication method

API Key

Example Serverless Config for API Key Authentication

This config should work out of the box. Feel free to copy to serverless.yml and deploy

IAM Authentication

Example Serverless Config for IAM Authentication

This configuration will require you to add IAM roles to the allowed principal section. These roles are managed outside the scope of this project.

See the section that has:

  resourcePolicy:
    - Effect: Allow
      Principal:
        AWS:
          - arn:aws:iam::{{otherAWSAccountID}}:root
          - arn:aws:iam::{{otherAWSAccountID}}:user/{{otherAWSUserName}}
          - arn:aws:iam::{{otherAWSAccountID}}:role/{{otherAWSRoleName}}

replace with your roles you would like to grant access.

sls deployment
pipenv install
pipenv shell
sls deploy \
  --stage dev \
  --product k8s \
  --owner myteam@foo.cloud \
  --team myteam \
  --environment dev

This will launch your hyperkube API. Capture the API URL, api key and stage for your hyperkube.yaml configuration. The kubectl hyperkube commands will leverage the config to interact with your stored k8s configs.

Serverless will launch an AWS API Gateway to handle API requests forwardered to AWS Lambda functions. A Dynamodb table is configured to store non-senstative cluster config details, while sensative information in uploaded configs (passwords and certs) is stored in AWS Secrets Manager.

Testing for lint errors on your local machine

  1. Install Test Dependencies
pip install -U -r tests/requirements.txt
  1. Run flake8 to check for lint errors
flake8 *.py tests cli/kubectl-hyperkube
  1. Run unit tests
python -m unittest discover -s tests/ -p "*.py"

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

hyper-kube-config-0.6.2.tar.gz (8.9 kB view details)

Uploaded Source

File details

Details for the file hyper-kube-config-0.6.2.tar.gz.

File metadata

  • Download URL: hyper-kube-config-0.6.2.tar.gz
  • Upload date:
  • Size: 8.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.3.0 pkginfo/1.7.0 requests/2.25.1 setuptools/49.2.1 requests-toolbelt/0.9.1 tqdm/4.57.0 CPython/3.9.1

File hashes

Hashes for hyper-kube-config-0.6.2.tar.gz
Algorithm Hash digest
SHA256 938aab6a622c3fe9a3194e12faf09fbb8b373bb1ba21d951717254453cb4c324
MD5 e57c1d2974b5c0f51fc1b3cd8f8c171a
BLAKE2b-256 e85c6163ba329b07fea777e7fa3ad5a86b5d3da214665725aaefe0f02690ce33

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