atlassian / data-center-helm-charts

Helm charts for Atlassian's Data Center products
https://atlassian.github.io/data-center-helm-charts/
Apache License 2.0
158 stars 134 forks source link

[Suggestion] - How to add JNDI resources to server.xml #540

Closed zeddit closed 12 months ago

zeddit commented 1 year ago

Suggestion

the official guide says it could add smtp servers by Configuring a JNDI location, e.g. the jira one 's documentation is located at here, https://confluence.atlassian.com/adminjiraserver0904/configuring-an-smtp-mail-server-to-send-notifications-1188768602.html#ConfiguringanSMTPmailservertosendnotifications-ConfiguringaJNDIlocation

However, I found it hard to code the into the server.xml. I found another solution that may add a new xml file, e.g. 'jira.xml', to the path of '/opt/atlassian/jira/conf/Catalina/localhost', which contain Context and Resources.

But I still cannot make it succeed. the frontend UI still pops me out with NameNotFoundException: Name [mail/JiraMailServer] is not bound in this Context. Unable to find [mail].

What should I do to add some JNDI resources to jira deployed in kubernetes

thanks.

Product

Jira

Code of Conduct

bianchi2 commented 1 year ago

hi @zeddit server.xml is generated from a template each time the container starts, and indeed, it does not support additional resources in the context. What you can do though is to:

additionalFiles:
- name: custom-server-xml
  type: configMap
  key: server.xml
  mountPath:  /opt/atlassian/jira/conf

Once done, run helm upgrade, and you should have server.xml mounted into conf.

zeddit commented 1 year ago

@bianchi2 really appreciate for your reply. I have come up with this idea, however, it will break things if I change some other configurations or environment variables some day. Will the chart support inserting JNDI resources in the futures, because the crowd app could load xml files under conf/Catalina/localhost correctly.

bianchi2 commented 1 year ago

@zeddit have you tried mounting xml from configmap to conf/Catalina/localhost? Did it work for you? Or you edited the file manually from within the container and then restarted?

Supporting any resources in server.xml context isn't easy, and adding just support of smtp is unlikely something that we'll be doing (as I said before, server.xml is generated in container entrypoint, so it's not even a Helm thing)

zeddit commented 1 year ago

@bianchi2 I have tried to mount xml to conf/Catalina/localhost as mentioned in Crowd here. It works for Crowd, however not worked for Jira. I am not familiar with Tomcat, so I am not sure If I make the configuration code correctly, and there lacks documents about mounting xml to conf/Catalina/localhost for jira.

I tried to change some attributes from Crowd template, e.g. Path, baseDoc etc. However, the JNDI still cannot be found in Jira UI.

bianchi2 commented 1 year ago

Thanks for explaining. Yeah, it looks like for now the only way to achieve that is to mount server.xml as configmap and not forget to change it when you change some envs that are used to generate it (like proxy host, https etc).

BryanGuffeySonos commented 1 year ago

@bianchi2 - if I were to mount via configMap, do I need to change generateByHelm to true in values.yaml? or no? And why would I do this vs using customServerXml?

bianchi2 commented 1 year ago

@BryanGuffeySonos customServerXml is a field for your to define your own server.xml. If you set generateByHelm to true then server.xml will be generated from helm template (i.e. you won't be able to add any custom elements)

BryanGuffeySonos commented 1 year ago

@bianchi2 so do you think it’s better to use customServerXml or a config map with additional files if I’m adding a connector and modifying the engine for Application tunnels?

Thanks!

On Sun, Sep 3, 2023 at 13:35 yivantsov-atlassian @.***> wrote:

@BryanGuffeySonos https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_BryanGuffeySonos&d=DwMCaQ&c=rs51NVPNx2acMvSlALPpNg&r=EB4s-BECsd0aGLHH9zo9OKcnjbPHE5x6s8SDDdF97oA&m=-th3jSHwDVfQ7VJBwkrBdQNbUZeeASUgAsifx6zrUns-v7NmJgDUYUfAj2eYDySQ&s=4dta-XM_Ir6VBsh45jTmCegVRFN0Paq8lqPcxev1vxc&e= customServerXml is a field for your to define your own server.xml. If you set generateByHelm to true then server.xml will be generated from helm template (i.e. you won't be able to add any custom elements)

— Reply to this email directly, view it on GitHub https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_atlassian_data-2Dcenter-2Dhelm-2Dcharts_issues_540-23issuecomment-2D1704395699&d=DwMCaQ&c=rs51NVPNx2acMvSlALPpNg&r=EB4s-BECsd0aGLHH9zo9OKcnjbPHE5x6s8SDDdF97oA&m=-th3jSHwDVfQ7VJBwkrBdQNbUZeeASUgAsifx6zrUns-v7NmJgDUYUfAj2eYDySQ&s=QOBwk7Sxo1ItVk0fcgVADufJSUq1z2rXo3NycLE5100&e=, or unsubscribe https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_A2KRJTZWQK2BYXDLGKKYOBDXYTS2BANCNFSM6AAAAAAWEZBBGU&d=DwMCaQ&c=rs51NVPNx2acMvSlALPpNg&r=EB4s-BECsd0aGLHH9zo9OKcnjbPHE5x6s8SDDdF97oA&m=-th3jSHwDVfQ7VJBwkrBdQNbUZeeASUgAsifx6zrUns-v7NmJgDUYUfAj2eYDySQ&s=0rVrS-NY7xdacH0uq23hM8ItZOIK04fgIaa63rms8_k&e= . You are receiving this because you were mentioned.Message ID: @.***>

bianchi2 commented 1 year ago

@BryanGuffeySonos both additionalConfigMaps and customServerXml will let you define your own server.xml and keep it with helm chart values. Historically, these two props were added after additionalFiles to server different usecases.

BryanGuffeySonos commented 1 year ago

Got it. so no preference between them - can we define specific values to be added vs the entire server.xml being overwritten?

bianchi2 commented 1 year ago

Yes, no preference.

BryanGuffeySonos commented 1 year ago

Also yes to being able to use one or the other to only override specific things or insert additional items, or will either one create a wholly custom server.xml. I promise, last question, and thanks for all your time!

bianchi2 commented 1 year ago

@BryanGuffeySonos tomcatConfig was introduced mainly for OpenShift where container runs as a non privileged user and server.xml generation (that happens in the image entrypoint) fails due to permission issues. So, we added this option to do generation on helm side and let users override what's possible to override in the template packaged into the image.

In your case I suggest you define additionalConfigMaps with your desired server.xml content. In this case, dynamic generation of server.xml will not take effect in the image entrypoint, and a configmap with your server.xml will be mounted to tomcat's conf dir.

BryanGuffeySonos commented 1 year ago

@bianchi2 - I tried using additionalConfigMaps and was unsuccessful. In the examples provided in the documentation, it is recommended to define the ConfigMap in the Pod spec, but according to the Kubernetes documentation,

You must create the ConfigMap object before you reference it in a Pod specification. Alternatively, mark the ConfigMap reference as optional in the Pod spec (see Optional ConfigMaps). If you reference a ConfigMap that doesn't exist and you don't mark the reference as optional, the Pod won't start. Similarly, references to keys that don't exist in the ConfigMap will also prevent the Pod from starting, unless you mark the key references as optional.

Can you help me understand this?

bianchi2 commented 1 year ago

In additionalCofnigMaps you define the keys and content of configmaps that you want Helm to create for you:

additionalConfigMaps: 
 - name: server-xml
   keys:
     - fileName: server.xml
       mountPath: /opt/atlassian/jira/conf
       content: |
         <xml>YOUR_SERVER_XML</xml>
bianchi2 commented 12 months ago

Close this one since a workaround is available - mount server.xml using additionalConfigMaps or additionalFiles (if you want to create the CM outside Helm)