How do you stop Confluence application in Kubernetes running from a docker image?

5/19/2021

I'm migrating Confluence from a VM to an instance of Confluence Server 7.11.1 using the official Atlassian docker image in Kubernetes. I successfully got the application to come up, and was able to get through the set-up screens to start an empty Confluence.

To customize my instance I want to copy over my old server's confluence home directory to the default confluence home location and also change the database connection URL. According to documentation here, I need to stop confluence from running while doing this. I tried to run the stop-confluence.sh script from the confluence user, but I can't stop the container because there is no catalina.pid file in the docker version of k8s.

I tried the alternative of killing the java process that runs Confluence, but the entire container shuts down when I do this.

How do I stop Confluence in Kubernetes so that I can copy files and modify configuration in the container? Is the docker image version of the Confluence application not meant to be stopped and everything needs to be provided as env variables? Notes on the official atlassian docker image configuration is here.

Error message:

confluence@usmai-www-confluence-0:~$ /opt/atlassian/confluence/bin/stop-confluence.sh -fg
executing as current user
If you encounter issues starting up Confluence, please see the Installation guide at http://confluence.atlassian.com/display/DOC/Confluence+Installation+Guide

Server startup logs are located in /opt/atlassian/confluence/logs/catalina.out
---------------------------------------------------------------------------
Using Java: /opt/java/openjdk/bin/java
2021-05-19 23:29:48,363 INFO [main] [atlassian.confluence.bootstrap.SynchronyProxyWatchdog] A Context element for ${confluence.context.path}/synchrony-proxy is found in /opt/atlassian/confluence/conf/server.xml. No further action is required
---------------------------------------------------------------------------
Using CATALINA_BASE:   /opt/atlassian/confluence
Using CATALINA_HOME:   /opt/atlassian/confluence
Using CATALINA_TMPDIR: /opt/atlassian/confluence/temp
Using JRE_HOME:        /opt/java/openjdk
Using CLASSPATH:       /opt/atlassian/confluence/bin/bootstrap.jar:/opt/atlassian/confluence/bin/tomcat-juli.jar
Using CATALINA_OPTS:   -XX:ReservedCodeCacheSize=256m -XX:+UseCodeCacheFlushing -Djdk.tls.server.protocols=TLSv1.1,TLSv1.2 -Djdk.tls.client.protocols=TLSv1.1,TLSv1.2 -Dconfluence.context.path=/portal  -Djava.locale.providers=JRE,SPI,CLDR -Dorg.apache.tomcat.websocket.DEFAULT_BUFFER_SIZE=32768 -Dsynchrony.enable.xhr.fallback=true -Xms1024m -Xmx1024m -Dconfluence.home= -XX:+UseG1GC -Datlassian.plugins.enable.wait=300 -Djava.awt.headless=true -XX:G1ReservePercent=20 -Xloggc:/opt/atlassian/confluence/logs/gc-2021-05-19_23-29-48.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=5 -XX:GCLogFileSize=2M -Xlog:gc+age=debug:file=/opt/atlassian/confluence/logs/gc-2021-05-19_23-29-48.log::filecount=5,filesize=2M -XX:-PrintGCDetails -XX:+PrintGCDateStamps -XX:-PrintTenuringDistribution -XX:+IgnoreUnrecognizedVMOptions   -DConfluenceHomeLogAppender.disabled=
Using CATALINA_PID:    /opt/atlassian/confluence/work/catalina.pid
$CATALINA_PID was set but the specified file does not exist. Is Tomcat running? Stop aborted.
-- moglido
confluence
docker
kubernetes

1 Answer

5/20/2021

Apparently, the confluence java process is the "ENTRYPOINT" for the docker container, so when you kill the java process, it kills the container as well.

I would suggest that you create a persistent volume with readWriteMany attribute set and mount it to a temporary pod - say with ubuntu image.

You then use "kubectl cp" to copy the existing home directory to the persistent volume mounted on the ubuntu pod.

You can then make any modifications to the files as you please. Once done, just kill the ubuntu pod.

Your files will still be present on the persistent volume.

Now mount this persistent volume to /opt/atlassian/confluence in your confluence pod and it it should just work.

-- Rakesh Gupta
Source: StackOverflow