有办法在文件夹SOLR_INSTALL/server/solr-webapp/webapp/WEB-INF/lib/
中安装/下载库jts-core
吗?按照官方指南的规定:https://solr.apache.org/guide/8_10/spatial-search.html#jts-和多边形平面
事实上,我试图在中间放一个initContainer
来下载这样的jar,但很明显,我从Solr容器中得到了Permission denied
,因为只有root才能在最终的Solr容器上写入。
我还试图只为我的initContainer
设置一个securityContext
,以便以root身份运行,但该配置在initContainer
中没有效果,我认为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
另一个分散尝试是设置一个podSecurityContext.runAsUser: 0
,所以对于pod中的所有容器,但Solr没有以root
的身份运行,我顺便放弃了这个选项。
有什么建议/想法/解决方案吗?
事先非常感谢。
我最近发现了一个解决方案,它可能并不优雅,但在任何版本的Solr映像中都能很好地工作,下面是一个配置示例:
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
在本例中,我创建了一个emptyDir
卷,并将其附加到initContainer
的任何目录中,但在最终的Solr容器中,我将其附加在target directory ($SOLR_HOME/server/solr-webapp/webapp/WEB-INF/lib)
中。
这将清空../WEB-INF/lib
目录,但由于我使用相同的Solr映像,我可以在最后复制initContainer
的../WEB-INF/lib
(jar和文件夹(的内容。
其效果是,最终容器将具有它应该具有的所有内容以及jts-core-1.15.1.jar
jar。
这也适用于要引入Solr容器的其他文件或库。
让我知道你觉得这个变通办法怎么样👍
谢谢。
在这种情况下,这与权限或CRD无关;由CCD_ 17下载的文件将由于命名空间隔离而不可用于其他容器。
您可以创建一个Dockerfile,使用solr作为基本映像,使用COPY
作为jar到映像中。然后在安装头盔时更换image.repository
solr头盔参数。通过这种方式,您可以在预先安装了库的情况下运行映像。