DEV Community

Cover image for Create an EKS or GKE cluster in minutes
jdxlabs
jdxlabs

Posted on • Updated on

Create an EKS or GKE cluster in minutes

It is very easy to create a Kubernetes cluster nowadays. I wanted to share some convenient commands to create a cluster on your favorite Cloud provider (AWS or GCP).

Compared to creating it through the interface, the advantage of command lines is that you can reproduce it quickly and automate it.

Create an EKS cluster (on AWS)

First, you have to create an AWS account and install the AWS cli.

Here are the commands to create the cluster :

brew install eksctl
eksctl --help
eksctl create cluster --name eks1 --region eu-west-1 --nodes 1
Enter fullscreen mode Exit fullscreen mode

then delete it :

eksctl delete cluster --name eks1 --region eu-west-1
Enter fullscreen mode Exit fullscreen mode

Create a GKE cluster (on Google Cloud)

First, you need to create a Google Cloud account and follow these steps to install the client :

brew install gcloud
gcloud init

# Also install the plugin to authenticate with GKE :
gcloud components install gke-gcloud-auth-plugin
Enter fullscreen mode Exit fullscreen mode

Here are the commands to create the cluster :
(Autopilot is easier to manage but VMs allow more configuration and reduce costs)

# Option 1 : GKE on VMs :
gcloud container clusters create gke1 \
    --num-nodes=1 \
    --zone europe-west1-b \  # Specify 1 zone to have only 1 node in total
    --project=<myproject>

# Option 2 : GKE with Autopilot :
gcloud container clusters create-auto gke1 \
    --region europe-west1 \
    --project=<myproject>
Enter fullscreen mode Exit fullscreen mode

then delete it :

gcloud container clusters delete gke1 \
    --region europe-west1 [--zone europe-west1-b] \
    --project=<myproject>
Enter fullscreen mode Exit fullscreen mode

Be careful to delete the cluster when you are not using it, because it is not free, you must follow the billing section of your service provider according to the configuration you have requested.

Note that GKE in minimal configuration is cheaper than the EKS solution, and consider the price just for a day or two for example.

Anyway, with these commands, you will have clusters similar to production conditions where you can work on.

If you just want a little tool to work locally on Kubernetes, you can use a tool like Kind.

Top comments (0)