test traffic split and auto retry

This commit is contained in:
marcel-dempers 2020-10-24 20:36:10 +11:00 committed by Marcel Dempers
parent 17ad5d11a7
commit fce0fb89b2
4 changed files with 171 additions and 0 deletions

View File

@ -0,0 +1,99 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1" />
<link rel="stylesheet" href="bootstrap.min.css">
<title>Video Catalog</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<article>
<nav class="navbar navbar-light bg-light">
<span class="navbar-brand mb-0 h1">Video Catalog: V2</span>
</nav>
<div ng-app="videos" ng-controller="videosController" class="container">
<div class="row">
<div id="accordion">
<div id="{{ l.id }}" ng-repeat="l in playlist" class="card">
<div class="card-header" id="heading{{ l.id }}">
<h5 class="mb-0" style="text-align: center;">
<button class="btn btn-link" data-toggle="collapse" data-target="#collapse{{ l.id }}" aria-expanded="true"
aria-controls="collapse{{ l.id }}">
{{ l.name }}
</button>
</h5>
</div>
<div id="collapse{{ l.id }}" class="collapse show" aria-labelledby="heading{{ l.id }}" data-parent="#accordion">
<div class="card-body">
<div class="row">
<div class="col card" ng-repeat="v in l.videos" style="width: 18rem;">
<img class="card-img-top" src="{{ v.imageurl }}" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">{{ v.title }}</h5>
<p class="card-text">{{ v.description }}</p>
<a href="{{ v.url }}" class="btn btn-primary">Watch</a>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</article>
<hr />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"
integrity="sha384-uefMccjFJAIv6A+rW+L4AHf99KvxDjWSu1z9VI8SKNVmz4sk7buKt/6v9KI65qnm"
crossorigin="anonymous"></script>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.6.9/angular.min.js"></script>
<script>
var model = {
playlist: [],
};
var playlistApiUrl = "";
if (location.hostname == "localhost"){
playlistApiUrl = "http://localhost:81/"
} else {
playlistApiUrl = "http://" + location.hostname + "/api/playlists"
}
var app = angular.module('videos', []);
app.controller('videosController', function ($scope, $http) {
$http.get(playlistApiUrl)
.then(function (response) {
console.log(response);
//$scope.model = model;
for (i = 0; i < response.data.length; ++i) {
model.playlist.push(response.data[i]);
}
$scope.playlist = response.data;
});
});
</script>
</body>
</html>

View File

@ -0,0 +1,14 @@
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: videos-api
spec:
hosts:
- videos-api
http:
- route:
- destination:
host: videos-api
retries:
attempts: 10
perTryTimeout: 2s

View File

@ -0,0 +1,43 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: videos-web-v2
labels:
app: videos-web-v2
spec:
selector:
matchLabels:
app: videos-web-v2
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
labels:
app: videos-web-v2
spec:
containers:
- name: videos-web-v2
image: aimvector/service-mesh:videos-web-2.0.0
imagePullPolicy : Always
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: videos-web-v2
labels:
app: videos-web-v2
spec:
type: ClusterIP
selector:
app: videos-web-v2
ports:
- protocol: TCP
name: http
port: 80
targetPort: 80

View File

@ -0,0 +1,15 @@
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: videos-web
spec:
hosts:
- servicemesh.demo
http:
- route:
- destination:
host: videos-web-v2
weight: 50
- destination:
host: videos-web
weight: 50