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:59 UTC

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

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'