-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproduct.yaml
71 lines (69 loc) · 1.85 KB
/
product.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
apiVersion: v1
kind: ConfigMap
metadata:
name: product-server
namespace: sample-sms
data:
server: |
from flask import Flask, json
import requests
api = Flask(__name__)
@api.route('/', defaults={'version': 'v1'}, methods=['GET'])
@api.route('/<version>', methods=['GET'])
def get(version):
detail = requests.get('http://detail-service.sample-sms.svc.cluster.local:5000')
if detail.status_code != 200:
raise Error('GET detail {}'.format(detail.status_code))
review = requests.get('http://review-{}-service.sample-sms.svc.cluster.local:5000'.format(version))
if review.status_code != 200:
raise Error('GET review {}'.format(review.status_code))
product = {'details': detail.json(), 'review': review.json()}
return json.dumps(product)
if __name__ == '__main__':
api.run()
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: deployment-product
namespace: sample-sms
annotations:
medinvention.dev/sms.group: product
medinvention.dev/sms.port: "5000"
medinvention.dev/sms.service: product-service
spec:
selector:
matchLabels:
app: product
replicas: 1
template:
metadata:
labels:
app: product
spec:
containers:
- name: server
image: python:3
command: ['sh', '-c', 'pip install flask requests && python /var/static/server']
ports:
- containerPort: 5000
volumeMounts:
- name: product-server
mountPath: /var/static
volumes:
- name: product-server
configMap:
name: product-server
---
apiVersion: v1
kind: Service
metadata:
name: product-service
namespace: sample-sms
spec:
ports:
- name: http
port: 5000
targetPort: 5000
selector:
app: product