Score:1

kubectl not getting all pods

ch flag

I am using Google Cloud Platform, and I have two different kubernetes clusters running on GKE. Now these clusters are zonal clusters, and are running on different zones. the issue is when I am using the cloud shell, kubectl get pods is getting pods from another cluster. I have used kubectl config set-cluster xxx to set the cluster, but still, the other pods are showing only.

A. Darwin avatar
my flag
Can you provide the output of kubectl config view?
jaafar Nasrallah avatar
ch flag
I can't really do that, but the very weird thing is, other clusters have the following properties : name, server, and certificate-authority-data. but the cluster that I want to have its pods showing, only has name and server, where the server is empty, and the name showing just the cluster name ex : my_test_cluster. where as the others show like : gke_projectname_zone_cluster-name
jaafar Nasrallah avatar
ch flag
@A.Darwin thank you for your answer, but the above comment still puzzles me and I don't thing it qualifies to be a full post
Score:1
my flag

If kubectl get pods returns pods from another cluster, your kubectl configuration is probably pointing to the other cluster.

You can check the current context (current cluster) kubectl is using with: kubectl config current-context.

Note that, as the GKE documentation highlights:

When you create a cluster using the Google Cloud console or using gcloud CLI from a different computer, your environment's kubeconfig file is not updated. Additionally, if a project team member uses gcloud CLI to create a cluster from their computer, their kubeconfig is updated but yours is not. The kubeconfig entry contains either:

Your credentials as shown in gcloud auth list, or

The application default credentials, if configured.

To generate a kubeconfig context in your environment, ensure that you have the container.clusters.get permission. The least-privileged IAM role that provides this permission is container.clusterViewer.

To generate a kubeconfig context for a specific cluster, run the following command:

gcloud container clusters get-credentials CLUSTER_NAME

Replace CLUSTER_NAME with the name of your cluster.

If the target cluster is not running in the default zone or region, or if you did not set a default zone or region, you need to supply the region (--region=REGION) or zone (--zone=ZONE) in the command.

Note: Running gcloud container clusters get-credentials also changes the current context for kubectl to that cluster.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.