Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 15 additions & 7 deletions src/ClusterBootstrap/services/restfulapi/restfulapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: restfulapi
namespace: default
labels:
run: dlwsrestfulapi
run: dlwsrestfulapi
spec:
selector:
matchLabels:
Expand All @@ -15,13 +15,17 @@ spec:
labels:
restfulapi-node: pod
app: restfulapi
annotations:
prometheus.io/scrape: "true"
prometheus.io/path: "/metrics"
prometheus.io/port: "5000"
spec:
{% if cnf["dnsPolicy"] %}
{% if cnf["dnsPolicy"] %}
dnsPolicy: {{cnf["dnsPolicy"]}}
{% endif %}
nodeSelector:
restfulapi: active
hostNetwork: true
hostNetwork: true
containers:
- name: restfulapi
image: {{cnf["worker-dockerregistry"]}}{{cnf["dockerprefix"]}}{{cnf["restfulapi"]}}:{{cnf["dockertag"]}}
Expand All @@ -31,6 +35,10 @@ spec:
name: apiconfig
- mountPath: /var/log/apache2
name: log
ports:
- containerPort: 5000
hostPort: 5000
name: main
{% if False %}
{% for volume in cnf["mountpoints"] %}
{% if cnf["mountpoints"][volume]["mountpoints"] is string and cnf["mountpoints"][volume]["mountpoints"]!="" %}
Expand All @@ -42,7 +50,7 @@ spec:
name: {{mp}}
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
volumes:
- name: apiconfig
Expand All @@ -60,14 +68,14 @@ spec:
{% else %}
{% for mp in cnf["mountpoints"][volume]["mountpoints"] %}
- name: {{mp}}
hostPath:
hostPath:
path: {{cnf["storage-mount-path"]}}/{{mp}}
{% endfor %}
{% endif %}
{% endfor %}
{% endfor %}
{% endif %}
tolerations:
- key: CriticalAddonsOnly
operator: Exists
- key: node-role.kubernetes.io/master
effect: NoSchedule
effect: NoSchedule
8 changes: 8 additions & 0 deletions src/RestAPI/dlwsrestapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
import traceback
import threading

import prometheus_client

CONTENT_TYPE_LATEST = str("text/plain; version=0.0.4; charset=utf-8")

dir_path = os.path.dirname(os.path.realpath(__file__))
with open(os.path.join(dir_path, 'logging.yaml'), 'r') as f:
logging_config = yaml.load(f)
Expand Down Expand Up @@ -1205,6 +1209,10 @@ def endpoint_exist(endpoint_id):
##
api.add_resource(Endpoint, '/endpoints')

@app.route("/metrics/")
def metrics():
return Response(prometheus_client.generate_latest(), mimetype=CONTENT_TYPE_LATEST)

if __name__ == '__main__':
app.run(debug=False,host="0.0.0.0",threaded=True)