Google Kubernetes Engine (GKE) Quick Start on CLI

Google Cloud provides a nice quickstart guide for GKE:

https://cloud.google.com/kubernetes-engine/docs/quickstart


This post follows the steps on CLI.

You need to install gcloud & kubectl as a pre-requisite.


# enable GKE

% gcloud services enable container.googleapis.com

% gcloud services list | grep -i 'kube'

container.googleapis.com          Kubernetes Engine API

# config gcloud

% gcloud config set project YOUR_PROJECT_ID

% gcloud config set compute/zone us-west1-a

% gcloud config set compute/region us-west1

# create cluster (few minutes)

% gcloud container clusters create hello-cluster --num-nodes=1

% gcloud container clusters list

NAME           LOCATION    MASTER_VERSION   MASTER_IP     MACHINE_TYPE  NODE_VERSION     NUM_NODES  STATUS

hello-cluster  us-west1-a  1.18.17-gke.100  35.230.17.63  e2-medium     1.18.17-gke.100  1          RUNNING

# get credentials

% gcloud container clusters get-credentials hello-cluster

# deploy

% kubectl create deployment hello-server --image=gcr.io/google-samples/hello-app:1.0

% kubectl get deploy

NAME           READY   UP-TO-DATE   AVAILABLE   AGE

hello-server   1/1     1            1           7s

# create LB (few minutes)

% kubectl expose deployment hello-server --type LoadBalancer --port 80 --target-port 8080

% kubectl get service hello-server

NAME           TYPE           CLUSTER-IP      EXTERNAL-IP      PORT(S)        AGE

hello-server   LoadBalancer   10.115.254.75   34.105.110.107   80:30448/TCP   56s

# access

% curl http://34.105.110.107/

Hello, world!

Version: 1.0.0

Hostname: hello-server-57684579f-pdbk9

# delete LB (needed to avoid incurring charges)

% kubectl delete service hello-server

service "hello-server" deleted

# delete cluster (few minutes)

% gcloud container clusters delete hello-cluster


Comments

Popular posts from this blog

Selenide: Quick Start

Minikube Installation for M1 Mac

Server Testing Tools: Serverspec, InSpec, Testinfra, Goss