如何将kubernetes事件从GKE集群传播到Google云日志 [英] How to propagate kubernetes events from a GKE cluster to google cloud log
问题描述
反正有将所有kubernetes事件传播到Google云日志吗?
例如,一个pod创建/删除或活动探测失败,我知道我可以在控制台中使用kubectl get事件.
但是,我想将这些事件与其他Pod级别的日志一起保存在云日志中的日志文件中.
这是非常有用的信息.
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.
推荐答案
似乎OP找到了日志,但是我无法使用Stackdriver在GKE(1.4.7)上运行.弄清楚这有点棘手,所以我想我应该和别人分享.我可以通过使用gcl接收器创建一个eventer部署来获取它们.
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.
例如:
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
然后,使用高级过滤器(替换您的GCE项目名称)搜索日志:
Then, search for logs with an advanced filter (substitute your GCE project name):
resource.type="global"
logName="projects/project-name/logs/kubernetes.io%2Fevents"
这篇关于如何将kubernetes事件从GKE集群传播到Google云日志的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!