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/11/18 06:52:09 UTC

[skywalking-showcase] branch event created (now 5764ddc)

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

kezhenxu94 pushed a change to branch event
in repository https://gitbox.apache.org/repos/asf/skywalking-showcase.git.


      at 5764ddc  Add feature event

This branch includes the following new commits:

     new 5764ddc  Add feature event

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


[skywalking-showcase] 01/01: Add feature event

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 5764ddc87ed15a3559e05e732b746ac5a83fde37
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Thu Nov 18 14:51:58 2021 +0800

    Add feature event
---
 Makefile.in                                        |   2 +
 deploy/platform/docker/Makefile.in                 |   2 +-
 deploy/platform/docker/docker-compose.event.yaml   |  43 +++++++++
 deploy/platform/kubernetes/Makefile                |   2 +
 deploy/platform/kubernetes/Makefile.in             |   2 +-
 .../feature-event/permissions.yaml}                |  21 +++-
 .../kubernetes/feature-event/resources.yaml        |  90 +++++++++++++++++
 .../platform/kubernetes/feature-event/scaler.yaml  | 106 +++++++++++++++++++++
 deploy/platform/kubernetes/features.mk             |   2 +-
 docs/readme.md                                     |   1 +
 10 files changed, 266 insertions(+), 5 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 2181347..55c545b 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -28,6 +28,8 @@ ES_IMAGE ?= docker.elastic.co/elasticsearch/elasticsearch-oss:7.10.0
 
 SW_OAP_IMAGE ?= ghcr.io/apache/skywalking/oap:b63008c61e1fcb1d69b25a8be7ce99f1d987a175
 SW_ROCKET_BOT_IMAGE ?= ghcr.io/apache/skywalking/ui:b63008c61e1fcb1d69b25a8be7ce99f1d987a175
+SW_CLI_IMAGE ?= ghcr.io/apache/skywalking-cli/skywalking-cli:8c5725f2c4c47de6091748c1b4747f0d6047ad8e
+SW_EVENT_EXPORTER_IMAGE ?= ghcr.io/apache/skywalking-kubernetes-event-exporter/skywalking-kubernetes-event-exporter:c4abefe016160873651915c5a3b8cdd2071774e7
 
 SW_AGENT_NODEJS_BACKEND_VERSION ?= e755659c7f308d3b5589619778c8360308cb14f8
 SW_AGENT_NODEJS_FRONTEND_VERSION ?= af0565a67d382b683c1dbd94c379b7080db61449
diff --git a/deploy/platform/docker/Makefile.in b/deploy/platform/docker/Makefile.in
index 2c80d2b..1c5ba3c 100644
--- a/deploy/platform/docker/Makefile.in
+++ b/deploy/platform/docker/Makefile.in
@@ -17,4 +17,4 @@
 #
 
 .EXPORT_ALL_VARIABLES:
-FEATURE_FLAGS ?= agent,cluster,so11y,vm
+FEATURE_FLAGS ?= agent,cluster,so11y,vm,event
diff --git a/deploy/platform/docker/docker-compose.event.yaml b/deploy/platform/docker/docker-compose.event.yaml
new file mode 100644
index 0000000..929e083
--- /dev/null
+++ b/deploy/platform/docker/docker-compose.event.yaml
@@ -0,0 +1,43 @@
+# 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.
+#
+version: '2.1'
+
+services:
+  # @feature: event; set up event reporter to upload events.
+  event-reporter:
+    image: ${SW_CLI_IMAGE}
+    networks: [ sw ]
+    entrypoint:
+      - /bin/sh
+      - -xc
+    command:
+      - >-
+        while true; do
+          /swctl --grpc-addr=oap:11800 event report --uuid=$$RANDOM$$RANDOM$$RANDOM --name=Upgrade --service-name=songs --message='Upgrade from {fromVersion} to {toVersion}' --start-time=$$(($$(date +%s)*1000-60000)) --end-time=$$(($$(date +%s)*1000)) fromVersion=v1 toVersion=v2
+          sleep 30
+          /swctl --grpc-addr=oap:11800 event report --uuid=$$RANDOM$$RANDOM$$RANDOM --name=Upgrade --service-name=recommendation --message='Upgrade from {fromVersion} to {toVersion}' --start-time=$$(($$(date +%s)*1000-60000)) --end-time=$$(($$(date +%s)*1000)) fromVersion=v1 toVersion=v2
+          sleep 30
+          /swctl --grpc-addr=oap:11800 event report --uuid=$$RANDOM$$RANDOM$$RANDOM --name=Upgrade --service-name=gateway --message='Upgrade from {fromVersion} to {toVersion}' --start-time=$$(($$(date +%s)*1000-60000)) --end-time=$$(($$(date +%s)*1000)) fromVersion=v1 toVersion=v2
+          sleep 30
+        done
+    depends_on:
+      oap:
+        condition: service_healthy
+
+networks:
+  sw:
diff --git a/deploy/platform/kubernetes/Makefile b/deploy/platform/kubernetes/Makefile
index aeb6b4f..178ae19 100644
--- a/deploy/platform/kubernetes/Makefile
+++ b/deploy/platform/kubernetes/Makefile
@@ -38,6 +38,7 @@ $(deploy_resources): deploy.%.resources: %
 
 .PHONY: deploy
 deploy: $(deploy_features)
+ifneq ($(SHOW_TIPS),false)
 	@echo
 	@echo "Now wait the Pods to be ready and use the following command to expose the port of SkyWalking UI"
 	@echo
@@ -45,6 +46,7 @@ deploy: $(deploy_features)
 	@echo
 	@echo "Then open your browser and navigate to http://localhost:8080"
 	@echo
+endif
 
 # Undeploy
 undeploy_features := $(foreach r,$(features),undeploy.$(r))
diff --git a/deploy/platform/kubernetes/Makefile.in b/deploy/platform/kubernetes/Makefile.in
index 3e955ba..85bc910 100644
--- a/deploy/platform/kubernetes/Makefile.in
+++ b/deploy/platform/kubernetes/Makefile.in
@@ -21,4 +21,4 @@
 NAMESPACE ?= default
 AGENTLESS ?= false
 
-FEATURE_FLAGS ?= agent,cluster,kubernetes-monitor,so11y,vm,als
+FEATURE_FLAGS ?= agent,cluster,kubernetes-monitor,so11y,vm,als,event
diff --git a/deploy/platform/docker/Makefile.in b/deploy/platform/kubernetes/feature-event/permissions.yaml
similarity index 65%
copy from deploy/platform/docker/Makefile.in
copy to deploy/platform/kubernetes/feature-event/permissions.yaml
index 2c80d2b..8aa437c 100644
--- a/deploy/platform/docker/Makefile.in
+++ b/deploy/platform/kubernetes/feature-event/permissions.yaml
@@ -15,6 +15,23 @@
 # specific language governing permissions and limitations
 # under the License.
 #
+---
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  namespace: ${NAMESPACE}
+  name: skywalking-event-exporter-sa
 
-.EXPORT_ALL_VARIABLES:
-FEATURE_FLAGS ?= agent,cluster,so11y,vm
+---
+apiVersion: rbac.authorization.k8s.io/v1
+kind: ClusterRoleBinding
+metadata:
+  name: skywalking-event-exporter-role-binding
+roleRef:
+  apiGroup: rbac.authorization.k8s.io
+  kind: ClusterRole
+  name: view
+subjects:
+  - kind: ServiceAccount
+    namespace: ${NAMESPACE}
+    name: skywalking-event-exporter-sa
diff --git a/deploy/platform/kubernetes/feature-event/resources.yaml b/deploy/platform/kubernetes/feature-event/resources.yaml
new file mode 100644
index 0000000..bb32769
--- /dev/null
+++ b/deploy/platform/kubernetes/feature-event/resources.yaml
@@ -0,0 +1,90 @@
+# 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.
+#
+#
+# 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: ConfigMap
+metadata:
+  name: skywalking-event-exporter-cm
+  namespace: ${NAMESPACE}
+data:
+  config.yaml: |
+    filters:
+      - namespace: ${NAMESPACE}|${NAMESPACE}-agentless
+        exporters:
+          - skywalking
+
+    exporters:
+      skywalking:
+        template:
+          source:
+            service: "{{ .Service.Name }}"
+            serviceInstance: "{{ .Pod.Name }}"
+            endpoint: ""
+          message: "{{ .Event.Message }}"
+        address: "oap:11800"
+
+---
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+  name: skywalking-event-exporter-deployment
+  namespace: ${NAMESPACE}
+spec:
+  replicas: 1
+  template:
+    metadata:
+      labels:
+        app: skywalking-event-exporter
+    spec:
+      serviceAccountName: skywalking-event-exporter-sa
+      containers:
+        - name: skywalking-event-exporter
+          image: ${SW_EVENT_EXPORTER_IMAGE}
+          args:
+            - start
+            - -v=debug
+            - -c=/data/config.yaml
+          volumeMounts:
+            - mountPath: /data
+              name: config
+      volumes:
+        - name: config
+          configMap:
+            name: skywalking-event-exporter-cm
+  selector:
+    matchLabels:
+      app: skywalking-event-exporter
diff --git a/deploy/platform/kubernetes/feature-event/scaler.yaml b/deploy/platform/kubernetes/feature-event/scaler.yaml
new file mode 100644
index 0000000..b032572
--- /dev/null
+++ b/deploy/platform/kubernetes/feature-event/scaler.yaml
@@ -0,0 +1,106 @@
+# 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.
+#
+
+---
+# @feature: event; a cron job to mimic the restart of Pods
+kind: Role
+apiVersion: rbac.authorization.k8s.io/v1
+metadata:
+  name: event-role
+rules:
+  - apiGroups:
+      - ''
+      - extensions
+      - apps
+    resources:
+      - '*'
+    verbs:
+      - '*'
+
+---
+kind: RoleBinding
+apiVersion: rbac.authorization.k8s.io/v1
+metadata:
+  name: event-role-binding
+subjects:
+  - kind: ServiceAccount
+    name: event-scaler-sa
+roleRef:
+  kind: Role
+  name: event-role
+  apiGroup: ""
+
+---
+apiVersion: v1
+kind: ServiceAccount
+metadata:
+  name: event-scaler-sa
+
+---
+apiVersion: batch/v1beta1
+kind: CronJob
+metadata:
+  name: event-scale-up
+spec:
+  schedule: "0,10,20,30,40,50 * * * *"
+  successfulJobsHistoryLimit: 1
+  failedJobsHistoryLimit: 1
+  jobTemplate:
+    spec:
+      template:
+        metadata:
+          annotations:
+            sidecar.istio.io/inject: "false"
+        spec:
+          serviceAccountName: event-scaler-sa
+          containers:
+            - name: event-scaler
+              image: bitnami/kubectl:1.20.12
+              volumeMounts:
+              command:
+                - sh
+                - -c
+                - kubectl -n ${NAMESPACE} scale deployment songs-deployment recommendation-deployment gateway-deployment app-deployment --replicas=2
+          restartPolicy: Never
+
+---
+apiVersion: batch/v1beta1
+kind: CronJob
+metadata:
+  name: event-scale-down
+spec:
+  schedule: "5,15,25,35,45,55 * * * *"
+  successfulJobsHistoryLimit: 1
+  failedJobsHistoryLimit: 1
+  jobTemplate:
+    spec:
+      template:
+        metadata:
+          annotations:
+            sidecar.istio.io/inject: "false"
+        spec:
+          serviceAccountName: event-scaler-sa
+          containers:
+            - name: event-scaler
+              image: bitnami/kubectl:1.20.12
+              volumeMounts:
+              command:
+                - sh
+                - -c
+                - kubectl -n ${NAMESPACE} scale deployment songs-deployment recommendation-deployment gateway-deployment app-deployment --replicas=1
+          restartPolicy: Never
diff --git a/deploy/platform/kubernetes/features.mk b/deploy/platform/kubernetes/features.mk
index 329c425..79de1cf 100644
--- a/deploy/platform/kubernetes/features.mk
+++ b/deploy/platform/kubernetes/features.mk
@@ -54,7 +54,7 @@ feature-als:
 
 .PHONY: deploy.feature-als
 deploy.feature-als: prerequisites
-	$(MAKE) deploy FEATURE_FLAGS=agent TAG=$(TAG)-agentless NAMESPACE=$(NAMESPACE)-agentless AGENTLESS=true
+	$(MAKE) deploy FEATURE_FLAGS=agent TAG=$(TAG)-agentless NAMESPACE=$(NAMESPACE)-agentless AGENTLESS=true SHOW_TIPS=false
 
 .PHONY: undeploy.feature-als
 undeploy.feature-als:
diff --git a/docs/readme.md b/docs/readme.md
index eace110..d17d1f8 100644
--- a/docs/readme.md
+++ b/docs/readme.md
@@ -83,6 +83,7 @@ Currently, the features supported are:
 | `vm`          | Start 2 virtual machines and export their metrics to SkyWalking. | The "virtual machines" are mimicked by Docker containers or Pods. |
 | `als`         | Start microservices WITHOUT SkyWalking agent enabled, and configure SkyWalking to analyze the topology and metrics from their access logs. | Command `istioctl` is required to run this feature. The agentless microservices will be running at namespace `${NAMESPACE}-agentless` |
 | `kubernetes-monitor` | Deploy OpenTelemetry and export Kubernetes monitoring metrics to SkyWalking for analysis and display on UI. | |
+| `event`       | Deploy tools to trigger events, and SkyWalking Kubernetes event exporter to export events into SkyWalking. | |
 
 ### Kubernetes