Skip to content

Commit

Permalink
initial zipkin and upstream integration
Browse files Browse the repository at this point in the history
  • Loading branch information
christian-posta committed May 11, 2017
1 parent 933f00e commit fed3746
Show file tree
Hide file tree
Showing 4 changed files with 87 additions and 22 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ target
.project
.settings
spring-boot/**/project/**
**/cli/**
ticket-monster-msa/**/project/**
camel/**/project/**
service-mesh/**/project/**
Expand Down
64 changes: 46 additions & 18 deletions service-mesh/istio/bookinfo/demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,36 +4,64 @@

APP_DIR=app

ISTIO_LIST="istioctl list"
ISTIOCTL="$(which istioctl)"

ISTIO_LIST="$ISTIOCTL list"

if [ "$1" == "--upstream" ]; then
echo "installing demo from upstream..."
APP_DIR=$(relative ../setup/project/istio/demos/apps/bookinfo)
source $(relative ../setup/project/istio/istio.VERSION)
ISTIO_LIST="istioctl get"

ISTIOCTL="$(relative ../setup/cli/istioctl)"
ISTIO_LIST="$ISTIOCTL get"

fi

echo "Using APPDIR=$APP_DIR"
echo "Using istioctl from $ISTIOCTL"
echo "Press <enter> to continue..."
read -s

# Let's find the dashboard URL
GRAFANA_HOST=$(oc get pod $(oc get pod | grep -i running | grep grafana | awk '{print $1 }') -o yaml | grep hostIP | cut -d ':' -f2 | xargs)
GRAFANA_PORT=$(oc get svc/grafana -o yaml | grep nodePort | cut -d ':' -f2 | xargs)
ISTIO_GRAFANA_URL=http://$GRAFANA_HOST\:$GRAFANA_PORT/dashboard/db/istio-dashboard

SERVICE_GRAPH=$(kubectl get po -l app=servicegraph -o jsonpath={.items[0].status.hostIP}):$(kubectl get svc servicegraph -o jsonpath={.spec.ports[0].nodePort})
SERVICE_GRAPH_URL=http://$SERVICE_GRAPH/dotviz



ISTIO_DASHBOARD_URL=http://$GRAFANA_HOST\:$GRAFANA_PORT/dashboard/db/istio-dashboard

desc "Let's open the grafana dashboard"
run "open $ISTIO_DASHBOARD_URL"
desc "Let's open the grafana and zipkin dashboard"
run "open $ISTIO_GRAFANA_URL; open $SERVICE_GRAPH_URL"

if [ "$2" == "--zipkin" ]; then
# Let's find the zipkin URL
ZIPKIN_HOST=$(oc get pod $(oc get pod | grep -i running | grep zipkin | awk '{print $1 }') -o yaml | grep hostIP | cut -d ':' -f2 | xargs)
ZIPKIN_PORT=$(oc get svc/zipkin -o yaml | grep nodePort | cut -d ':' -f2 | xargs)
ISTIO_ZIPKIN_URL=http://$ZIPKIN_HOST\:$ZIPKIN_PORT/
run "open $ISTIO_ZIPKIN_URL"
fi

desc "let's take a look at the app"
run "cat $(relative $APP_DIR/bookinfo.yaml)"


desc "let's add the istio proxy"
run "istioctl kube-inject -f $(relative $APP_DIR/bookinfo.yaml)"
if [ "$2" == "--zipkin" ]; then
run "$ISTIOCTL kube-inject --hub docker.io/ijsnellf --tag zipkin -f $(relative $APP_DIR/bookinfo.yaml)"
else
run "$ISTIOCTL kube-inject -f $(relative $APP_DIR/bookinfo.yaml)"
fi


desc "deploy the bookinfo app with istio proxy enabled"
run "kubectl apply -f <(istioctl kube-inject -f $(relative $APP_DIR/bookinfo.yaml))"
if [ "$2" == "--zipkin" ]; then
run "kubectl apply -f <($ISTIOCTL kube-inject --hub docker.io/ijsnellf --tag zipkin -f $(relative $APP_DIR/bookinfo.yaml))"
else
run "kubectl apply -f <($ISTIOCTL kube-inject -f $(relative $APP_DIR/bookinfo.yaml))"
fi


desc "take a look at the services we now have"
run "kubectl get services"
Expand All @@ -42,7 +70,7 @@ desc "take a look at the pods we now have"
run "kubectl get pods"

# define the gateway rul
GATEWAY_URL=$(kubectl get po -l infra=istio-ingress-controller -o jsonpath={.items[0].status.hostIP}):$(kubectl get svc istio-ingress-controller -o jsonpath={.spec.ports[0].nodePort})
GATEWAY_URL=$(kubectl get po -l istio=ingress -o jsonpath={.items[0].status.hostIP}):$(kubectl get svc istio-ingress -o jsonpath={.spec.ports[0].nodePort})


backtotop
Expand All @@ -63,7 +91,7 @@ read -s
run "cat $(relative $APP_DIR/route-rule-all-v1.yaml)"

desc "update the istio routing rules"
run "istioctl create -f $(relative $APP_DIR/route-rule-all-v1.yaml)"
run "$ISTIOCTL create -f $(relative $APP_DIR/route-rule-all-v1.yaml)"

backtotop
desc "Now go to the app and make sure all the traffic goes to the v1 reviews"
Expand All @@ -89,13 +117,13 @@ read -s
run "cat $APP_DIR/route-rule-reviews-test-v2.yaml"

desc "Let's make the change"
run "istioctl create -f $APP_DIR/route-rule-reviews-test-v2.yaml"
run "$ISTIOCTL create -f $APP_DIR/route-rule-reviews-test-v2.yaml"

desc "let's look at the route rules"
read -s
run "$ISTIO_LIST route-rule"
run "istioctl get route-rule reviews-test-v2"
run "istioctl get route-rule reviews-default"
run "$ISTIOCTL get route-rule reviews-test-v2"
run "$ISTIOCTL get route-rule reviews-default"

desc "No go to your browser and refresh the app.. should still see v2 of the reviews"
desc "But if you login as jason, you should see the new, v2"
Expand All @@ -114,7 +142,7 @@ read -s
desc "see source here: https://github.com/istio/istio/blob/master/demos/apps/bookinfo/src/reviews/reviews-application/src/main/java/application/rest/LibertyRestEndpoint.java#L64"
read -s
run "cat $(relative $APP_DIR/destination-ratings-test-delay.yaml)"
run "istioctl create -f $(relative $APP_DIR/destination-ratings-test-delay.yaml)"
run "$ISTIOCTL create -f $(relative $APP_DIR/destination-ratings-test-delay.yaml)"

backtotop
desc "Now go to the productpage and test the delay"
Expand All @@ -130,7 +158,7 @@ read -s
backtotop
desc "We could change the fault injection to a shorter duration"
read -s
desc "cat $APP_DIR/destination-ratings-test-delay.yaml | sed s/5.0/2.5/g | istioctl replace"
desc "cat $APP_DIR/destination-ratings-test-delay.yaml | sed s/5.0/2.5/g | $ISTIOCTL replace"
read -s
desc "Or we should fix the bug in the reviews app (ie, should not be 10s timeout)"
read -s
Expand All @@ -148,7 +176,7 @@ desc "Run some tests to verify the 50/50 split"
read -s

desc "Install our new routing rule"
run "istioctl replace -f $(relative $APP_DIR/route-rule-reviews-50-v3.yaml)"
run "$ISTIOCTL replace -f $(relative $APP_DIR/route-rule-reviews-50-v3.yaml)"

desc "If we're confident now this is a good change, we can route all traffic that way"
run "istioctl replace -f $(relative $APP_DIR/route-rule-reviews-v3.yaml)"
run "$ISTIOCTL replace -f $(relative $APP_DIR/route-rule-reviews-v3.yaml)"
17 changes: 15 additions & 2 deletions service-mesh/istio/setup/cleanup.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
. $(dirname ${BASH_SOURCE})/../../../util.sh


rm $(relative cli/istioctl)

# delete addons
kubectl delete deploy/grafana
Expand All @@ -23,4 +24,16 @@ kubectl delete svc/istio-manager
kubectl delete svc/istio-mixer

kubectl delete cm/mixer-config
kubectl delete cm/istio
kubectl delete cm/istio

# some of the new things
kubectl delete cm/prometheus
kubectl delete svc/istio-egress
kubectl delete svc/istio-ingress
kubectl delete svc/zipkin
kubectl delete deploy/istio-egress
kubectl delete deploy/istio-ingress
kubectl delete deploy/zipkin
kubectl delete sa/istio-ingress-service-account
kubectl delete sa/istio-manager-service-account
kubectl delete deploy/servicegraph
27 changes: 25 additions & 2 deletions service-mesh/istio/setup/demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,43 @@ if [ "$1" == "--upstream" ]; then
echo "installing from upstream..."
if [ -d "$(relative project/istio)" ]; then
pushd $(relative project/istio)
git reset --hard
git pull
popd
else
git clone https://github.com/istio/istio.git $(relative project/istio)
fi
ADDONS=$(relative project/istio/kubernetes/addons)
INSTALL=$(relative project/istio/kubernetes/istio-install)

if [ "$2" == "--zipkin" ]; then
pushd $(relative project/istio)
curl -s -L https://gist.github.com/christian-posta/d6192ada85ed65a8a99047e38f2779e0/raw | git apply -
popd
fi

ADDONS=$(relative project/istio/install/kubernetes/addons)
INSTALL=$(relative project/istio/install/kubernetes/istio.yaml)

#Download upstream client
source $(relative project/istio/istio.VERSION)
curl -s ${ISTIOCTL_URL}/istioctl-osx > $(relative cli/istioctl)
chmod +x $(relative cli/istioctl)
fi

echo "Using $INSTALL for the installation"
echo "Using $ADDONS for the addons"
if [ "$2" = "--zipkin" ]; then
echo "Yay! Installing Zipkin too!"
fi
echo "Press <enter> to continue..."
read -s


echo "Let's install the istio addons"
kubectl create -f $ADDONS

if [ "$2" = "--zipkin" ]; then
curl -s -L https://gist.github.com/christian-posta/c5f61d68913c35cdb3ea005e17a8adbd/raw | kubectl create -f -
fi

echo "Let's install the istio ingress controller, mixer, and manager"
kubectl create -f $INSTALL

0 comments on commit fed3746

Please sign in to comment.