Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add configurable base context to angular and spring app #357

Open
wants to merge 1 commit into
base: 1.7.x
Choose a base branch
from

Conversation

fhopfensperger
Copy link

This PR allows to configure a subcontext (sub http path) for the Angular and Spring boot app and Keycloak. For example, the services then listen to the following urls: https://example.com/mock-server/auth/ & https://example.com/mock-server/microcks/

Work is still in progress, but I already have a working deployment up and running on my Azure Kubernetes cluster with Istio.

Signed-off-by: Florian Hopfensperger florian.hopfensperger@de.ibm.com

@fhopfensperger fhopfensperger force-pushed the add_configurable_contextpath branch 2 times, most recently from 3511af7 to 4e3abe8 Compare March 7, 2021 07:54
@lbroudoux
Copy link
Member

Hi @fhopfensperger

Could you explain the motivation with this PR? We had previous discussion (like for example in #320) about that and ended-up with it not being a harde requirement because you could mostly always find a gateway configuration to handle that. Is there some specific issues we wouldn't be able to handle ?

PR seems to involve a large set of resources...

Copy link
Member

@lbroudoux lbroudoux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had some questions about required changes ...
Also it would be nice removing unnecessary formatting changes (like introduced spaces or new lines) to ease-up a complete review later.

Comment on lines +22 to +24
keycloak.cors=true
keycloak.cors-max-age=3600
keycloak.cors-allowed-methods=POST, PUT, DELETE, GET, OPTIONS
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you explain why this is required?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that all APIs that are secured by Keycloak could no longer be called locally by the Angular app in development mode. Background is (see comment on proxy.conf), the angular app is accessible at http://localhost:4200 and the spring boot app is accessible at http://localhost:8080. So we would have a CORS issue. Link to the Keycloak issue.

"browserTarget": "microcks-ui:build",
"proxyConfig": "proxy.conf.json"
},
"browserTarget": "microcks-ui:build" },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

proxy.conf.json is necessary while in development mode. I use ng serve to serve the frontend with hot-reload and backend is ran with mvn spring-boot:run

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually i do the same with ng serve and mvn spring-boot:run but I changed that the Angular services do not use the hardcoded /api/ path instead the (https://github.com/fhopfensperger/microcks/blob/4e3abe87d93030588c2ebc6bd50f115db4a5282c/webapp/src/main/webapp/src/app/services/importers.service.ts#L27) services load the actual address + path from the environment. Because of this I have configured the environment.ts file and removed the not longer needed proxy.conf.json:

export const environment = {
  production: false,
  apiUrl: 'http://localhost:8080/',
  baseContext: '/'
};

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But something just comes to my mind, we could define in the environment only the / as apiUrl and keep the proxy.conf. Maybe we can fix the CORS issue as well. If you want I can try it out.

Comment on lines 21 to 23
console.log = () => { };
console.warn = () => { };
console.error = () => { };
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great idea but I would have let console.error though.. to be sure to grab critical messages.

@@ -4,7 +4,7 @@ For development purposes, frontend GUI and backend APIs have been separated and
* Frontend is an Angular 6 application served by `ng serve` with livereload enabled,
* Backend is a Spring Boot application served by Boot internal server

We also need a Keycloak server running on port `8180`.
We also need a Keycloak server running on port `8180`. You can run the Keycloak server as a container from docker-compose, just adjust the exposed port to `8180`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@@ -25,7 +25,7 @@ $ ./standalone.sh -Djboss.socket.binding.port-offset=100
In a terminal, start frontend GUI server using NG :

```
$ cd src/main/webapp
$ cd webapp/src/main/webapp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +54 to +55
spring.resources.static-locations=classpath:/META-INF/resources/,classpath:/resources/,classpath:/static/,classpath:/public/,file:/deployments/assets/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't understand why this should be now necessary ... 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fhopfensperger
Copy link
Author

Hi @lbroudoux
First of all thank you for the great product. You really surprised me now because at the moment I'm still working on the helm chart when my daily business allows it.

Main reason for the PR was the fact that I have a Kubernetes cluster that has a single external DNS. The DNS entry is routed to the Istio ingress gateway, which then decides which service to route the request to based on sub-path. So unfortunately I cannot implement what has been described in #320, because I don't "have" an "typical" ingress controller. Also when I started the PR, there was no solution for the issue. 😅

Right now I have the implementation running in an AKS cluster and am in the process of testing the same locally on my minikube and CRC with and without sub path.

Hi @fhopfensperger

Could you explain the motivation with this PR? We had previous discussion (like for example in #320) about that and ended-up with it not being a harde requirement because you could mostly always find a gateway configuration to handle that. Is there some specific issues we wouldn't be able to handle ?

PR seems to involve a large set of resources...

@fhopfensperger
Copy link
Author

Had some questions about required changes ...
Also it would be nice removing unnecessary formatting changes (like introduced spaces or new lines) to ease-up a complete review later.

Would love to fix the formatting issues, what type of formatter do you use for the Typescript and Java code?

@fhopfensperger fhopfensperger force-pushed the add_configurable_contextpath branch 4 times, most recently from 14adaf7 to 1c861cb Compare March 11, 2021 11:47
@fhopfensperger
Copy link
Author

fhopfensperger commented Mar 11, 2021

Short update from my side. The current implementation (Rest Mocking functionality) has been successfully tested on the following platforms and ingress types:

  • Azure Kubernetes Service: Istio Ingressgateway with workload routing based on a base context like /mock-server/microcks/ using VirtualServices
  • Minikube: Ingress Nginx with and without base context
  • OpenShift on IBM Cloud: OpenShift Router with TLS edge-termination; with and without base context

I have not tested the Async and the Testing feature. Could you please help me with this? If you want to test the current implementation yourself, feel free to use the container image docker.io/fhopfensperger/microcks:1.1.0. (Please ignore the tag that I just randomly selected).

Because:
- Allows ingress subpath configuration
- Avoids separate external dns names for services

Signed-off-by: Florian Hopfensperger <florian.hopfensperger@de.ibm.com>
@fhopfensperger fhopfensperger changed the title WIP: Add configurable base context to angular and spring app Add configurable base context to angular and spring app Mar 15, 2021
@keiranbatten-nzta
Copy link

@fhopfensperger @lbroudoux what is the reason for the inactivity on this PR?

@lbroudoux
Copy link
Member

lbroudoux commented May 10, 2023

Hi,
We didn't have any other requests for this feature and focused on some other ones. Is this something that would be still useful?

@lbroudoux lbroudoux changed the base branch from master to 1.7.x May 10, 2023 12:24
@lbroudoux
Copy link
Member

I just updated to branch 1.7.x where current development goes to refresh the impact of the Pull Request

@keiranbatten-nzta
Copy link

Hi,

Thanks for your response. I would definitely find this useful. We are looking to deploy in Azure Kubernetes Service using application gateway ingress controller and the only option we have is to run it at a different context path than root. Keycloak now supports this using the --hostname-url and --admin-hostname-url options in the start command or similarly by setting environment variables.

@lbroudoux
Copy link
Member

Great! As I think I've been too long to answer to keep @fhopfensperger in the loop - sorry for that! - I'd need some help for review, testing and validation.

@keiranbatten-nzta Would you be ready to help on that tasks if I push this one up?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants