Skip to content

Instantly share code, notes, and snippets.

@jiraguha
Created July 2, 2020 09:52
Show Gist options
  • Save jiraguha/0e295fb7e0fce843d0662ea3ed54ca3c to your computer and use it in GitHub Desktop.
Save jiraguha/0e295fb7e0fce843d0662ea3ed54ca3c to your computer and use it in GitHub Desktop.
kubernetes on google cloud

Kubernetes on google cloud

Install google cloud cli

Find more here: Utiliser le programme d’installation du SDK Google Cloud

# On mac
curl https://sdk.cloud.google.com | bash

Set up google cloud

Find more here: Guide de démarrage rapide  |  Documentation Kubernetes Engine

Login

gcloud init

Project

gcloud config set project <project-id>

Zone

gcloud config set compute/zone <compute-zone>

The cluster

Create it

gcloud container clusters create <cluster-name> --num-nodes=1

Log in the cluster

gcloud container clusters get-credentials <cluster-name>

Managing context

kubectl config get-contexts
kubectl config use-context <context-name>

Managing namespaces

# list all namespaces
kubectl get namespaces
# current namespace
kubectl config view --minify | grep namespace:
# switch namespace
kubectl config set-context --current --namespace=<namespace>

Find more here Aide-mémoire kubectl | Kubernetes

Deploy a workload

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

Delete

# list first
gcloud container clusters
# delete it
gcloud container clusters delete cluster-name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment