kubetwo 0.4.0

Creator: railscoder56

Last updated:

Add to Cart

Description:

kubetwo 0.4.0

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.

Python (3.6 and newer)
Terraform (1.0.0 and newer)

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

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Customer Reviews

There are no reviews.