I am deploying plain Java application and spring application(without spring boot) into kubernetes.
I have planned to mount config map into a volume and refer it as part of deployment yaml file.
Query:
If I update the config map, I want the application to reload the properties .
I have seen some references where this can be done with spring cloud and it provides access to kubernetes as well.
I want to know if by any way the same can be done for normal Java application and a Spring application.
Related
I am trying to configure some key/value pairs for my Azure web application using app settings section from Azure portal to my Spring boot java class. I have Spring boot project, now i want to fetch some static URL and other config values from the Aure web app that my Spring boot project hosted. How to get that?
For example as below. I have added activeDirectotyEnabled key and value as true in Azure portal.
I want to fetch the value of the name 'activeDirectotyEnabled' in my java class.
Please help how to get that?
If I am understanding your scenario correctly, You can connect your Spring Boot app to an App Configuration store and can externalize configuration properties to Azure App Configuration.
See this detailed tutorial: Quickstart: Create a Java Spring app with Azure App Configuration
As the description in the picture
Application Settings are exposed as environment variables for access by your application at runtime.
So these are just environment variables, you can read them as any other environment var in Spring Boot
for example
#Value("${activeDirectotyEnabled}")
boolean isActiveDirectotyEnabled;
So I have a Servlet/JSP web application. We used Ant scripts to build scripts to build properties for different environments, during deployment using loads of filtering. But we are now moving the application to build with Maven. We are thinking of using Spring Cloud Config as centralized repository for property files for all environments that we have. So primarily my question was:
Can we use Spring Cloud Config Server to host properties and fetch it in a non-Spring application?
Can we use Spring Cloud Config to fetch XML, XSD, Text files too? (This is a bit of stretch but just asking if its possible)
We don't plan to use GIT as repository for property, just use a filesystem.
Any pointers would be appreciated.
Spring Cloud Config Server provides an HTTP API that is described in the "Quick Start" section of the Spring Cloud Config documentation. You can use GET requests to fetch configuration properties for specific applications and profiles, e.g.:
curl http://config-server-host:8888/my-application/dev
Using the HTTP API allows you to integrate Config Server with applications that are not based on Spring.
Spring Cloud Config Server can also return non-property files that are handled as "plain text". Please review section "Serving Plain Text" in the Spring Cloud Config documentation:
The Config Server provides these through an additional endpoint at /{application}/{profile}/{label}/{path}, where application, profile, and label have the same meaning as the regular environment endpoint, but path is a path to a file name (such as log.xml).
A curl request for a logback.xml file would therefore look as follows:
curl http://config-server-host:8888/my-application/dev/logback.xml?useDefaultLabel
Currently we have spring applications which are deployed on to Tomcat Servers.We are trying to update application.properties dynamically on the fly, without restarting our server/service. What are our options?
Do we need right any polling service which listens to event changes and update props file?
You can use the Spring Config project. As per the microservice architecture, you can define a different spring profile based on the environment and you will get the capability to reload application properties on the fly without restarting the application using Spring cloud bus events. The same setup can be useful in monolithic architecture as well.
i am using terraform scripts to create AWS resources. Using AWS ElastiCached memcached for caching some data.
output "configuration_endpoint" {
value = "${aws_elasticache_cluster.memcache.configuration_endpoint}"
}
i want to dynamically configure the memcached configuration end point into the spring boot application.properties file instead of hard coding it.
Currently its as below
memcached.addresses=xyz.cache.amazonaws.com:11211
i am unable to find any good references online for the same. Is there any way to set this dynamically once the resources are created in aws. I use Jenkins to run this terraform script and deploy the springboot application into AWS.
We have a suite of microservices that are currently hosted on AWS ECS-Fargate. They are implemented using Spring Boot and packaged as a Docker container using an OpenJDK-based image.
Application logging is configured using logging.config from the Spring runtime core properties and currently points to a bundled classpath resource as follows:
logging:
config: 'classpath:config/logback-spring.xml'
At the ECS task level we configure logs using the awslogs driver which redirects all console output to AWS CloudWatch.
However, this approach is quickly proving unwieldy as it requires us to rebuild and subsequently redeploy the microservices everytime we need to modify the logging configuration.
What is the current best practice for configuring logs using resources external to the application when hosted within the AWS environment?