From 29fdb950f17ef2e415bc626a9e375713fd667081 Mon Sep 17 00:00:00 2001 From: Beppe Vanrolleghem Date: Thu, 5 Mar 2020 09:55:12 +0100 Subject: [PATCH] aanpassing deployment voor traffic mirror test --- deploy.yaml | 73 ++++++++++++++++++++++++++++++++++++++-------- serverD/app.py | 24 +++++++++++++++ serverD/dockerfile | 10 +++++++ serverD/readme.md | 1 + serverD/test.txt | 8 +++++ 5 files changed, 104 insertions(+), 12 deletions(-) create mode 100644 serverD/app.py create mode 100644 serverD/dockerfile create mode 100644 serverD/readme.md create mode 100644 serverD/test.txt diff --git a/deploy.yaml b/deploy.yaml index c1731ea..6639d07 100644 --- a/deploy.yaml +++ b/deploy.yaml @@ -88,6 +88,44 @@ spec: ports: - containerPort: 6000 --- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: server-d + namespace: istio-project-1 +spec: + replicas: 1 + selector: + matchLabels: + app: "project-1" + mirror: "true" + template: + metadata: + labels: + app: "project-1" + mirror: "true" + spec: + containers: + - name: front-end + image: beppev/server-d:latest + ports: + - containerPort: 6000 +--- +apiVersion: v1 +kind: Service +metadata: + name: mirror-service + namespace: istio-project-1 + labels: + app: "project-1" +spec: + selector: + mirror: "true" + ports: + - name: http + protocol: TCP + port: 6000 +--- apiVersion: v1 kind: Service metadata: @@ -174,6 +212,14 @@ spec: port: number: 5000 host: expose-server-service + - match: + - uri: + prefix: /get + route: + - destination: + port: + number: 7000 + host: mirror-service --- # TODO fix gateway zodat we ingress gateway kunnen gebruike ipv de fuken loadbalancer. apiVersion: networking.istio.io/v1alpha3 kind: Gateway @@ -209,15 +255,18 @@ spec: - match: - port: 6000 route: - - destination: - host: server-check - port: - number: 6000 - subset: v1 - weight: 50 - - destination: - host: server-check - port: - number: 6000 - subset: v2 - weight: 50 + - destination: + host: server-check + port: + number: 6000 + subset: v1 + weight: 50 + - destination: + host: server-check + port: + number: 6000 + subset: v2 + weight: 50 + mirror: + host: mirror-service + mirror_percent: 100 \ No newline at end of file diff --git a/serverD/app.py b/serverD/app.py new file mode 100644 index 0000000..d3a2bc7 --- /dev/null +++ b/serverD/app.py @@ -0,0 +1,24 @@ +from flask import Flask +from flask import jsonify + +app = Flask(__name__) +requ = "" + + +@app.route('/', defaults={'path': ''}) +@app.route('/') +def doRequest(path): + requ = +path + ' \n' + with open("test.txt", "a") as myfile: + myfile.write(requ) + return "None" + + +@app.route('/get') +def get(): + with open("test.txt", "r") as infile: + return 'we have something: ' + '\n '.join(infile.readlines()) + + +if __name__ == '__main__': + app.run(debug=True, host="0.0.0.0", port=7000) diff --git a/serverD/dockerfile b/serverD/dockerfile new file mode 100644 index 0000000..643443f --- /dev/null +++ b/serverD/dockerfile @@ -0,0 +1,10 @@ +from python:3.7 + +copy . /app +workdir /app + +run pip install -r requirements.txt +expose 7000 +entrypoint [ "python" ] + +cmd [ "app.py" ] \ No newline at end of file diff --git a/serverD/readme.md b/serverD/readme.md new file mode 100644 index 0000000..1d3c326 --- /dev/null +++ b/serverD/readme.md @@ -0,0 +1 @@ +dees is de mirror server \ No newline at end of file diff --git a/serverD/test.txt b/serverD/test.txt new file mode 100644 index 0000000..567e458 --- /dev/null +++ b/serverD/test.txt @@ -0,0 +1,8 @@ +another request +another request +another request +another request +another request favicon.ico +another request +another request server-a +another request favicon.ico