Setup Google GKE

Here you find helpful scripts to set up & access GKE on Google Cloud:

  • create-gke.sh: Create a GKE cluster demo-gke with 4 nodes and application level secrets encryption

  • access-gke.sh: Add entry to Kubectl config to access the GKE cluster demo-gke (if you have created the cluster via UI and not via script)

  • install-prometheus.sh: Install Prometheus Operator using Helm 3

  • update-gke-pod-security.sh: Enable Pod Security Policies on the GKE cluster demo-gke

  • delete-gke.sh: Delete the GKE cluster demo-gke

Prerequisites

You need:

  • a valid account to access Google Cloud and be able to use the Google API for creating a GKE cluster.

  • installed google cloud cli (see https://cloud.google.com/sdk/docs/install for details)

  • installed gke plugin for kubectl (just perform gcloud components install gke-gcloud-auth-plugin after you have installed the Google cloud cli)

Login to Google Cloud

You need an account on Google Cloud, and you have to log in to your account via

gcloud auth login

before executing any script here.

Create GKE cluster

NOTE: Please open and edit the file create-gke.sh before executing and change the project to your own one first.

Now you can run create-gke.sh to create a GKE cluster.

After running create-gke.sh script wait until you see the final running status line (similar to this one):

NAME      LOCATION        MASTER_VERSION  MASTER_IP       MACHINE_TYPE   NODE_VERSION  NUM_NODES  STATUS
demo-gke  europe-west3-a  1.15.9-gke.8    35.242.252.226  n1-standard-2  1.15.9-gke.8  4          RUNNING

Get access to the cluster

After successfully creating the cluster you can access the cluster by running access-gke.sh.

You may need to install the gke plugin for kubectl by performing gcloud components install gke-gcloud-auth-plugin

Install Prometheus Operator and Grafana for Monitoring

You may also install Prometheus Operator for monitoring the cluster using install-prometheus.sh script. Please make sure you have installed Helm 3.x before executing this script.

After running the script you can access the Grafana web page by navigating to localhost:3000. Login credentials are: admin/prom-operator.

There are predefined dashboards under Manage Dashboards. Interesting ones are:

  1. USE Method / Cluster

  2. Use Method / Node

  3. Kubernetes / Compute Resources / Pod

When you select the one for the cluster it looks like the following image.

Grafana

Delete GKE cluster again

After playing around with the GKE cluster and running all demos you can delete the cluster using the script delete-gke.sh again to save money.

Last updated

Was this helpful?