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/08 04:38:58 UTC

[skywalking-showcase] branch main updated (278de5b -> 402da4a)

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

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


    from 278de5b  Add license of Gradle wrapper
     new f50211e  Enable deploy features via CLI
     new 402da4a  Add Kubernetes cluster feature

The 2 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.


Summary of changes:
 deploy/platform/docker/Makefile                    |  9 +---
 deploy/platform/docker/docker-compose.so11y.yaml   |  2 +
 deploy/platform/kubernetes/Makefile                | 48 +++++++++++--------
 .../permissions.yaml                               | 16 ++++---
 .../resources.yaml                                 | 55 +++++++++++++++++++++-
 .../kubernetes/feature-single-node/resources.yaml  |  1 -
 .../kubernetes/feature-so11y/permissions.yaml      |  2 +-
 .../platform/kubernetes/features.mk                | 18 +++----
 8 files changed, 103 insertions(+), 48 deletions(-)
 copy deploy/platform/kubernetes/{feature-so11y => feature-cluster}/permissions.yaml (73%)
 copy deploy/platform/kubernetes/{feature-single-node => feature-cluster}/resources.yaml (64%)
 copy services/recommendation-service/Makefile => deploy/platform/kubernetes/features.mk (73%)

[skywalking-showcase] 02/02: Add Kubernetes cluster feature

Posted by ke...@apache.org.
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

commit 402da4a9b54df9972ea1bb4dec2813612a419768
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Mon Nov 8 12:38:42 2021 +0800

    Add Kubernetes cluster feature
---
 .../permissions.yaml                               | 16 ++++---
 .../resources.yaml                                 | 55 +++++++++++++++++++++-
 .../kubernetes/feature-single-node/resources.yaml  |  1 -
 .../kubernetes/feature-so11y/permissions.yaml      |  2 +-
 4 files changed, 64 insertions(+), 10 deletions(-)

diff --git a/deploy/platform/kubernetes/feature-so11y/permissions.yaml b/deploy/platform/kubernetes/feature-cluster/permissions.yaml
similarity index 73%
copy from deploy/platform/kubernetes/feature-so11y/permissions.yaml
copy to deploy/platform/kubernetes/feature-cluster/permissions.yaml
index 0aa91d7..6d36eee 100644
--- a/deploy/platform/kubernetes/feature-so11y/permissions.yaml
+++ b/deploy/platform/kubernetes/feature-cluster/permissions.yaml
@@ -19,29 +19,33 @@
 apiVersion: v1
 kind: ServiceAccount
 metadata:
-  name: otel-sa-so11y
+  name: skywalking-sa-cluster
 
 ---
 kind: ClusterRole
 apiVersion: rbac.authorization.k8s.io/v1
 metadata:
-  name: otel-role-so11y
+  name: skywalking-sa-cluster-role
 rules:
   - apiGroups: [ "" ]
     resources:
-      - "pods" # @feature: so11y; OpenTelemetry needs to read OAP pods information to get OAP details
+      - "pods" # @feature: cluster; OAP needs to read other OAP Pods information to form a cluster
+    verbs: [ "get", "watch", "list" ]
+  - apiGroups: [ "batch" ]
+    resources:
+      - "jobs" # @feature: cluster; OAP needs to wait for the init job to complete
     verbs: [ "get", "watch", "list" ]
 
 ---
 apiVersion: rbac.authorization.k8s.io/v1
 kind: ClusterRoleBinding
 metadata:
-  name: otel-role-binding-so11y
+  name: skywalking-sa-cluster-role-binding
 roleRef:
   apiGroup: rbac.authorization.k8s.io
   kind: ClusterRole
-  name: otel-role-so11y
+  name: skywalking-sa-cluster-role
 subjects:
   - kind: ServiceAccount
-    name: otel-sa-so11y
+    name: skywalking-sa-cluster
     namespace: default
diff --git a/deploy/platform/kubernetes/feature-single-node/resources.yaml b/deploy/platform/kubernetes/feature-cluster/resources.yaml
similarity index 64%
copy from deploy/platform/kubernetes/feature-single-node/resources.yaml
copy to deploy/platform/kubernetes/feature-cluster/resources.yaml
index 5b29142..e710cb7 100644
--- a/deploy/platform/kubernetes/feature-single-node/resources.yaml
+++ b/deploy/platform/kubernetes/feature-cluster/resources.yaml
@@ -73,6 +73,42 @@ spec:
       port: 12800
 
 ---
+apiVersion: batch/v1
+kind: Job
+metadata:
+  name: oap-init-job # @feature: cluster; set up an init job to initialize ES templates and indices
+spec:
+  template:
+    metadata:
+      name: oap-init-job
+    spec:
+      serviceAccountName: skywalking-sa-cluster
+      restartPolicy: Never
+      initContainers:
+        - name: wait-for-es
+          image: docker.elastic.co/elasticsearch/elasticsearch-oss:${ES_VERSION}
+          command:
+            - 'sh'
+            - '-c'
+            - 'for i in $(seq 1 60); do nc -z -w3 elasticsearch 9200 && exit 0 || sleep 5; done; exit 1'
+      containers:
+        - name: oap-init
+          image: ${SW_OAP_IMAGE}
+          env: # @feature: cluster; make sure all env vars are the same with the cluster nodes as this will affect templates / indices
+            - name: JAVA_OPTS
+              value: "-Dmode=init" # @feature: cluster; set the OAP mode to "init" so the job can complete
+            - name: SW_OTEL_RECEIVER
+              value: default
+            - name: SW_OTEL_RECEIVER_ENABLED_OC_RULES
+              value: vm,oap
+            - name: SW_STORAGE
+              value: elasticsearch
+            - name: SW_STORAGE_ES_CLUSTER_NODES
+              value: elasticsearch:9200
+            - name: SW_TELEMETRY
+              value: prometheus
+
+---
 apiVersion: apps/v1
 kind: Deployment
 metadata:
@@ -80,7 +116,7 @@ metadata:
   labels:
     app: oap
 spec:
-  replicas: 1
+  replicas: 2 # @feature: cluster; set OAP replicas to >1
   selector:
     matchLabels:
       app: oap
@@ -89,6 +125,15 @@ spec:
       labels:
         app: oap
     spec:
+      serviceAccountName: skywalking-sa-cluster # @feature: cluster; set a service account with Pod "read" permission
+      initContainers:
+        - name: wait-for-oap-init
+          image: bitnami/kubectl:1.20.12
+          command:
+            - 'kubectl'
+            - 'wait'
+            - '--for=condition=complete'
+            - 'job/oap-init-job'
       containers:
         - name: oap
           image: ${SW_OAP_IMAGE}
@@ -107,6 +152,12 @@ spec:
             - name: http
               containerPort: 12800
           env:
+            - name: JAVA_OPTS
+              value: "-Dmode=no-init"
+            - name: SW_CLUSTER
+              value: kubernetes # @feature: cluster; set cluster coordinator to kubernetes
+            - name: SW_CLUSTER_K8S_LABEL
+              value: app=oap # @feature: cluster; set label selectors to select OAP Pods as a cluster
             - name: SW_HEALTH_CHECKER
               value: default
             - name: SW_OTEL_RECEIVER
@@ -150,7 +201,7 @@ spec:
       labels:
         app: rocket-bot
     spec:
-      serviceAccountName: skywalking-sa
+      serviceAccountName: skywalking-sa-cluster
       containers:
         - name: rocket-bot
           image: ${SW_ROCKET_BOT_IMAGE}
diff --git a/deploy/platform/kubernetes/feature-single-node/resources.yaml b/deploy/platform/kubernetes/feature-single-node/resources.yaml
index 5b29142..3f48173 100644
--- a/deploy/platform/kubernetes/feature-single-node/resources.yaml
+++ b/deploy/platform/kubernetes/feature-single-node/resources.yaml
@@ -150,7 +150,6 @@ spec:
       labels:
         app: rocket-bot
     spec:
-      serviceAccountName: skywalking-sa
       containers:
         - name: rocket-bot
           image: ${SW_ROCKET_BOT_IMAGE}
diff --git a/deploy/platform/kubernetes/feature-so11y/permissions.yaml b/deploy/platform/kubernetes/feature-so11y/permissions.yaml
index 0aa91d7..aefc8f7 100644
--- a/deploy/platform/kubernetes/feature-so11y/permissions.yaml
+++ b/deploy/platform/kubernetes/feature-so11y/permissions.yaml
@@ -29,7 +29,7 @@ metadata:
 rules:
   - apiGroups: [ "" ]
     resources:
-      - "pods" # @feature: so11y; OpenTelemetry needs to read OAP pods information to get OAP details
+      - "pods" # @feature: so11y; OpenTelemetry needs to read OAP Pods information to get OAP details
     verbs: [ "get", "watch", "list" ]
 
 ---

[skywalking-showcase] 01/02: Enable deploy features via CLI

Posted by ke...@apache.org.
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

commit f50211ecff0f1ce1e12bf87a9812f32951205b21
Author: kezhenxu94 <ke...@apache.org>
AuthorDate: Mon Nov 8 11:26:28 2021 +0800

    Enable deploy features via CLI
---
 deploy/platform/docker/Makefile                    |  9 +---
 deploy/platform/docker/docker-compose.so11y.yaml   |  2 +
 deploy/platform/kubernetes/Makefile                | 48 +++++++++++++---------
 .../features.mk}                                   |  9 +++-
 4 files changed, 41 insertions(+), 27 deletions(-)

diff --git a/deploy/platform/docker/Makefile b/deploy/platform/docker/Makefile
index af5c48c..63cce31 100644
--- a/deploy/platform/docker/Makefile
+++ b/deploy/platform/docker/Makefile
@@ -18,13 +18,8 @@
 
 include ../../../Makefile.in
 
-ifeq ($(FEATURE_FLAGS),all)
-  features := $(wildcard docker-compose.*.yaml)
-  features := $(foreach f,$(features),-f $(f))
-else
-  features := $(subst $(comma), ,$(FEATURE_FLAGS))
-  features := $(foreach f,$(features),-f docker-compose.$(f).yaml)
-endif
+features := $(subst $(comma), ,$(FEATURE_FLAGS))
+features := $(foreach f,$(features),-f docker-compose.$(f).yaml)
 
 .PHONY: deploy
 deploy:
diff --git a/deploy/platform/docker/docker-compose.so11y.yaml b/deploy/platform/docker/docker-compose.so11y.yaml
index 1f069f1..4e708d8 100644
--- a/deploy/platform/docker/docker-compose.so11y.yaml
+++ b/deploy/platform/docker/docker-compose.so11y.yaml
@@ -17,3 +17,5 @@
 #
 
 # So11y in Docker compose is enabled by default
+
+version: '2.1'
diff --git a/deploy/platform/kubernetes/Makefile b/deploy/platform/kubernetes/Makefile
index ff1a9b7..fbfabfb 100644
--- a/deploy/platform/kubernetes/Makefile
+++ b/deploy/platform/kubernetes/Makefile
@@ -17,32 +17,42 @@
 #
 
 include ../../../Makefile.in
+include features.mk
 
-ifeq ($(FEATURE_FLAGS),all)
-  features := $(wildcard feature-*)
-else
-  features := $(subst $(comma), ,$(FEATURE_FLAGS))
-  features := $(foreach f,$(features),feature-$(f))
-endif
+features := $(subst $(comma), ,$(FEATURE_FLAGS))
+features := $(foreach f,$(features),feature-$(f))
 
-resources := $(foreach dir,$(features),$(wildcard $(dir)/*))
+# Deploy
+deploy_features := $(foreach r,$(features),deploy.$(r))
+.PHONY: $(deploy_features)
+$(deploy_features): %: %.resources
 
-resources_deploy := $(foreach r,$(resources),$(r).deploy)
-.PHONY: $(resources_deploy)
-$(resources_deploy): %.deploy: %
-	@docker run --rm -v "$(shell pwd)/$<":/input \
+deploy_resources := $(foreach r,$(deploy_features),$(r).resources)
+.PHONY: $(deploy_resources)
+$(deploy_resources): deploy.%.resources: %
+	$(eval resources := $(wildcard $(shell pwd)/$</*))
+	@$(foreach resource, $(resources), docker run --rm -v "$(pwd)/$(resource)":/input \
 		$(foreach v,$(EXPORTED_VARS),-e $(v)) \
-		bhgedigital/envsubst sh -c "envsubst < /input" | kubectl apply -f -
+		bhgedigital/envsubst sh -c "envsubst < /input" | kubectl apply -f - ; \
+	)
 
 .PHONY: deploy
-deploy: $(resources_deploy)
+deploy: $(deploy_features)
 
-resources_undeploy := $(foreach r,$(resources),$(r).undeploy)
-.PHONY: $(resources_undeploy)
-$(resources_undeploy): %.undeploy: %
-	@docker run --rm -v "$(shell pwd)/$<":/input \
+# Undeploy
+undeploy_features := $(foreach r,$(features),undeploy.$(r))
+.PHONY: $(undeploy_features)
+$(undeploy_features): %: %.resources
+
+undeploy_resources := $(foreach r,$(undeploy_features),$(r).resources)
+.PHONY: $(undeploy_resources)
+$(undeploy_resources): undeploy.%.resources: %
+	$(info undeploying feature $<)
+	$(eval resources := $(wildcard $(shell pwd)/$</*))
+	@$(foreach resource, $(resources), docker run --rm -v "$(pwd)/$(resource)":/input \
 		$(foreach v,$(EXPORTED_VARS),-e $(v)) \
-		bhgedigital/envsubst sh -c "envsubst < /input" | kubectl delete --ignore-not-found -f -
+		bhgedigital/envsubst sh -c "envsubst < /input" | kubectl delete --ignore-not-found -f - ; \
+	)
 
 .PHONY: undeploy
-undeploy: $(resources_undeploy)
+undeploy: $(undeploy_features)
diff --git a/deploy/platform/docker/docker-compose.so11y.yaml b/deploy/platform/kubernetes/features.mk
similarity index 73%
copy from deploy/platform/docker/docker-compose.so11y.yaml
copy to deploy/platform/kubernetes/features.mk
index 1f069f1..8d019fc 100644
--- a/deploy/platform/docker/docker-compose.so11y.yaml
+++ b/deploy/platform/kubernetes/features.mk
@@ -16,4 +16,11 @@
 # under the License.
 #
 
-# So11y in Docker compose is enabled by default
+# This file contains the targets to deploy features that are not
+# applicable to deploy via manifest, we can deploy them via command
+# line interface here, for better maintainability.
+
+include ../../../Makefile.in
+
+feature-istio:
+	@echo 'Example: deploying Istio via command line'