Google Kubernetes Engine – Troubleshooting Missing Pod Output Logs

google-cloud-platformgoogle-kubernetes-enginelogging

In freshly installed cluster (Kubernetes version: v1.22.8-gke.201) I have the following test deployment:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: busybox
  labels:
    app: busybox
spec:
  replicas: 1
  strategy: 
    type: RollingUpdate
  selector:
    matchLabels:
      app: busybox
  template:
    metadata:
      labels:
        app: busybox
    spec:
      containers:
        - name: busybox
          image: busybox:latest
          imagePullPolicy: IfNotPresent
          command: ['sh', '-c', 'while true; do printf "$(date +%Y-%m-%d\ %H:%M:%S\ %Z) => your lucky number is: $RANDOM\n"; sleep 5; done']

I can see output produced by the pod using:

kubectl logs <pod_name>

But in the console, after going to Kubernetes Engine -> Workloads, in Overview tab,
Logs, clicking Container Logs link redirects to Operations Logging and all Logs Explorer returns is: 'No data found'.

In Cluster details, section Features, Cloud Logging is enabled and Components set as 'System and Workloads' (which is the default).

What else should be done to be able to see pod's output in Logs Explorer?

Best Answer

Answering to myself:

Enabling Cloud Logging API resolved the issue:

$ gcloud services enable logging.googleapis.com

It should be visible on the list of enabled APIs:

$ gcloud services list
NAME                    TITLE
[...]
logging.googleapis.com  Cloud Logging API
[...]
Related Topic