Multiple API routes within a service

I have a sample Python flask application that renders and basic html page on “/” , inserts data into mongo on “/insertdata” and displays all data on screen for route “/displaydata” .

Sample code below -

from flask import Flask, redirect, url_for, request,render_template
app = Flask(__name__)

@app.route('/')
def result():
   return render_template('index.html')

@app.route('/insertdata',methods=['POST','GET'])
def url_shorten():
    ''' Inserts data from UI '''
    # Insert Data From UI (index page)
    return "Susccessful"

@app.route('/displaydata',methods=['POST','GET'])
def url_widen():
    '''Display all data'''
    # Display all data insertes in collection on display button click
    return "Mongo o/p"

if __name__ == '__main__':
   app.run(debug = True)

I Have deployed this sample application in a kubernetes environment (AKS) .

To configure behind kong (db-mode opensource), i have created a service with following url -
http://sampleapp.samplens.svc.cluster.local:5555/

And the corresponding route to be path = “/sampleapp” (Strip path and host disabled)
On hitting the kong proxy endpoint /sampleapp , i am getting this o/p

{
  "message":"An invalid response was received from the upstream server"
}

Also do i need to create separate services in kong for each endpoint insertdata & displaydata and corresponding routes for the same ??

Is it possible to configure a microservice in KONG with a single route, for ex in this instance /sampleapp must perform all operations in UI without any breakage like insert and delete of data !! & without having to create individual service and routes for all endpoints within the microservice !!

IIRC this message indicates that the upstream reset the connection or something similar. Do you have logs of the request from within the service itself that could point to what happened here?


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ