Installing ECK with Terraform on GCP

eck-blog-thumb.png

On this page, you will find a how-to spin up ECK using Terraform. The main idea is to have a Kubernetes cluster and ECK installed by running only 3 commands.

Demo

To see the demo, please access https://github.com/framsouza/eck-terraform

Features

Every feature will be deployed via Terraform:

  • Install GKE (Google Kubernetes Engine) cluster
  • It will contain 1 node pool with 3 nodes (One in each zone) running on region europe-west1
  • It contains a helm provider that will be responsible to install the ECK operator
  • Elasticsearch cluster with 3 nodes
  • One Kibana instance

Requirements

Before starting you should have the following commands installed:

Let's play

As you probably know, Terraform is an infrastructure as code tool, which means we can describe our infrastructure desire into a file and apply it via Terraform. Here, we are going to spin up a GKE cluster with 3 nodes running on europe-west1 region. The machines we are going to use is e2-standard-4 which will give us 4vCPU nad 16GB of memory in each node.

First, you have to authenticate into Google Cloud console, to so run the following command,

gcloud auth application-default login

Once you are logged it, you should export 2 variables, the Kubernetes config path and the Google project you are going to use

export KUBE_CONFIG_PATH=~/.kube/config && export GOOGLE_PROJECT=<YOUR-PROJECT-NAME>

Now, you can run

terraform init

It will load the providers and configuration. Right after that, you should run

terraform plan

It will show you everything that will be created by Terraform, take a moment to check this output. Once you are ready, you just need to run:

terraform apply -parallelism=1

It will apply your changes in sequence. Once everything was applied, you will get an output similar to this,

Apply complete! Resources: 7 added, 0 changed, 0 destroyed.

Outputs:

gke_name = "TO CONNECT TO KUBERNETES: gcloud container clusters get-credentials <KUBERNETES-NAME> --region europe-west1 --project <YOUR-PROJECT-NAME>"
kibana_endpoint = "TO CONNECT TO KIBANA: kubectl port-forward svc/<KIBANA-ENDPOINT> 5601:5601"
kubernetes_name = "fram-gke-eck"

Once you port-foward your kibana service, you can easily access it on your browser via localhost.

Wrapping up

Now, to clean up everything you just need to run

terraform destroy

Happy terraform!

Keep learning about ECK: