Home > other >  Why do I see files from another GCP Kubernetes cluster in a different cluster?
Why do I see files from another GCP Kubernetes cluster in a different cluster?

Time:11-15

I am trying to learn Google Cloud and very new to it.

I created 1 project in GCP: project1.

And I created a Kubernetes cluster in project1 with the name p1-cluster1. In this cluster, I click on the Connect button and a terminal is opened on GCP page. I created a new directory with the name development under /home/me. And I have developed a personal project under /home/me/development so that I now have a bunch of code here.

I decided to develop a second personal project. For this purpose, I created a new project with the name project2 in GCP. And then created a new Kubernetes cluster with the name p2-cluster2. And when I connect to this cluster, a terminal window opens, and I automatically end up in my home folder /home/me. I expect to see an empty folder but I instead see the development folder that I created in project1 in p1-cluster1.

Why do I see contents/files of another project (and another cluster) in a different project (and cluster)? Am I doing something wrong? If this is normal, what is the benefit of creating different projects?

I can create a new folder with the name development_2. But what if I accidentally ruin things (i.e. operative system) when working under development folder..? Do I also ruin things for the project under the development_2 folder?

And also, if I simultaneously run 2 tasks in 2 different projects, will they be competing with each other for the system resources (i.e. memory and CPU)?

This is extremely confusing and I could not make it clear to me by looking at documentation. I would really appreciate help of more experienced people in this specific domain.

CodePudding user response:

I suppose you use Cloud shell to "connect" to the clusters. This is just a convenient way instead of using your own machine's shell. You get a machine which can be used for development instead of your local machine.

Therefore you have the same files and the some directory. It is not on the GKE Cluster, but a "local" machine from the perspective of GKE.

In order to actually execute something on the cluster you have to use kubectl which has a concept of kube contexts. If you have multiple clusters, then you need multiple kube contexts.

So if you "Connect" that from p1-cluster1 your kube-context will be set to that cluster.

See these articles for more detail:

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

https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl

EDIT:

So when you do

gcloud container clusters get-credentials p1-cluster1

on your local machine, you can the context to call

kubectl get pods

on that cluster. Only that command is executed on the cluster.

  • Related