Simple CLI tool to create Kubernetes cluster on AWS EC2.
Project description
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
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
File details
Details for the file kubetwo-0.4.0.tar.gz
.
File metadata
- Download URL: kubetwo-0.4.0.tar.gz
- Upload date:
- Size: 21.6 kB
- Tags: Source
- Uploaded using 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
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c46477ed844c981290114578f938453160b89b902d231f68bb0e376ab197232d |
|
MD5 | d93b4e62fe29688f58c1edc7e23883a6 |
|
BLAKE2b-256 | 57fa5eb9dfd9aabaa60d6374dbb03ff632885b2c7572ebc41f703dbd0ea71835 |