Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File copy in Kubernetes #65

Open
lorenzozimolo opened this issue Jan 4, 2021 · 2 comments
Open

File copy in Kubernetes #65

lorenzozimolo opened this issue Jan 4, 2021 · 2 comments

Comments

@lorenzozimolo
Copy link

lorenzozimolo commented Jan 4, 2021

Hello.

in Kubernetes I can mount a ConfigMap under /mnt/liferay/files (and subfolders) instead of mounting a volume.
These files are exposed as symbolic links to hidden folders, to manage updates on ConfigMaps.

As a result the automatic copy in configure_liferay.sh, creates links and not regular files in the destination folders, and this fact denies modifications of the files (for example to inject credentials or other env variables), because ConfigMaps are immutable inside the container.

At the moment I execute a script before starting the server with the following code:

cd ${LIFERAY_MOUNT_DIR}/files/
find . -not -path '*/\.*' -type d -exec mkdir -v -p ${LIFERAY_HOME}/{} \;
find . -not -path '*/\.*' -not -type d -exec cp -v -H {} ${LIFERAY_HOME}/{} \;

but it's only a workaround.

Is it possible to better support this situation?

thanks
Lorenzo

@arbetts
Copy link
Contributor

arbetts commented Jun 30, 2021

@zsoltbalogh @lorenzozimolo from my understanding of the files mount point it is intended to be a LIFERAY_HOME override, which houses the tomcat app server and liferay web app. Based on my understanding of this extension point I would not suggest implementing the configure_liferay.sh script to read through symlinks and copy the underlying files.

in fact we use symlinks on the tomcat folder so that we can target it correctly even though its a link to the tomcat-version folder.

@lorenzozimolo you might be able to use the pre-configure lifecycle phase to read the configMap/secret file and then put it into the right location.

I've used inotifywait to accomplish a dynamic copy of files from the configMap directory into the liferay deploy folder like this:

inotifywait -m -q -e create --exclude data /mnt/my/config/map/ |
    while read watched_filename EVENT_NAMES event_filename; do
      if [[ -d "${watched_filename}${event_filename}" ]]; then
        echo "Notifying on directory creation event: ${watched_filename}${event_filename}"

        for file in ${watched_filename}${event_filename}/*; do
          if [[ -f ${file} ]]; then
            echo -e "Copying $(basename ${file}) to /opt/liferay/deploy"
            cp -p ${file} /opt/liferay/deploy 2>/dev/null
          fi
        done
      fi
    done

@mr-ssd
Copy link

mr-ssd commented Sep 2, 2022

@lorenzozimolo in configure_liferay.sh just update cp -r "${LIFERAY_MOUNT_DIR}"/files/* "${LIFERAY_HOME}" to cp -rL "${LIFERAY_MOUNT_DIR}"/files/* "${LIFERAY_HOME}"
will fix the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants