To check the container logs of a GKE cluster, you can use the following command steps:
-
First, make sure that you have authenticated with Google Cloud and set the current project to the one containing the GKE cluster you want to access:
gcloud auth login gcloud config set project <PROJECT_ID>
Replace
<PROJECT_ID>
with the ID of the Google Cloud project containing the GKE cluster. -
Use the
kubectl
command-line tool to list the pods running in the GKE cluster:kubectl get pods
This will list all of the pods running in the default namespace of the GKE cluster.
-
Identify the pod and container that you want to view the logs for. You can use the following command to view the logs for a specific container within a pod:
kubectl logs <POD_NAME> <CONTAINER_NAME>
Replace
<POD_NAME>
with the name of the pod you want to view the logs for, and<CONTAINER_NAME>
with the name of the container within the pod.If you're not sure of the container name, you can list the containers in the pod using the following command:
kubectl describe pod <POD_NAME>
-
If you want to view the logs continuously (like
tail -f
), you can use the following command:kubectl logs -f <POD_NAME> <CONTAINER_NAME>
This will stream the logs to your terminal in real-time.
That's it! You can now view the container logs of a GKE cluster using the kubectl
command-line tool.