You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@skywalking.apache.org by ke...@apache.org on 2021/04/06 14:52:23 UTC

[skywalking-kubernetes-event-exporter] 01/01: doc: add docs and default config and sample deployment manifest

This is an automated email from the ASF dual-hosted git repository.

kezhenxu94 pushed a commit to branch doc
in repository https://gitbox.apache.org/repos/asf/skywalking-kubernetes-event-exporter.git

commit 00ad555a847e7a4cbd8e54d0248ebc1dd5316d0f
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Tue Apr 6 22:51:48 2021 +0800

    doc: add docs and default config and sample deployment manifest
---
 README.md                                          |  22 ++++-
 assets/default-config.yaml                         |  17 +++-
 configs/config.go                                  |   5 +-
 .../skywalking-kubernetes-event-exporter.yaml      | 102 +++++++++++++++++++++
 4 files changed, 139 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index df30b5d..a78e1db 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,21 @@
-# Kubernetes Event Exporter
+# SkyWalking Kubernetes Event Exporter
+
+SkyWalking Kubernetes Event Exporter is able to watch, filter, and send Kubernetes events into SkyWalking backend,
+afterwards, SkyWalking associates the events with the system metrics and thus gives you an overview about how the
+metrics are effected by the events.
+
+## Configurations
+
+Configurations are in YAML format, or config map if running inside Kubernetes,
+otherwise, [the default configuration file](assets/default-config.yaml) will be used if there is neither `-c` option
+specified in the command line interface nor config map is created in Kubernetes.
+
+All available configuration items and their documentations can be found
+in [the default configuration file](assets/default-config.yaml).
+
+## Deployments
+
+Go to [the /deployments](deployments) directory, modify according to your needs,
+and `kubectl apply -f skywalking-kubernetes-event-exporter.yaml`.
+
+You can also simply run `skywalking-kubernetes-event-exporter start` in command line interface to run this exporter from outside of Kubernetes.
diff --git a/assets/default-config.yaml b/assets/default-config.yaml
index fa8fa32..9ca1771 100644
--- a/assets/default-config.yaml
+++ b/assets/default-config.yaml
@@ -17,13 +17,20 @@
 #
 
 filters:
-  - namespace: istio-system
-    exporters:
+  - reason: ""     # filter events of the specified reason, regular expression like "Killing|Killed" is supported.
+    message: ""    # filter events of the specified message, regular expression like "Pulling container.*" is supported.
+    minCount: 1    # filter events whose count is >= the specified value.
+    type: ""       # filter events of the specified type, regular expression like "Normal|Error" is supported.
+    action: ""     # filter events of the specified action, regular expression is supported.
+    kind: ""       # filter events of the specified kind, regular expression like "Pod|Service" is supported.
+    namespace: ""  # filter events from the specified namespace, regular expression like "default|bookinfo" is supported, empty means all namespaces.
+    name: ""       # filter events from the specified namespace, regular expression like ".*bookinfo.*" is supported.
+    exporters:     # events satisfy this filter can be exported into several exporters that are defined in the `exporters` section below.
       - skywalking
 
-exporters:
-  skywalking:
-    template:
+exporters:         # defines and configures the exporters that can be used in the `filters` section above.
+  skywalking:      # the exporter name, which is declared in the struct type `Exporter`'s Name function.
+    template:      # exporter-specific configurations, different exporter may have different configuration contents.
       source:
         service: "{{ .Service.Name }}"
         serviceInstance: "{{ .Pod.Name }}"
diff --git a/configs/config.go b/configs/config.go
index 13a69f4..04558dd 100644
--- a/configs/config.go
+++ b/configs/config.go
@@ -35,7 +35,7 @@ type FilterConfig struct {
 	reasonRegExp    *regexp.Regexp
 	Message         string `yaml:"message"`
 	messageRegExp   *regexp.Regexp
-	MinCount        int32  `yaml:"min-count"`
+	MinCount        int32  `yaml:"minCount"`
 	Type            string `yaml:"type"`
 	typeRegExp      *regexp.Regexp
 	Action          string `yaml:"action"`
@@ -74,6 +74,9 @@ func (filter *FilterConfig) Filter(event *v1.Event) bool {
 	if filter.Message != "" && !filter.messageRegExp.MatchString(event.Message) {
 		return true
 	}
+	if event.Count < filter.MinCount {
+		return true
+	}
 	if filter.Type != "" && !filter.typeRegExp.MatchString(event.Type) {
 		return true
 	}
diff --git a/deployments/skywalking-kubernetes-event-exporter.yaml b/deployments/skywalking-kubernetes-event-exporter.yaml
new file mode 100644
index 0000000..173684a
--- /dev/null
+++ b/deployments/skywalking-kubernetes-event-exporter.yaml
@@ -0,0 +1,102 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+---
+apiVersion: v1
+kind: Namespace
+metadata:
+  name: monitoring
+
+---
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  namespace: monitoring
+  name: skywalking-event-exporter
+
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRoleBinding
+metadata:
+  name: skywalking-event-exporter
+roleRef:
+  apiGroup: rbac.authorization.k8s.io
+  kind: ClusterRole
+  name: view
+subjects:
+  - kind: ServiceAccount
+    namespace: monitoring
+    name: skywalking-event-exporter
+
+---
+apiVersion: v1
+kind: ConfigMap
+metadata:
+  name: skywalking-event-exporter-cm
+  namespace: monitoring
+data:
+  config.yaml: |
+    filters:
+      - namespace: istio-system
+        exporters:
+          - skywalking
+
+    exporters:
+      skywalking:
+        template:
+          source:
+            service: "{{ .Service.Name }}"
+            serviceInstance: "{{ .Pod.Name }}"
+            endpoint: ""
+          message: "{{ .Event.Message }}" # this is default, just to demonstrate the context
+        address: "skywalking-oap.istio-system:11800"
+
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: skywalking-event-exporter
+  namespace: monitoring
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: skywalking-event-exporter
+        version: v1
+    spec:
+      serviceAccountName: skywalking-event-exporter
+      containers:
+        - name: skywalking-event-exporter
+          image: apache/skywalking-event-exporter
+          imagePullPolicy: IfNotPresent
+          args:
+            - start
+            - -c=/data/config.yaml
+          volumeMounts:
+            - mountPath: /data
+              name: config
+      volumes:
+        - name: config
+          configMap:
+            name: skywalking-event-exporter-cm
+  selector:
+    matchLabels:
+      app: skywalking-event-exporter
+      version: v1