| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repo provides an example of remote debugging a Python Application(Flask) on Kubernetes/OpenShift with VSCode.
eval "$(curl https://raw.githubusercontent.com/MoOyeg/testFlask/master/sample_env)"Create necessary projects
oc new-project $NAMESPACE_DEV
oc new-project $NAMESPACE_PROD
Create a new application on openshift, using the oc new-app command.We will specificy environment variables we pre-configured in our entrypoint bash script to enable debugging for our application
oc new-app https://github.com/MoOyeg/testFlask.git --name=$APP_NAME -l app=testflask --env=REMOTE_DEBUG="true" --env=DEBUG_PORT=5679 -n $NAMESPACE_DEV --strategy=dockerIf the previous command gives this error - error: unable to locate any images in image streams, local docker images with name "image-registry.openshift-image-registry.svc:5000/openshift/ubi8"
oc tag --source=docker registry.redhat.io/ubi8/ubi:latest ubi8:latest -n openshiftExpose the service to the outside world with an openshift route
oc expose svc/$APP_NAME --port 8080 -n $NAMESPACE_DEVIf app build above is successful our application pod should start in debug mode. We can confirm by looking at application logs.
oc logs deployment/$APP_NAME -n $NAMESPACE_DEVWith our application debugger listening we need to port-forward from our debug service to allow vscode connect.
oc port-forward service/$APP_NAME -n $NAMESPACE_DEV --address 0.0.0.0 5679:5679With our debugger accessible we need to configure our vscode instance to connect to the debugging session. Port-Forward session has to continously run for duration of debugging
Clone the original source code
git clone https://github.com/MoOyeg/testFlask.gitOpen folder in VSCode
Set your vscode setting.json to point to our created instance above and use the remote debug configuration. I have provided a sample settings.json with a remote debugger attach and local development example under .vscode folder.
Start debug session in vscode, we should see log in our application show a debug connection has been made.
oc logs deployment/$APP_NAME -n $NAMESPACE_DEVCalling our route URL for the application should trigger our breakpoints.
curl $(oc get route/$APP_NAME -n $NAMESPACE_DEV -o jsonpath='{.spec.host}')| Back | FazBrowse Home | New Git URL |