The problem
After changing the quarkus.package.type
to fast-jar
, the application instances on our Kubernetes cluster could no longer read a mounted ConfigMap.
2022-02-17 14:39:45,155 WARN [com.example.MyStartupService] (main)
Config param is not defined and might be missing: foo.bars
Locally there is no problem with the configuration, but we also do not mount it - just have a static application.yml
. Before this change everything worked fine, we can directly track it to the quarkus.package.type
.
Our Setup
First and foremost: We do not use a application.properties
, but a application.yml
(utilizing quarkus-config-yaml
).
We are using Quarkus 2.7.1.Final
.
Java Code
@ConfigMapping(prefix = CONFIG_PREFIX)
public interface FooBarConfigMapping {
String CONFIG_PREFIX = "foo";
String CONFIG_NAME = "bars";
String CONFIG_PARAM = String.join(".", CONFIG_PREFIX, CONFIG_NAME);
@WithName(CONFIG_NAME)
List<BarConfig> barConfigurations();
interface BarConfig {
@WithName("name")
String name();
}
}
@ApplicationScoped
public class MyStartupService {
@Inject
FooBarConfigMapping fooBarConfigMapping;
@Transactional
void startup(@Observes @Priority(2501) StartupEvent event) {
if (fooBarConfigMapping.barConfigurations().isEmpty()) {
LOGGER.debug("Config param is not defined and might be missing: " + FooBarConfigMapping.CONFIG_PARAM);
}
// do something with fooBarConfigMapping.barConfigurations()
}
}
Deployment
Our application-config.yaml (ConfigMap):
apiVersion: v1
kind: ConfigMap
metadata:
name: application-configmap
# ...
data:
application.yml: |
foo:
bars:
-
name: A
-
name: B
-
name: C
Our deployment.yaml (Deployment):
apiVersion: apps/v1
kind: Deployment
metadata:
# ...
spec:
# ...
template:
# ...
spec:
# ...
containers:
# ...
volumeMounts:
- name: application-config
mountPath: /config
volumes:
- name: application-config
configMap:
name: application-configmap
Misc
I can't find any good information what might have changed between
legacy-jar
andfast-jar
i.r.t. reading out the config. Maybe it is related to the different structures (as shown here). For me this might be the likeliest source of the error.1.1. I tried to change the mount-path from
/config
to/usr/local/apps/config
(following this SmallRye ConfigMap example), but to no avail.1.2. I also tried to rename the mounted file from
application.yml
toapplication.yaml
, but same outcome.