Skip to content

Commit

Permalink
add istio scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Toeplitz committed Nov 12, 2017
1 parent aa88b01 commit fc5ae5a
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 9 deletions.
22 changes: 19 additions & 3 deletions kube_scripts/istio/helloworld.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ kind: Deployment
metadata:
name: helloworld-v1
spec:
replicas: 1
replicas: 4
template:
metadata:
labels:
Expand All @@ -27,6 +27,23 @@ spec:
containers:
- name: helloworld
image: gcr.io/pwave-cloud/github-toeplitz-pwave-cloud:b14b148dcdb8a904e9201446cecd96917633553f
env:
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MY_POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
resources:
requests:
cpu: "100m"
Expand All @@ -44,8 +61,7 @@ spec:
rules:
- http:
paths:
- path: /hello
backend:
- backend:
serviceName: helloworld
servicePort: 50051
---
10 changes: 10 additions & 0 deletions kube_scripts/istio/lb.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: config.istio.io/v1alpha2
kind: RouteRule
metadata:
name: ratings-lb-policy
namespace: default # optional (default is "default")
spec:
destination:
name: helloworld
loadBalancing:
name: ROUND_ROBIN
2 changes: 1 addition & 1 deletion kube_scripts/istio/pwave.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ spec:
rules:
- http:
paths:
- path: /hello
backend:
serviceName: helloworld
servicePort: 5000
path: /
---
8 changes: 8 additions & 0 deletions kube_scripts/istio/shutdown.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/bash

kubectl delete -f /home/ms/istio-0.2.12/install/kubernetes/istio.yaml
kubectl delete -f /home/ms/istio-0.2.12/install/kubernetes/istio-initializer.yaml
kubectl delete -f /home/ms/istio-0.2.12/install/kubernetes/addons/prometheus.yaml
kubectl delete -f /home/ms/istio-0.2.12/install/kubernetes/addons/grafana.yaml

#istioctl delete -f lb.yaml
17 changes: 15 additions & 2 deletions kube_scripts/istio/startup.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
#!/bin/bash

kubectl apply -f /home/ms/istio-0.2.12/install/kubernetes/istio.yaml
kubectl apply -f /home/ms/istio-0.2.12/install/kubernetes/istio-initializer.yaml
kubectl create -f /home/ms/istio-0.2.12/install/kubernetes/istio.yaml
kubectl create -f /home/ms/istio-0.2.12/install/kubernetes/istio-initializer.yaml
kubectl apply -f /home/ms/istio-0.2.12/install/kubernetes/addons/prometheus.yaml
kubectl apply -f /home/ms/istio-0.2.12/install/kubernetes/addons/grafana.yaml

# From https://istio.io/docs/reference/config/traffic-rules/destination-policies.html
#istioctl create -f lb.yaml

## Istio dashboard
# kubectl -n istio-system port-forward $(kubectl -n istio-system get pod -l app=grafana -o jsonpath='{.items[0].metadata.name}') 3000:3000 &
#
# http://localhost:3000/dashboard/db/istio-dashboard
#


11 changes: 11 additions & 0 deletions kube_scripts/istio/timeout.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: config.istio.io/v1alpha2
kind: RouteRule
metadata:
name: reviews-default
spec:
destination:
name: helloworld
httpReqTimeout:
simpleTimeout:
timeout: 10000000s

2 changes: 1 addition & 1 deletion pwave_client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ int main(int argc, char** argv) {
// localhost at port 50051). We indicate that the channel isn't authenticated
// (use of InsecureChannelCredentials()).
/* GreeterClient greeter(grpc::CreateChannel("localhost:50051", grpc::InsecureChannelCredentials())); */
GreeterClient greeter(grpc::CreateChannel("35.188.65.177:50051/hello", grpc::InsecureChannelCredentials()));
GreeterClient greeter(grpc::CreateChannel("104.154.238.95:80", grpc::InsecureChannelCredentials()));
/* GreeterClient greeter(grpc::CreateChannel("104.197.15.119:31140", grpc::InsecureChannelCredentials())); */

for (int i = 0; i < 1000; i++) {
Expand Down
6 changes: 4 additions & 2 deletions pwave_client_async.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ int main(int argc, char** argv) {
// localhost at port 50051). We indicate that the channel isn't authenticated
// (use of InsecureChannelCredentials()).
/* GreeterClient greeter(grpc::CreateChannel("192.168.1.200:30080", grpc::InsecureChannelCredentials())); */
GreeterClient greeter(grpc::CreateChannel("10.11.241.49:30080", grpc::InsecureChannelCredentials()));
GreeterClient greeter(grpc::CreateChannel("104.154.238.95:80", grpc::InsecureChannelCredentials()));
/* GreeterClient greeter(grpc::CreateChannel("192.168.1.200:80", grpc::InsecureChannelCredentials())); */

// Spawn reader thread that loops indefinitely
Expand All @@ -116,8 +116,10 @@ int main(int argc, char** argv) {
std::string user("world " + std::to_string(i));
printf("sending call %d\n", i);
greeter.SayHello(user); // The actual RPC call!
std::this_thread::sleep_for(std::chrono::milliseconds(500));
/* std::this_thread::sleep_for(std::chrono::milliseconds(500)); */
std::this_thread::sleep_for(std::chrono::milliseconds(5));
}
printf("done\n");

std::cout << "Press control-c to quit" << std::endl << std::endl;
thread_.join(); //blocks forever
Expand Down

0 comments on commit fc5ae5a

Please sign in to comment.