From e8dafb527df72ab5f8377a38ebcfd4873dce095f Mon Sep 17 00:00:00 2001 From: Kenshin Chen Date: Sat, 14 May 2022 19:51:10 +0800 Subject: [PATCH] add brpc demo (#218) --- .gitignore | 3 +- Makefile | 12 ++- demo/install-demo.sh | 18 +++- demo/metaprotocol-brpc/brpc-sample.yaml | 100 ++++++++++++++++++++ demo/metaprotocol-brpc/destinationrule.yaml | 28 ++++++ demo/metaprotocol-brpc/install.sh | 21 ++++ demo/metaprotocol-brpc/service.yaml | 28 ++++++ demo/metaprotocol-brpc/serviceentry.yaml | 30 ++++++ demo/metaprotocol-brpc/traffic-split.yaml | 34 +++++++ demo/metaprotocol-brpc/uninstall.sh | 19 ++++ demo/uninstall-demo.sh | 17 +++- 11 files changed, 300 insertions(+), 10 deletions(-) create mode 100644 demo/metaprotocol-brpc/brpc-sample.yaml create mode 100644 demo/metaprotocol-brpc/destinationrule.yaml create mode 100755 demo/metaprotocol-brpc/install.sh create mode 100644 demo/metaprotocol-brpc/service.yaml create mode 100644 demo/metaprotocol-brpc/serviceentry.yaml create mode 100644 demo/metaprotocol-brpc/traffic-split.yaml create mode 100755 demo/metaprotocol-brpc/uninstall.sh diff --git a/.gitignore b/.gitignore index ca16d6f0b..9bb397101 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,5 @@ debug out .idea -tmp \ No newline at end of file +tmp +.vscode diff --git a/Makefile b/Makefile index 72e0ac5d8..4f2f37c34 100644 --- a/Makefile +++ b/Makefile @@ -42,9 +42,17 @@ install: install-for-tcm: bash demo/install-aeraki.sh mode=tcm demo: - bash demo/install-demo.sh + bash demo/install-demo.sh default uninstall-demo: - bash demo/uninstall-demo.sh + bash demo/uninstall-demo.sh default +demo-kafka: + bash demo/install-demo.sh kafka +uninstall-demo-kafka: + bash demo/uninstall-demo.sh kafka +demo-brpc: + bash demo/install-demo.sh brpc +uninstall-demo-brpc: + bash demo/uninstall-demo.sh brpc test: style-check $(GOMOD) tidy $(GOTEST) -race `go list ./... | grep -v e2e` diff --git a/demo/install-demo.sh b/demo/install-demo.sh index 3ac37281d..6cdf5a5ab 100755 --- a/demo/install-demo.sh +++ b/demo/install-demo.sh @@ -14,6 +14,8 @@ BASEDIR=$(dirname "$0")/.. +DEMO=$1 + SCRIPTS_DIR=$BASEDIR/test/e2e/scripts COMMON_DIR=$BASEDIR/test/e2e/common export ISTIO_VERSION=1.12.7 @@ -37,9 +39,17 @@ helm install \ kubectl apply -f $BASEDIR/demo/gateway/demo-ingress.yaml -n istio-system kubectl apply -f $BASEDIR/demo/gateway/istio-ingressgateway.yaml -n istio-system -if [ $# == 0 ] +if [ ${DEMO} == "default" ] +then + echo "install default demo" + bash ${BASEDIR}/demo/metaprotocol-dubbo/install.sh + bash ${BASEDIR}/demo/metaprotocol-thrift/install.sh +elif [ ${DEMO} == "brpc" ] +then + echo "install brpc demo" + bash ${BASEDIR}/demo/metaprotocol-brpc/install.sh +elif [ ${DEMO} == "kafka" ] then - bash $BASEDIR/demo/metaprotocol-dubbo/install.sh - bash $BASEDIR/demo/metaprotocol-thrift/install.sh - #bash ${BASEDIR}/demo/kafka/install.sh + echo "install kafka demo" + bash ${BASEDIR}/demo/kafka/install.sh fi diff --git a/demo/metaprotocol-brpc/brpc-sample.yaml b/demo/metaprotocol-brpc/brpc-sample.yaml new file mode 100644 index 000000000..e17748d91 --- /dev/null +++ b/demo/metaprotocol-brpc/brpc-sample.yaml @@ -0,0 +1,100 @@ +# Copyright Aeraki Authors +# +# Licensed 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: apps/v1 +kind: Deployment +metadata: + name: brpc-echo-server-v1 + labels: + app: brpc-echo-server +spec: + selector: + matchLabels: + app: brpc-echo-server + replicas: 1 + template: + metadata: + annotations: + sidecar.istio.io/bootstrapOverride: aeraki-bootstrap-config + sidecar.istio.io/proxyImage: smwyzi/proxyv2:brpc-0.1 + labels: + app: brpc-echo-server + version: v1 + service_group: user + spec: + containers: + - name: brpc-echo-server + image: smwyzi/brpc-demo:2022-0508-0 + command: + - /usr/local/bin/echo_server + ports: + - containerPort: 8000 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: brpc-echo-server-v2 + labels: + app: brpc-echo-server +spec: + selector: + matchLabels: + app: brpc-echo-server + replicas: 1 + template: + metadata: + annotations: + sidecar.istio.io/bootstrapOverride: aeraki-bootstrap-config + sidecar.istio.io/proxyImage: smwyzi/proxyv2:brpc-0.1 + labels: + app: brpc-echo-server + version: v2 + service_group: batchjob + spec: + containers: + - name: brpc-echo-server + image: smwyzi/brpc-demo:2022-0508-0 + command: + - /usr/local/bin/echo_server + ports: + - containerPort: 8000 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: brpc-echo-client + labels: + app: brpc-echo-client +spec: + selector: + matchLabels: + app: brpc-echo-client + replicas: 1 + template: + metadata: + annotations: + sidecar.istio.io/bootstrapOverride: aeraki-bootstrap-config + sidecar.istio.io/proxyImage: smwyzi/proxyv2:brpc-0.1 + labels: + app: brpc-echo-client + spec: + containers: + - name: brpc-echo-client + image: smwyzi/brpc-demo:2022-0508-0 + command: + - /usr/local/bin/echo_client + - --server=brpc-echo-server:8000 + ports: + - containerPort: 9009 diff --git a/demo/metaprotocol-brpc/destinationrule.yaml b/demo/metaprotocol-brpc/destinationrule.yaml new file mode 100644 index 000000000..bbba49d4b --- /dev/null +++ b/demo/metaprotocol-brpc/destinationrule.yaml @@ -0,0 +1,28 @@ +# Copyright Aeraki Authors +# +# Licensed 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: networking.istio.io/v1alpha3 +kind: DestinationRule +metadata: + name: brpc-echo-server +spec: + host: brpc-echo-server + subsets: + - name: v1 + labels: + version: v1 + - name: v2 + labels: + version: v2 diff --git a/demo/metaprotocol-brpc/install.sh b/demo/metaprotocol-brpc/install.sh new file mode 100755 index 000000000..e900ba57a --- /dev/null +++ b/demo/metaprotocol-brpc/install.sh @@ -0,0 +1,21 @@ +# Copyright Aeraki Authors +# +# Licensed 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. + +BASEDIR=$(dirname "$0") + +kubectl create ns meta-brpc +kubectl label namespace meta-brpc istio-injection=enabled --overwrite=true +kubectl apply -f $BASEDIR/../../k8s/aeraki-bootstrap-config.yaml -n meta-brpc +kubectl apply -f $BASEDIR/brpc-sample.yaml -n meta-brpc +kubectl apply -f $BASEDIR/service.yaml -n meta-brpc \ No newline at end of file diff --git a/demo/metaprotocol-brpc/service.yaml b/demo/metaprotocol-brpc/service.yaml new file mode 100644 index 000000000..ba27f0b91 --- /dev/null +++ b/demo/metaprotocol-brpc/service.yaml @@ -0,0 +1,28 @@ +# Copyright Aeraki Authors +# +# Licensed 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: Service +metadata: + name: brpc-echo-server + labels: + app: brpc-echo-server +spec: + ports: + - name: tcp-metaprotocol-brpc + port: 8000 + protocol: TCP + selector: + app: brpc-echo-server diff --git a/demo/metaprotocol-brpc/serviceentry.yaml b/demo/metaprotocol-brpc/serviceentry.yaml new file mode 100644 index 000000000..a51f179c9 --- /dev/null +++ b/demo/metaprotocol-brpc/serviceentry.yaml @@ -0,0 +1,30 @@ +# Copyright Aeraki Authors +# +# Licensed 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: networking.istio.io/v1alpha3 +kind: ServiceEntry +metadata: + name: brpc-echo-server +spec: + hosts: + - brpc-echo-server + ports: + - number: 8000 + name: tcp-metaprotocol-brpc + protocol: TCP + workloadSelector: + labels: + app: brpc-echo-server + resolution: STATIC diff --git a/demo/metaprotocol-brpc/traffic-split.yaml b/demo/metaprotocol-brpc/traffic-split.yaml new file mode 100644 index 000000000..711153f36 --- /dev/null +++ b/demo/metaprotocol-brpc/traffic-split.yaml @@ -0,0 +1,34 @@ +# Copyright Aeraki Authors +# +# Licensed 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: metaprotocol.aeraki.io/v1alpha1 +kind: MetaRouter +metadata: + name: test-metaprotocol-brpc-route + namespace: meta-brpc +spec: + hosts: + - brpc-echo-server.meta-brpc.svc.cluster.local + routes: + - name: traffic-split + route: + - destination: + host: brpc-echo-server.meta-brpc.svc.cluster.local + subset: v1 + weight: 20 + - destination: + host: brpc-echo-server.meta-brpc.svc.cluster.local + subset: v2 + weight: 80 diff --git a/demo/metaprotocol-brpc/uninstall.sh b/demo/metaprotocol-brpc/uninstall.sh new file mode 100755 index 000000000..230a77ad7 --- /dev/null +++ b/demo/metaprotocol-brpc/uninstall.sh @@ -0,0 +1,19 @@ +# Copyright Aeraki Authors +# +# Licensed 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. + +BASEDIR=$(dirname "$0") + +kubectl delete -f $BASEDIR/brpc-sample.yaml -n meta-brpc +kubectl delete -f $BASEDIR/service.yaml -n meta-brpc +kubectl delete ns meta-brpc \ No newline at end of file diff --git a/demo/uninstall-demo.sh b/demo/uninstall-demo.sh index d21e09b23..138a809a5 100755 --- a/demo/uninstall-demo.sh +++ b/demo/uninstall-demo.sh @@ -14,15 +14,26 @@ BASEDIR=$(dirname "$0")/.. +DEMO=$1 + kubectl delete -f https://raw.githubusercontent.com/istio/istio/release-1.10/samples/addons/prometheus.yaml -n istio-system kubectl delete -f https://raw.githubusercontent.com/istio/istio/release-1.10/samples/addons/grafana.yaml -n istio-system kubectl delete -f $BASEDIR/demo/gateway/demo-ingress.yaml -n istio-system kubectl delete -f $BASEDIR/demo/gateway/istio-ingressgateway.yaml -n istio-system -bash $BASEDIR/demo/metaprotocol-dubbo/uninstall.sh -bash $BASEDIR/demo/metaprotocol-thrift/uninstall.sh -bash ${BASEDIR}/demo/kafka/uninstall.sh + +if [ ${DEMO} == "default" ] +then + bash ${BASEDIR}/demo/metaprotocol-dubbo/uninstall.sh + bash ${BASEDIR}/demo/metaprotocol-thrift/uninstall.sh +elif [ ${DEMO} == "brpc" ] +then + bash ${BASEDIR}/demo/metaprotocol-brpc/uninstall.sh +elif [ ${DEMO} == "kafka" ] +then + bash ${BASEDIR}/demo/kafka/uninstall.sh +fi kubectl delete kiali kiali -n istio-system kubectl delete ns istio-system