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 15:11:36 UTC

[skywalking-kubernetes-event-exporter] branch main updated: doc: add docs and default config and sample deployment manifest (#4)

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

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


The following commit(s) were added to refs/heads/main by this push:
     new fdbd8e9  doc: add docs and default config and sample deployment manifest (#4)
fdbd8e9 is described below

commit fdbd8e947def95c66bfdf30aa866db8149e287b4
Author: Zhenxu Ke <ke...@apache.org>
AuthorDate: Tue Apr 6 23:11:31 2021 +0800

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

diff --git a/README.md b/README.md
index df30b5d..edc4ef4 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,49 @@
-# Kubernetes Event Exporter
+# SkyWalking Kubernetes Event Exporter
+
+[![GitHub stars](https://img.shields.io/github/stars/apache/skywalking-kubernetes-event-exporter.svg?style=for-the-badge&label=Stars&logo=github)](https://github.com/apache/skywalking-kubernetes-event-exporter)
+[![Twitter Follow](https://img.shields.io/twitter/follow/asfskywalking.svg?style=for-the-badge&label=Follow&logo=twitter)](https://twitter.com/AsfSkyWalking)
+
+[![Check](https://github.com/apache/skywalking-kubernetes-event-exporter/actions/workflows/build-and-test.yaml/badge.svg)](https://github.com/apache/skywalking-kubernetes-event-exporter/actions/workflows/build-and-test.yaml)
+
+<img src="http://skywalking.apache.org/assets/logo.svg" alt="Sky Walking logo" height="90px" align="right" />
+
+SkyWalking Kubernetes Event Exporter is able to watch, filter, and send Kubernetes events
+into [Apache SkyWalking](https://github.com/apache/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.
+
+# Download
+
+Go to the [download page](https://skywalking.apache.org/downloads/) to download all available binaries, including macOS,
+Linux, Windows.
+
+# Contact Us
+
+* Mailing list: **dev@skywalking.apache.org**. Send email
+  to [dev-subscribe@skywalking.apache.org](mailto:dev-subscribe@skywalking.apache.org), follow the reply to subscribe
+  the mail list.
+* Join `skywalking` channel at [Apache Slack](http://s.apache.org/slack-invite). If the link is not working, find the
+  latest one at [Apache INFRA WIKI](https://cwiki.apache.org/confluence/display/INFRA/Slack+Guest+Invites).
+* Twitter, [ASFSkyWalking](https://twitter.com/ASFSkyWalking)
+* QQ Group: 901167865(Recommended), 392443393
+* [bilibili B站 视频](https://space.bilibili.com/390683219)
+
+# License
+
+[Apache 2.0 License.](LICENSE)
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