Do SpringBoot Configuration Trees support refresh?
I have the following. If the /mnt/secrets/ volume changes does Spring automatically refresh Beans with #ConfigurationProperties?
spring:
application:
name: "foo"
# Read Secrets
config:
import:
- configtree:/mnt/secrets/
activate:
on-cloud-platform: kubernetes
Currently if a Kubernetes configmap or secret is modified/updated, it does not redeploy the pod automatically. There needs to be a manual deployment to pick the new changes.
This is currently a feature in progress to facilicate this. https://github.com/kubernetes/kubernetes/issues/22368
So going by above, can you see if your case falls on the same lines. If so, check if below helps.
From a Kubernetes perspective, you can use Reloader to look for changes and auto redeployment.
For now, use Reloader - https://github.com/stakater/Reloader
It watches if some change happens in ConfigMap and/or Secret; then performs a rolling upgrade on relevant DeploymentConfig, Deployment, Daemonset, Statefulset and Rollout
How to use it - https://github.com/stakater/Reloader#how-to-use-reloader
Related
During pod startup Kubernetes is creating some environment variables based on services i created (via downward API?). Problem is that one of them, MY_APPLICATION_PORT, seems to be initialized incorrectly, it looks like:
MY_APPLICATION_PORT=tcp://192.168.0.5:7777
whereas i expect it to hold only 7777 value. The problem is that i have a Spring Boot application that has this property in application.properties:
my.application.port=7777
So when spring resolves it's properties, it prefers value from environment variable over one from .properties file, thus overwriting it with incorrect value.
My question is - do you guys know how to control creation of kubernetes env variables? I can overwrite it in my deployment.yaml, but I wonder if there's another way.
EDIT:
I've found this as a closest description of my issue I've seen online:
https://github.com/kubernetes/kubernetes/issues/65130
This environment variable comes from compatibility with a very old Docker feature. You can disable it in Kubernetes by setting enableServiceLinks: false on a Container object in a Pod spec, anywhere that may appear. For example:
apiVersion: apps/v1
kind: Deployment
spec:
template:
spec:
containers:
- name: ...
enableServiceLinks: false
env: [...]
In particular the syntax is intended to be compatible with the environment variables generated by container links in first-generation Docker networking. Since then Docker has also introduced a DNS system into its core, and in pure Docker using links at all is now considered obsolete. It should be safe to always set this Kubernetes property, especially if it causes conflicts like what you describe here.
Can we use a configmap on Kubernetes as config server. Kind of a central config and do away with config server?
Short answer: Yes, this is what we did.
One thing to note though is that config maps aren't as centralized as the config server.
As the config map is local to your namespace you would have to keep all your environments (test, staging, production) inside the same namespace (which I do not recommend) in order to have a single config in the same manner as the cloud config gives you.
But even if you separate your environments into separate namespaces (which I recommend) and have one config map for each it's still easy to maintain and a good replacement for the config server.
I am working in a Java Springboot microservice-based complex application that comprises 30 services.
All are containerized and from ECR, services are deployed inside the Kubernetes namespace in AWS.
Every time, the namespace is purged and all services are re-deployed.
How can I update only one service inside a namespaceā¦is it possible to do that kind of deployment.
Can someone please Any sample configurations using helm or any useful links
How can I update only one service inside a namespaceā¦is it possible to do that kind of deployment.
If you are executing helm upgrade it should only update the resources which are updated.
you need to understand how does Helm packs the resources, helm is using Kustomization so if you are updating Secrets, ConfigMap etc it will generate new names for those resources.
As a side effect, it will "change" the Deployment and the results will be a "full" deploy of all the resources
I'm working on migrating an app to new hosting infrastructure.
I currently have profiles like this defined:
dev
qa
prod
Each of those have corresponding bits of configuration for things like JMS brokers, etc.
I'm now working on building a new proof of concept instance of this app on new hosting infrastructure.
I'm looking to keep the on-prem instances working unchanged (no need adjust their active profiles), but will add an additional cloud profile to my instances on the new hosting.
My goal is to have config like this work, but I'm not having much luck yet:
For the app itself, run it with spring.profiles.active=dev,cloud instead of spring.profiles.active=dev like I do now.
In my application.yaml:
---
# default config, applicable to all environments, goes here
---
spring:
profiles: cloud
# config common to all hosts on this new hosting platform goes here
---
spring:
profiles: cloud & dev
# this is the bit that isn't applying, but should have overrides of some details for when the dev env is on The Cloud
---
spring:
profiles: dev
# the current on-prem dev instance; my goal is to have some config here apply both on prem and
# in the cloud, but have the cloud config override some of this in specific instances
The alternative solution I see is to go to the deployment config of all my on-prem instances, and add a new on-prem profile to each (e.g. on-prem,dev, on-prem,qa, & on-prem,prod), shift anything that's on-prem specific into new on-prem & dev, etc profiles in YAML, and keep the stuff that's common across both in a bare dev profile... maybe this is just what I need to do, but suggestions would be appreciated.
We have an old java application which has few properties files. We are doing a POC to deploy it in Kubernetes cluster using Helm chart. As of now, we manually creating configmap by copying the content from properties file. If any updates in properties file, as a result the same update should be done in configmap manually. So, Is there any solution available to create a configmap from the properties file during maven build?
Thanks in advance.
If you were using Spring Cloud Config in the past to fetch your properties and reload application during change of properties, there is an alternative provided by Spring for Kubernetes which allows fetching and reading the properties from your ConfigMap(s) directly and allows reload when the ConfigMap changes
Reference - https://cloud.spring.io/spring-cloud-static/spring-cloud-kubernetes/1.1.0.M3/reference/html/#kubernetes-propertysource-implementations
But looks like there is no solution available yet to generate ConfigMap(s) from property file(s) directly during a maven build.
It can be done by help of volume and volumeMounts.
You can get info from this