Is there a way to install/download the library jts-core
in the folder SOLR_INSTALL/server/solr-webapp/webapp/WEB-INF/lib/
? As specified in the official guide: https://solr.apache.org/guide/8_10/spatial-search.html#jts-and-polygons-flat
Actually, I tried to put in the middle an initContainer
that downloads such jar, but I get obviously a Permission denied
from the Solr container since only root can write on the final solr container.
I tried also to set a securityContext
only for my initContainer
, in order to run as root, but that configuration has no effect in the initContainer
, I think it is not seen by the Solr CRD.
podOptions:
initContainers:
- name: "install-jts-core"
image: solr:8.9.0
command: ['sh', '-c', 'wget -O /opt/solr-8.9.0/server/solr-webapp/webapp/WEB-INF/lib/jts-core-1.15.1.jar https://repo1.maven.org/maven2/org/locationtech/jts/jts-core/1.15.1/jts-core-1.15.1.jar']
securityContext: <--- this has no effect on SolrCloud CRD
runAsUser: 0
Another disperate attempt was to set a podSecurityContext.runAsUser: 0
, so for all containers in the pod, but Solr does not run as root
, I discarded that option by the way.
Any hint/idea/solution please?
Thank you very much in advance.
I have recently found a solution that may not be elegant, but works well in any version of Solr image, below a configuration example:
podOptions:
initContainers:
- name: "install-jts-lib"
image: solr:8.9.0
command:
- 'sh'
- '-c'
- |
wget -O /tmp-webinf-lib/jts-core-1.15.1.jar https://repo1.maven.org/maven2/org/locationtech/jts/jts-core/1.15.1/jts-core-1.15.1.jar
cp -R /opt/solr/server/solr-webapp/webapp/WEB-INF/lib/* /tmp-webinf-lib
volumeMounts:
- mountPath: /tmp-webinf-lib
name: web-inf-lib
volumes:
- name: web-inf-lib
source:
emptyDir: {}
defaultContainerMount:
name: web-inf-lib
mountPath: /opt/solr/server/solr-webapp/webapp/WEB-INF/lib
In this example, I create an emptyDir
volume and attach it in any directory of the initContainer
, but in the final Solr container I attach it in the target directory ($SOLR_HOME/server/solr-webapp/webapp/WEB-INF/lib)
.
This will empty the ../WEB-INF/lib
directory, but since I'm using the same Solr image , I can copy the content of ../WEB-INF/lib
(jars and folders) of the initContainer
at the end.
The effect is that the final container will have all the content it should have had plus the jts-core-1.15.1.jar
jar.
This works also with other files or libraries you want to bring in the Solr container.
Let me know what do you think of this workaround 👍
Thank you.
In this case it is not about the permission or CRD; the file downloaded by a install-jts-core
will not be available to other containers because of namespace isolation.
You can create a Dockerfile using solr as the base image and COPY
the jar to into the image. Then replace image.repository
solr helm parameter during helm install. This way you run a image with the library pre-installed.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.