DevZero Logo
DevZero

GKE (Google Kubernetes Engine)

Connecting to GCP Kubernetes Engine from a DevZero workspace.

Architecture Diagram

GCP GKE Architecture

Prerequisites

Existing GKE Cluster

Step 1: Accessing GKE Cluster from a DevBox

  1. Go to your DevBox and install Gcloud SDK:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg curl
sudo apt-get update && sudo apt-get install google-cloud-cli
  1. Authenticate your GCP account with Gcloud SDK:
gcloud init
  1. Download the kubectl binaries:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
  1. Install kubectl:
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
  1. Connect to the cluster:
gcloud container clusters get-credentials <cluster-name> --zone <zone-name> --project <project-name>
  1. Check if the cluster is accessible:
kubectl get svc

GCP GKE -> Devbox

New GKE Cluster

Step 1: Creating a GKE Cluster

  1. Go to Kubernetes Engine > Kubernetes Cluster > Create.
  2. Select the standard Cluster, enter the name of the cluster and assign a Regional location where your Private Subnet is located.
  3. Click on Next. In the Node Pool > Default Pool > Nodes > Configure node settings section, choose the desired Machine Configuration for the nodes.
  4. Go to Cluster > Networking and select the Network VPC along with the Private Subnet for the cluster. Choose Private cluster in the IPv4 network access and uncheck the Access control plane using its external IP address checkbox.
  5. Enter a desired Default pod address range and service address range. Here we have taken 192.168.0.0/16 and 192.169.0.0/16 for pod address range and service address range repectively.

GCP GKE Setup

  1. Enter the Bastion Host's CIDR Range in the Authorized Networks section.

GCP GKE Networking Setup

  1. Click on Create.

GCP GKE Setup Overview

Step 2: Installing the necessary tools

  1. Go to your DevBox and install Gcloud SDK:
sudo apt-get update
sudo apt-get install apt-transport-https ca-certificates gnupg curl
sudo apt-get update && sudo apt-get install google-cloud-cli
  1. Authenticate your GCP account with Gcloud SDK:
gcloud init
  1. Download kubectl binaries:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
  1. Install kubectl:
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

Step 3: Accessing the GKE Cluster

  1. Connect to the cluster:
gcloud container clusters get-credentials <cluster-name> --zone <zone-name> --project <project-name>
  1. Check if the cluster is accessible:
kubectl get svc

GCP GKE -> Devbox

On this page