'preview' ingress service configuration - jenkins-x

I'd like to know how to add annotations on all preview ingress services definition generated for each jx preview to configure it.
I'm having issues with either header forward or header stripping by nginx. The server behind the preview ingress service is not receiving some headers requests.
Thank you for your help!

Jenkins X uses a controller called exposecontroller to generate ingress rules when applications are deployed. We can add annotations to Kubernetes services which exposecontroller then uses to in turn add to the ingress rule it creates.
You can add a list of annotations to your applications service helm chart which can be found in the repo of your project. Here's an example from a Jenkins X nodejs quickstart and to see an example of where we list multiple annotations that exposecontroller adds to generated ingress rules you can look at some of Jenkins X own charts

Related

How do I use Spring Cloud Kubernetes to programmatically write a ConfigMap value?

I have a service that uses Spring Cloud Kubernetes Config to reload its configuration when a value in a ConfigMap changes. That all works great.
Is it possible to use Spring Cloud Kubernetes (or one of its dependencies) to write a ConfigMap value? I didn't see any examples of this in the documentation (here). Can I do this programmatically, or do I need to call the underlying Kubernetes APIs to do this?
Based on Eugene's reply:
No, this is impossible at the moment to do so. You can go to GitHub and create an issue with the explanation of your use case, and this feature can be created within the future releases.

Swagger Configuration for base url

I have my Spring boot application deployed using the Kubernetes cluster. I have swagger configured using
springfox.documentation.*
Now on the swagger page when I use "Try it out" button, and submit an API request the Request Url is formed like https://java:9080/api/customer/order Which should be https://application.domain.com/api/customer/order
The swagger page opens at https://application.domain.com/swagger-ui.html#
Any idea how could it be fixed?
You need to configure the swagger ui to use your server. Look at this document.
Looks like setting the URL environment variable for the swagger UI should work. For better control, you can get a copy of the dist/index.html page, edit it with your configuration options, and mount it into the swagger container.
My answer is straight forward WRT Kubernetes + SpringBoot.
If it's on kubernetes, Then please try to append your application name in the URL.
Refer application name from deployment.yml
---
apiVersion: v1
kind: deployment
metadata:
name: {app-name}
Example:-
https://application.domain.com/{application-name}/swagger-ui.html

Listing all deployed rest endpoints (spring-boot, tomcat)

I know there is a similar kind of question exist but if works only for glassfish server.
Listing all deployed rest endpoints (spring-boot, jersey)
Is it possible to list all my configured rest-endpoints with spring boot? The actuator lists all existing paths on startup, I want something similar for my custom services, so I can check on startup if all paths are configured correctly and use this info for client calls.
How do I do this? I use #Path/#GET annotations on my service beans and register them via ResourceConfig#registerClasses.
Is there a way to query the Config for all Paths?
Update2: I want to have something like
GET /rest/mycontroller/info
POST /res/mycontroller/update
...
In my opinion, you are already using the right tool (actuator) to answer to your request.
Actuator gives you all the rest method running and you can configure it on your own, by disabling/enabling specific endpoints
If you have a look on the documentationprobably it can help you.
In any case, the default configuration of actuator display the endpoints (built-in in Intellij for your development).

Zuul proxy that discovers routes dynamically

I have a simple Zuul app that has a single route in the application.yml to route to my microservice. It's working.
However, what I'm looking for is a more dynamic solution where I can wire up routes dynamically, either through code or perhaps by POSTing to some Zuul endpoints during a build (possibly by using springfox and a swagger definition from microservices). I could not find an API for Zuul.
I'm somewhat aware of Eureka and that seems like a solution to abstract away the routing by doing discovery. However, I'm curious if there's a solution without introducing Eureka. If there's a way to wire up these routes in Zuul during a build vs. having to edit the application.yml every time.
Thanks in advance.
If you go for Eureka this will actually work ootb. Zuul as packaged in spring cloud will automatically expose every service using its name. So if you register a service called users in Eureka, Zuul will automatically create a route /users forwarding to the instances by default. That will only allow simple url structures but should solve your problem.
Please see the official documentation for details:
By convention, a service with the ID "users", will receive requests from the proxy located at /users (with the prefix stripped). The proxy uses Ribbon to locate an instance to forward to via discovery, and all requests are executed in a hystrix command, …
I'm actually editing a blog post about this exact topic (Routing and Filtering using Spring Cloud Zuul Server) but the source code has been available and working for some time now. Feel free to use it as a reference:
https://bitbucket.org/asimio/zuulserver
https://bitbucket.org/asimio/discoveryserver (in case routes are configured with serviceIds)
https://bitbucket.org/asimio/demo-config-properties/src (Zuul-Server-refreshable.yml where routes are dynamically updated).
Look at the refreshable Spring profile settings. This Zuul setup works with both, hard-coding routes url or discovered using Eureka.
It also acting as a Spring Cloud Config client so that routes could be dynamically updated via Git, which is also covered in another blog post: Refreshable Configuration using Spring Cloud Config Server, Spring Cloud Bus, RabbitMQ and Git.

How to disable tomcat 8 websocket server endpoint autodiscovery

I need to do some processing on the endpoint classes before they can be deployed and then deploy them manually. However it seems simply having a class annotated with #ServerEndpoint in my war is enough to deploy the endpoint in Tomcat and when I try to manually deploy later obviously I can't because the URL has been deployed already. Is there any way to disable the autodiscovery of endpoints?
Looking at the source for the version I'm using - 8.0.28, there's no dedicated option. The code deploying the endpoints is in org.apache.tomcat.websocket.server.WsSci. The quickest 'shurest' hack is to put my endpoints into the javax.websocket package. I elected to use their ServerApplicationConfig hook instead which serves my purposes if with some minor issues.

Resources