4

Is there anyway to propagate all kubernetes events to google cloud log?

For instance, a pod creation/deletion or liveness probing failed, I knew I can use kubectl get events in a console.
However, I would like to preserve those events in a log file in the cloud log with other pod level logs.
It is quite helpful information.

boraseoksoon
  • 2,164
  • 1
  • 20
  • 25
Rui Yang
  • 657
  • 1
  • 6
  • 16
  • I figured it out, it is not in the Container Log session in cloud log viewer, it is under the Compute Engine log session. I can find log in there. – Rui Yang Sep 15 '16 at 17:10
  • You can use [eventer](https://github.com/kubernetes/heapster/tree/master/events) container which archives events to different backends including GCL. You can find configuration yaml [here](https://github.com/kubernetes/kubernetes/blob/master/cluster/addons/cluster-monitoring/google/heapster-controller.yaml#L70). – Piotr Szczesniak Oct 27 '16 at 11:34

1 Answers1

6

It seems that OP found the logs, but I wasn't able to on GKE (1.4.7) with Stackdriver. It was a little tricky to figure out, so I thought I'd share for others. I was able to get them by creating an eventer deployment with the gcl sink.

For example:

deployment.yaml

kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  labels:
    k8s-app: eventer
  name: eventer
  namespace: kube-system
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: eventer
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  template:
    metadata:
      labels:
        k8s-app: eventer
    spec:
      containers:
      - name: eventer
        command:
        - /eventer
        - --source=kubernetes:''
        - --sink=gcl
        image: gcr.io/google_containers/heapster:v1.2.0
        imagePullPolicy: IfNotPresent
        resources:
          limits:
            cpu: 100m
            memory: 200Mi
          requests:
            cpu: 100m
            memory: 200Mi
        terminationMessagePath: /dev/termination-log
      restartPolicy: Always
      terminationGracePeriodSeconds: 30

Then, search for logs with an advanced filter (substitute your GCE project name):

resource.type="global"
logName="projects/project-name/logs/kubernetes.io%2Fevents"
Branton Davis
  • 386
  • 4
  • 10