Multiple GCP K8s Clusters under a different GCP project

Scenarios is described as this:

We have one GCP root account, which creating 2 projects, one is as a lab, the other one is as production. The lab one has only 1 Kubernetes cluster, which is deployed in single location(region) europe-west2-a, with 3 node zones europe-west2-a/b/c. The production one has 3 Kubernetes cluster, deployed in 3 different locations(regions), i.e. europe-west1, us-central1, asia-southeast1. Within every region, there are 3 available zones (node zones), like europe-west1-a/b/c.

Tutorial to follow

To switch the context:

  1. Config local gcloud to proper project, and region ```bash

    Checking current config

    gcloud config list

Setting proper project id

gcloud config set project $PROJECT_ID

Setting default region, i.e europe-west1

gcloud config set compute/region $REGION

Setting default compute zone, i.e europe-west1-a

gcloud config set compute/zone $COMPUTE_ZONE

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2. Setup Kubernetes Cluster 
```bash
# Install or Update kubectl CLI
gcloud components install/update kubectl

# Checking if any existing Kubernetes cluster
gcloud container clusters list

# To Create a new one, if none is interesting
gcloud container clusters create $CLUSTER_NAME

# Getting authentication credentials for any cluster you want in local context
gcloud container clusters get-credentials $CLUSTER_NAME

# Now you can switch contexts
kubectl config get-contexts

kubectl config use-context $WHATEVER_AVAILABLE_CONTEXT
  1. Kubernetes default Namespace change ```bash

    Checking all available namespaces

    kubectl get namespaces

Update default namespace

kubectl config set-context $(kubectl config current-context) –namespace=$APP_NAMESPACE ```

comments powered by Disqus