diff --git a/demo/common_func.sh b/demo/common_func.sh new file mode 100755 index 000000000..83b1869f6 --- /dev/null +++ b/demo/common_func.sh @@ -0,0 +1,37 @@ +#!/bin/bash + +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# ---------------------------------------------------------------------------- + +#set -x + +function LabelIstioInjectLabel() +{ + ns=$1 + echo $ns + label=`kubectl get po -n istio-system |grep istiod | awk '{print $1}' |xargs kubectl get po -o yaml -n istio-system |grep -A 1 REVIS |grep value: |awk '{print $2}'` + echo $label + if [ $label != "" ];then + kubectl label namespace $ns istio.io/rev=$label --overwrite + else + kubectl label namespace $ns istio-injection=enabled --overwrite=true + fi + return 0; +} + diff --git a/demo/dubbo/install.sh b/demo/dubbo/install.sh index d6126e914..79cb0d4ae 100755 --- a/demo/dubbo/install.sh +++ b/demo/dubbo/install.sh @@ -13,10 +13,12 @@ # limitations under the License. BASEDIR=$(dirname "$0") +source $BASEDIR/../common_func.sh + kubectl create ns dubbo -kubectl label namespace dubbo istio-injection=enabled --overwrite=true +LabelIstioInjectLabel dubbo kubectl apply -f $BASEDIR/dubbo-sample.yaml -n dubbo kubectl apply -f $BASEDIR/serviceentry.yaml -n dubbo kubectl apply -f $BASEDIR/destinationrule.yaml -n dubbo -kubectl apply -f $BASEDIR/virtualservice-traffic-splitting.yaml -n dubbo \ No newline at end of file +kubectl apply -f $BASEDIR/virtualservice-traffic-splitting.yaml -n dubbo diff --git a/demo/kafka/install.sh b/demo/kafka/install.sh index ed435ac2d..92b55834f 100755 --- a/demo/kafka/install.sh +++ b/demo/kafka/install.sh @@ -13,9 +13,11 @@ # limitations under the License. BASEDIR=$(dirname "$0") +source $BASEDIR/../common_func.sh + kubectl create ns kafka -kubectl label namespace kafka istio-injection=enabled --overwrite=true +LabelIstioInjectLabel kafka helm repo add zhaohuabing https://zhaohuabing.github.io/helm-repo helm repo update helm install my-release --set persistence.enabled=false --set zookeeper.persistence.enabled=false zhaohuabing/kafka -n kafka diff --git a/demo/metaprotocol-dubbo/install.sh b/demo/metaprotocol-dubbo/install.sh index 49fb11b9d..5efbf8fc3 100755 --- a/demo/metaprotocol-dubbo/install.sh +++ b/demo/metaprotocol-dubbo/install.sh @@ -13,10 +13,12 @@ # limitations under the License. BASEDIR=$(dirname "$0") +source $BASEDIR/../common_func.sh + kubectl create ns meta-dubbo -kubectl label namespace meta-dubbo istio-injection=enabled --overwrite=true +LabelIstioInjectLabel meta-dubbo kubectl apply -f $BASEDIR/../../k8s/aeraki-bootstrap-config.yaml -n meta-dubbo kubectl apply -f $BASEDIR/dubbo-sample.yaml -n meta-dubbo kubectl apply -f $BASEDIR/serviceentry.yaml -n meta-dubbo -kubectl apply -f $BASEDIR/destinationrule.yaml -n meta-dubbo \ No newline at end of file +kubectl apply -f $BASEDIR/destinationrule.yaml -n meta-dubbo diff --git a/demo/metaprotocol-qza/install.sh b/demo/metaprotocol-qza/install.sh index 5ec6679e2..b2f14a84f 100755 --- a/demo/metaprotocol-qza/install.sh +++ b/demo/metaprotocol-qza/install.sh @@ -13,10 +13,12 @@ # limitations under the License. BASEDIR=$(dirname "$0") +source $BASEDIR/../common_func.sh + kubectl create ns meta-qza -kubectl label namespace meta-qza istio-injection=enabled --overwrite=true +LabelIstioInjectLabel meta-qza kubectl apply -f $BASEDIR/qza-protocol.yaml -n istio-system kubectl apply -f $BASEDIR/../../k8s/aeraki-bootstrap-config.yaml -n meta-qza kubectl apply -f $BASEDIR/qza-sample.yaml -n meta-qza -kubectl apply -f $BASEDIR/destinationrule.yaml -n meta-qza \ No newline at end of file +kubectl apply -f $BASEDIR/destinationrule.yaml -n meta-qza diff --git a/demo/metaprotocol-thrift/install.sh b/demo/metaprotocol-thrift/install.sh index 41990ab94..066c976e0 100755 --- a/demo/metaprotocol-thrift/install.sh +++ b/demo/metaprotocol-thrift/install.sh @@ -13,11 +13,13 @@ # limitations under the License. BASEDIR=$(dirname "$0") +source $BASEDIR/../common_func.sh + kubectl create ns meta-thrift -kubectl label namespace meta-thrift istio-injection=enabled --overwrite=true +LabelIstioInjectLabel meta-thrift kubectl apply -f $BASEDIR/../../k8s/aeraki-bootstrap-config.yaml -n meta-thrift kubectl apply -f $BASEDIR/thrift-sample.yaml -n meta-thrift kubectl apply -f $BASEDIR/destinationrule.yaml -n meta-thrift kubectl create cm rate-limit-config -n meta-thrift --from-file $BASEDIR/rate-limit-server/config.yaml -kubectl apply -f $BASEDIR/rate-limit-server/rate-limit-server.yaml -n meta-thrift \ No newline at end of file +kubectl apply -f $BASEDIR/rate-limit-server/rate-limit-server.yaml -n meta-thrift diff --git a/demo/metaprotocol-trpc/install.sh b/demo/metaprotocol-trpc/install.sh index d5aba08f8..4c68671d3 100755 --- a/demo/metaprotocol-trpc/install.sh +++ b/demo/metaprotocol-trpc/install.sh @@ -13,10 +13,12 @@ # limitations under the License. BASEDIR=$(dirname "$0") +source $BASEDIR/../common_func.sh + kubectl create ns meta-trpc -kubectl label namespace meta-trpc istio-injection=enabled --overwrite=true +LabelIstioInjectLabel meta-trpc kubectl apply -f $BASEDIR/trpc-protocol.yaml -n istio-system kubectl apply -f $BASEDIR/../../k8s/aeraki-bootstrap-config.yaml -n meta-trpc kubectl apply -f $BASEDIR/trpc-sample.yaml -n meta-trpc -kubectl apply -f $BASEDIR/destinationrule.yaml -n meta-trpc \ No newline at end of file +kubectl apply -f $BASEDIR/destinationrule.yaml -n meta-trpc diff --git a/demo/metaprotocol-videopacket/install.sh b/demo/metaprotocol-videopacket/install.sh index 7d6470a9b..c5a0d173f 100755 --- a/demo/metaprotocol-videopacket/install.sh +++ b/demo/metaprotocol-videopacket/install.sh @@ -13,10 +13,12 @@ # limitations under the License. BASEDIR=$(dirname "$0") +source $BASEDIR/../common_func.sh + kubectl create ns meta-videopacket -kubectl label namespace meta-videopacket istio-injection=enabled --overwrite=true +LabelIstioInjectLabel meta-videopacket kubectl apply -f $BASEDIR/videopacket-protocol.yaml -n istio-system kubectl apply -f $BASEDIR/../../k8s/aeraki-bootstrap-config.yaml -n meta-videopacket kubectl apply -f $BASEDIR/videopacket-sample.yaml -n meta-videopacket -kubectl apply -f $BASEDIR/destinationrule.yaml -n meta-videopacket \ No newline at end of file +kubectl apply -f $BASEDIR/destinationrule.yaml -n meta-videopacket diff --git a/demo/thrift/install.sh b/demo/thrift/install.sh index c75c83988..e5c9ab251 100755 --- a/demo/thrift/install.sh +++ b/demo/thrift/install.sh @@ -13,9 +13,11 @@ # limitations under the License. BASEDIR=$(dirname "$0") +source $BASEDIR/../common_func.sh + kubectl create ns thrift -kubectl label namespace thrift istio-injection=enabled --overwrite=true +LabelIstioInjectLabel thrift kubectl apply -f $BASEDIR/thrift-sample.yaml -n thrift kubectl apply -f $BASEDIR/destinationrule.yaml -n thrift -kubectl apply -f $BASEDIR/virtualservice-traffic-splitting.yaml -n thrift \ No newline at end of file +kubectl apply -f $BASEDIR/virtualservice-traffic-splitting.yaml -n thrift