简体   繁体   English

Kubernetes Solr 运算符 JTS 和多边形 jar 文件

[英]Kubernetes Solr operator JTS and Polygons jar file

Is there a way to install/download the library jts-core in the folder SOLR_INSTALL/server/solr-webapp/webapp/WEB-INF/lib/ ?有没有办法在文件夹SOLR_INSTALL/server/solr-webapp/webapp/WEB-INF/lib/安装/下载库jts-core As specified in the official guide: https://solr.apache.org/guide/8_10/spatial-search.html#jts-and-polygons-flat如官方指南中所述: 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.实际上,我试图在中间放置一个下载此类 jar 的initContainer ,但我显然得到了 Solr 容器Permission deniedPermission denied ,因为只有 root 可以在最终的 solr 容器上写入。

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.我还尝试仅为我的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

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.另一个分散的尝试是设置podSecurityContext.runAsUser: 0 ,因此对于 pod 中的所有容器,但 Solr 不以root身份运行,我顺便放弃了该选项。

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:我最近发现了一个可能不优雅但在任何版本的 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

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) .在这个例子中,我创建一个emptyDir体积和任何目录,将其固定initContainer ,但在最后Solr的容器我将其固定在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.这将清空../WEB-INF/lib目录,但由于我使用的是相同的Solr的形象,我可以复制内容../WEB-INF/lib了的(瓶子和文件夹) initContainer末.

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.效果是最终容器将拥有它应该拥有的所有内容以及jts-core-1.15.1.jar jar。

This works also with other files or libraries you want to bring in the Solr container.这也适用于您想要引入 Solr 容器的其他文件或库。

Let me know what do you think of this workaround 👍让我知道您对此解决方法的看法👍

Thank you.谢谢你。

In this case it is not about the permission or CRD;在这种情况下,这与许可或 CRD 无关; the file downloaded by a install-jts-core will not be available to other containers because of namespace isolation.由于命名空间隔离,由install-jts-core下载的文件将无法用于其他容器。

You can create a Dockerfile using solr as the base image and COPY the jar to into the image.您可以使用 solr 作为基础映像创建 Dockerfile,然后将 jar COPY到映像中。 Then replace image.repository solr helm parameter during helm install.然后在 helm 安装期间替换image.repository solr helm 参数。 This way you run a image with the library pre-installed.通过这种方式,您可以运行预先安装了库的图像。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM