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 2022/10/14 13:03:57 UTC

[skywalking-showcase] branch main updated: Polish and fix apisix case

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-showcase.git


The following commit(s) were added to refs/heads/main by this push:
     new 8727b26  Polish and fix apisix case
8727b26 is described below

commit 8727b263536a1ff793e03bfdab50dc043b385811
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Fri Oct 14 21:03:48 2022 +0800

    Polish and fix apisix case
---
 .../kubernetes/feature-agent/resources.yaml        | 135 ++++++++++-----------
 services/app/frontend/Dockerfile                   |   6 +-
 services/app/frontend/Dockerfile.agentless         |   5 +-
 3 files changed, 73 insertions(+), 73 deletions(-)

diff --git a/deploy/platform/kubernetes/feature-agent/resources.yaml b/deploy/platform/kubernetes/feature-agent/resources.yaml
index 0d6cca4..dc4989d 100644
--- a/deploy/platform/kubernetes/feature-agent/resources.yaml
+++ b/deploy/platform/kubernetes/feature-agent/resources.yaml
@@ -246,79 +246,72 @@ metadata:
 data:
   apisix: |
       routes:
-          -
-              uri: /browser/*
-              service_id: 1
-          -
-              uri: /v3/*
-              service_id: 1
-          -
-              uri: /homepage
-              service_id: 2
-              plugins:
-                  skywalking:
-                      service_name: agent::frontend
-                      service_instance_name: "$hostname"
-                      endpoint_addr: http://oap:12800
-          -
-              uri: /test
-              service_id: 2
-              plugins:
-                  skywalking:
-                      service_name: agent::frontend
-                      service_instance_name: "$hostname"
-                      endpoint_addr: http://oap:12800
+      - uri: /browser/*
+        service_id: 1
+      - uri: /v3/*
+        service_id: 1
+      - uri: /homepage
+        service_id: 2
+        plugins:
+          skywalking:
+            service_name: "${{SW_AGENT_SERVICE}}"
+            service_instance_name: "${{SW_AGENT_SERVICE_INSTANCE}}"
+            endpoint_addr: http://oap:12800
+      - uri: /test
+        service_id: 2
+        plugins:
+          skywalking:
+            service_name: "${{SW_AGENT_SERVICE}}"
+            service_instance_name: "${{SW_AGENT_SERVICE_INSTANCE}}"
+            endpoint_addr: http://oap:12800
       services:
-          -
-              id: 1
-              upstream_id: 1
-          -
-              id: 2
-              upstream_id: 2
+      - id: 1
+        upstream_id: 1
+      - id: 2
+        upstream_id: 2
 
       upstreams:
-          - id: 1
-            nodes:
-              "oap:12800": 1
-            type: roundrobin
-          - id: 2
-            nodes:
-              "app:80": 1
-            type: roundrobin
+      - id: 1
+        nodes:
+          "oap:12800": 1
+        type: roundrobin
+      - id: 2
+        nodes:
+          "app:80": 1
+        type: roundrobin
 
       global_rules:
-          -
-              id: 1
-              plugins:
-                  prometheus:
-                      export_addr:
-                        ip: "0.0.0.0"
-                        port: 9091
+      - id: 1
+        plugins:
+          prometheus:
+            export_addr:
+              ip: "0.0.0.0"
+              port: 9091
       #END
   config: |
-      apisix:
-        node_listen: 80
-        enable_ipv6: false
-        enable_admin: false
-        config_center: yaml
-      plugin_attr:
-        prometheus:
-          export_addr:
-            ip: "0.0.0.0"
-            port: 9091
-        skywalking:
-          service_name: agent::frontend
-          service_instance_name: "$hostname"
-          endpoint_addr: http://oap:12800
-      plugins:
-        - prometheus
-        - skywalking
-      nginx_config:
-          http_server_configuration_snippet: |
-              location ~ \.(gif|jpg|png|js|css|html)$ {
-                root /app/build;
-                index index.html;
-              }
+    apisix:
+      node_listen: 80
+      enable_ipv6: false
+      enable_admin: false
+      config_center: yaml
+    plugin_attr:
+      prometheus:
+        export_addr:
+          ip: "0.0.0.0"
+          port: 9091
+      skywalking:
+        service_name: "${{SW_AGENT_SERVICE}}"
+        service_instance_name: "${{SW_AGENT_SERVICE_INSTANCE}}"
+        endpoint_addr: http://oap:12800
+    plugins:
+      - prometheus
+      - skywalking
+    nginx_config:
+      http_server_configuration_snippet: |
+        location ~ \.(gif|jpg|png|js|css|html)$ {
+          root /app/build;
+          index index.html;
+        }
 ---
 apiVersion: apps/v1
 kind: Deployment
@@ -350,15 +343,17 @@ spec:
               cpu: 500m
               memory: "256Mi"
           ports:
-            -
-              containerPort: 80
+            - containerPort: 80
               name: http
-            -
-              containerPort: 9091 # APISIX Prometheus pulgin port
+            - containerPort: 9091 # APISIX Prometheus pulgin port
               name: metrics
           env:
             - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
               value: ${BACKEND_SERVICE}:11800
+            - name: SW_SERVICE_INSTANCE
+              valueFrom:
+                fieldRef:
+                  fieldPath: metadata.name
           volumeMounts:
             - name: apisix-config
               mountPath: /usr/local/apisix/conf/config.yaml
diff --git a/services/app/frontend/Dockerfile b/services/app/frontend/Dockerfile
index ccfdf9b..497b3ce 100644
--- a/services/app/frontend/Dockerfile
+++ b/services/app/frontend/Dockerfile
@@ -28,7 +28,7 @@ RUN git clone --recurse-submodules https://github.com/apache/skywalking-client-j
     git submodule sync ; \
     npm install ; \
     npm run build
-    
+
 WORKDIR /app
 
 COPY . .
@@ -39,5 +39,7 @@ RUN npm install /skywalking-client-js && \
 
 FROM apache/apisix:2.15.0-debian
 
-COPY --from=build /app/build /app/build
+ENV SW_AGENT_SERVICE=agent::frontend
+ENV SW_AGENT_SERVICE_INSTANCE=agent::frontend-instance
 
+COPY --from=build /app/build /app/build
diff --git a/services/app/frontend/Dockerfile.agentless b/services/app/frontend/Dockerfile.agentless
index 8b9006d..f224f6e 100644
--- a/services/app/frontend/Dockerfile.agentless
+++ b/services/app/frontend/Dockerfile.agentless
@@ -28,4 +28,7 @@ RUN npm install && \
 
 FROM apache/apisix:2.15.0-debian
 
-COPY --from=build /app/build /app/build
\ No newline at end of file
+ENV SW_AGENT_SERVICE=frontend
+ENV SW_AGENT_SERVICE_INSTANCE=frontend-instance
+
+COPY --from=build /app/build /app/build