Skip to content

Latest commit

 

History

History

gcp

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 

Deploy Kubernetes in Google Cloud Platform

Prerequisites

Prerequisites for Kubernetes

kubectl

Use the Kubernetes command-line tool, kubectl, to deploy and manage applications on Kubernetes. Using kubectl, you can inspect cluster resources; create, delete, and update components; and look at your new cluster and bring up example apps.

More information and systems in kubernetes.io / Install and Set Up kubectl

kubectl setup on Linux
curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
sudo install -m 755 -o root -g root kubectl /usr/local/bin
kubectl setup on Mac

Using Homebrew package manager.

brew install kubectl
kubectl setup on Windows
Install-Script -Name install-kubectl -Scope CurrentUser -Force
install-kubectl.ps1

Prerequisites for Google Cloud Platform

To run the lab, you will need the gcloud cli and a GCP project with Billing and GKE API enabled.

Google Cloud SDK

Cloud SDK runs on Linux, Mac OS X, and Windows. It requires Python 2.7.x and doesn't currently support Python 3. Some tools bundled with Cloud SDK have additional requirements.

Google Cloud SDK setup for Linux or Mac
curl -sq https://sdk.cloud.google.com | bash; exec -l $SHELL
Google Cloud SDK setup for Windows

Download the Cloud SDK installer signed by Google Inc.

More information and systems in Installing Google Cloud SDK.

Managed Kubernetes with Google Kubernetes Engine (GKE)

Configure gcloud CLI

Login into Google Cloud Platform

gcloud auth login

Create new project for this lab (or use an existing one)

gcloud projects create rael-k8s-talks --name 'Project for the GKE cluster'
gcloud projects list

Enable billing for the project (if needed)

The project should have billing active, set it up from the gcloud cli using:

gcloud beta billing accounts list
gcloud beta billing projects link rael-k8s-talks --billing-account 0X0X0X-0X0X0X-0X0X0X

Enable Container API for the project

In Google Cloud Platform is necessary to enable the service APIs needed for each project.

gcloud services enable container

Select the project

gcloud config set project

Select the region

It's always recommended to deploy on the nearest region to the user.

gcloud config set compute/zone asia-northeast1-a

The list of available region can be found at cloud.google.com / Regions and Zones.

Create the GKE Cluster

gcloud container clusters create k8s-gke \
    --enable-autoscaling \
    --min-nodes 2 \
    --max-nodes 5 \
    --enable-ip-alias \
    --machine-type n1-standard-1

Configure kubectl

Configure GKE Kubectl context

gcloud container clusters get-credentials k8s-gke

Get information from the Kubernetes cluster

kubectl cluster-info
kubectl get cs