Skip to main content

kubetwo

kubetwo is a simple CLI tool to create Kubernetes clusters on AWS EC2 with just one command.

kubetwo will interact with Terraform and Ansible (Kubespray) for provisioning.

Requirements

To use kubetwo, following tools are necessary.

Quick Start

1. Prerequisites

First, please install kubetwo package using pip or pip3 depending on your environment.

pip install kubetwo

For kubetwo to interact with Terraform, it's necessary to set environment variables about AWS credentials.

export AWS_ACCESS_KEY_ID="your_anaccesskey"
export AWS_SECRET_ACCESS_KEY="your_asecretkey"
export AWS_DEFAULT_REGION="your_region"

Then, you need to create SSH key without password for Ansible to access the EC2.

ssh-keygen -t rsa -b 4096 -f ~/.ssh/kubetwo_id_rsa

Then set these SSH keys as environment variables.

export SSH_PUBLIC_KEY_PATH="~/.ssh/kubetwo_id_rsa.pub"
export SSH_PRIVATE_KEY_PATH="~/.ssh/kubetwo_id_rsa"

2 Spin up Kubernetes cluster

By running the following kubetwo create command, kubetwo will spin up AWS EC2 with Terraform and set up Kubernetes cluster with Ansible (Kubespray v2.16.0).

kubetwo create --cluster-name kubetwo-cluster

3. Access to the Kubernetes cluster

After the Kubernetes cluster is created, you can see admin.conf in the workspace. Setting KUBECONFIG will allow you to access the Kubernetes cluster.

export KUBECONFIG=$(pwd)/kubetwo_cluster/admin.conf

Let's check the Kubernetes cluster from your local machine. (If you don't have kubectl, please install it)

kubectl get nodes

4. Clean up

You can clean up newly created resources with kubetwo delete command. It will also delete workspace of kubetwo on your machine.

kubetwo delete --cluster-name kubetwo-cluster

Commands

kubetwo create

It will spin up AWS EC2 and create Kubernetes cluster.

Parameters

Name Type Default Description
cluster-name string - Kubernetes cluster name
ami string ami-0c3fd0f5d33134a76 Amazon Machine Image of EC2 instance
instance-type string t3.medium Instance type of EC2 instance
control-plane int 1 Number of control planes
worker-node int 1 Number of worker nodes
open-ports string 80,443 Worker node ports to open for global (-1 will open all ports)
approve boolean false If true, kubetwo won't prompt you to approve for execution

Example

kubetwo create \
--cluster-name kubetwo-cluster \
--control-plane 1 \
--worker-node 1 \
--open-ports 80,443

kubetwo scale

It will scale in/out worker nodes in Kubernetes cluster.

Parameters

Name Type Default Description
cluster-name string - Kubernetes cluster name
worker-node int - Number of worker nodes
approve boolean false If true, kubetwo won't prompt you to approve for execution

Example

kubetwo scale --cluster-name kubetwo-cluster --worker-node 2

kubetwo delete

It will remove newly created AWS resources and Kubernetes cluster. And also clean up the workspace of kubetwo on local machine.

Parameters

Name Type Default Description
cluster-name string - Kubernetes cluster name
approve boolean false If true, kubetwo won't prompt you to approve for execution

Example

kubetwo delete --cluster-name kubetwo-cluster

Release files for kubetwo 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kubetwo 0.4.0
File Size Uploaded
kubetwo-0.4.0.tar.gz 21.6 kB Details

Release files / kubetwo-0.4.0.tar.gz

Download URL kubetwo-0.4.0.tar.gz
Size 21.6 kB
Tags Source
SHA-256 checksum
How to use checksums
c46477ed844c981290114578f938453160b89b902d231f68bb0e376ab197232d
BLAKE2b-256 checksum
How to use checksums
57fa5eb9dfd9aabaa60d6374dbb03ff632885b2c7572ebc41f703dbd0ea71835
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.12

Release history Release notifications | RSS feed

This release

0.4.0 This release

1 release file

0.3.0

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page