I want to set environment variables via Kubernetes for server.xml in tomcat. Here is my deployment.yaml:
apiVersion: v1
kind: Pod
metadata:
name: tomcat-test-pod
...
...
env:
- name: hostName
value: 'test.com'
- name: localhost
value: 'localhost.com'
And here is my server.xml:
<?xml version='1.0' encoding='utf-8'?>
<Resource
auth="Container"
description="Global E-Mail Resource"
mail.debug="false"
mail.smtp.auth="false"
mail.smtp.ehlo="true"
mail.smtp.host="${hostName}"
mail.smtp.localhost="${localhost}"
mail.smtp.port="25"
mail.smtp.sendpartial="true"
mail.transport.protocol="smtp"
name="mail/Session"
type="javax.mail.Session"/>
From https://tomcat.apache.org/tomcat-9.0-doc/config/systemprops.html, it says that I need to set org.apache.tomcat.util.digester. PROPERTY_SOURCE to org.apache.tomcat.util.digester.EnvironmentPropertySource, but I am not sure what I am supposed to do. Do I need to set it in setenv.sh or do I need to create another class? Any help will be appreciated..