r/openshift • u/Ada_M4 • Dec 18 '20
Open Api specs
Hi, i was assigned a task - Create automatic monitoring of each pod in OS cluster. By monitoring i mean parse each OpenApi spec. on each pod/container in pod. Is there any good approach to do this? I read something about Prometheus by i would like to go for some custom approach. Thank you for answers in advance.
2
u/Shonucic Dec 18 '20
I'm not sure I understand the requirement. Isn't an API spec a static definition of what functions an API exposes? Why would that need to be monitored?
1
u/Ada_M4 Dec 19 '20
Yes it is static definition of app but is there any way i can expose them to other pods? That's my question. Ty for reply btw.
1
u/Shonucic Dec 19 '20
If your applications are web servers and are listening on particular ports you can expose them that way.
You can use a Kubernetes service to expose web applications to one another inside your Kubernetes cluster.
You can use a Kubernetes ingress or an OpenShift route to expose them to applications outside your Kubernetes cluster.
Basically they are exposed in the same way anything else would be exposed - i.e. By listening on a port inside the container and exposing that through the typical Kubernetes machinery.
2
u/Ada_M4 Dec 29 '20 edited Dec 29 '20
Hi, sorry I reply so late, Christmas. I understand that i can expose my app with creating service and route for service, but i need to expose my oas aswell.For example i have nodejs server what has 2 endpoints. And i made openapi.yaml. In index.js I let my server listen on port 8080 and that is it. Now i cant hit those endpoint. But i dont get how can i expose single file. Maybe i am missing something. Anyway ty for your time :).
Only thing that comes to my mind is to expose openapi.yaml as static file from some route for example "/api/docs". Did you meant this approach?
1
u/Shonucic Dec 29 '20 edited Dec 29 '20
That's right! Its the function of a web server, after all, to serve various kinds of files. Nothing different about a yaml file than an html or javascript file.
5
u/DangKilla Dec 18 '20
Sounds like you have some work to do!