Skip to content

Commit

Permalink
add brpc demo (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
smwyzi authored May 14, 2022
1 parent 49a300a commit e8dafb5
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 10 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
debug
out
.idea
tmp
tmp
.vscode
12 changes: 10 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
18 changes: 14 additions & 4 deletions demo/install-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
100 changes: 100 additions & 0 deletions demo/metaprotocol-brpc/brpc-sample.yaml
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions demo/metaprotocol-brpc/destinationrule.yaml
Original file line number Diff line number Diff line change
@@ -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
21 changes: 21 additions & 0 deletions demo/metaprotocol-brpc/install.sh
Original file line number Diff line number Diff line change
@@ -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
28 changes: 28 additions & 0 deletions demo/metaprotocol-brpc/service.yaml
Original file line number Diff line number Diff line change
@@ -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
30 changes: 30 additions & 0 deletions demo/metaprotocol-brpc/serviceentry.yaml
Original file line number Diff line number Diff line change
@@ -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
34 changes: 34 additions & 0 deletions demo/metaprotocol-brpc/traffic-split.yaml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions demo/metaprotocol-brpc/uninstall.sh
Original file line number Diff line number Diff line change
@@ -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
17 changes: 14 additions & 3 deletions demo/uninstall-demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e8dafb5

Please sign in to comment.