I have a Java application which uses JAAS authentication and hence it needs a below system property.
-Djava.security.auth.login.config=/jaas/conf/client_jaas.conf
We set this system property in our startup script thru JAVA_OPTS.
JAVA_OPTS="${JAVA_OPTS} -Djava.security.auth.login.config=/jaas/conf/client_jaas.conf"
I am trying to move this app to Kubernetes and setting as below.
"containers": [
{
"env": [
{
"name": "JAVA_OPTS",
"value": "-Djava.security.auth.login.config=/jaas/conf/client_jaas.conf"
},
But, I am getting the below error in my application logs.
Caused by: java.lang.IllegalArgumentException: Could not find a 'appClient' entry in the JAAS configuration. System property 'java.security.auth.login.config' is not set
Is there any other way to set this?
Thanks
I don't know if this is a related problem to the following: JAVA_OPTS is not an out-of-the-box environment variable, but a convention. If you take a look at this example Dockerfile
FROM openjdk:8-jre-alpine
ENV SPRING_OUTPUT_ANSI_ENABLED=ALWAYS \
JHIPSTER_SLEEP=0 \
JAVA_OPTS=""
# add directly the war
ADD *.war /app.war
EXPOSE 8081
CMD echo "The application will start in ${JHIPSTER_SLEEP}s..." && \
sleep ${JHIPSTER_SLEEP} && \
java ${JAVA_OPTS} -Djava.security.egd=file:/dev/./urandom -jar /app.war
you see that the JAVA_OPTS is first defined as a variable and later been used for the java command itself. With this configuration, you are then able to pass custom java options using ENV vars.
So I assume you did everything correctly in kubernetes, but the underlying docker image does not handle it properly