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

k8s上的es无法安装分词器插件 #1076

Open
yancy-hong opened this issue Sep 14, 2024 · 0 comments
Open

k8s上的es无法安装分词器插件 #1076

yancy-hong opened this issue Sep 14, 2024 · 0 comments

Comments

@yancy-hong
Copy link

yancy-hong commented Sep 14, 2024

使用ECK安装的es。

k8s部分配置文件:

initContainers:
  - name: install-plugins
    securityContext:
      privileged: true
      runAsUser: 0
    command:
      - sh
      - -c
      - |
        bin/elasticsearch-plugin install https://get.infini.cloud/elasticsearch/analysis-ik/8.12.2

pod init失败,部分describe pod:

Back-off restarting failed container install-plugins in pod elastic-search-es-default-1_elastic

改配置不自动安装分词器,并重新部署Pod:

initContainers:
  - name: install-plugins
    securityContext:
      privileged: true
      runAsUser: 0
    command:
      - sh
      - -c
      - |
        echo "hello"

kubectl exec 进入Pod,手动安装分词器:

bin/elasticsearch-plugin install https://get.infini.cloud/elasticsearch/analysis-ik/8.12.2

报错:

Exception in thread "main" java.nio.file.FileSystemException: 
     /usr/share/elasticsearch/config/analysis-ik: Operation not permitted

即使在k8s的配置里为config/analysis-ik添加权限也还是报这个错:

initContainers:
  - name: install-plugins
    securityContext:
      privileged: true
      runAsUser: 0
    command:
      - sh
      - -c
      - |
        mkdir -p config/analysis-ik
        chmod -R 777 config/analysis-ik
        bin/elasticsearch-plugin install https://get.infini.cloud/elasticsearch/analysis-ik/8.12.2

完整k8s配置:

apiVersion: elasticsearch.k8s.elastic.co/v1
kind: Elasticsearch
metadata:
  name: elastic-search
  namespace: elastic
spec:
  version: 8.12.2
  nodeSets:
    - name: default
      count: 2
      config:
        node.store.allow_mmap: false
        node.roles: ["master", "data", "ingest"]
      volumeClaimTemplates:
        - metadata:
            name: elasticsearch-data
          spec:
            accessModes:
              - ReadWriteOnce
            resources:
              requests:
                storage: 20Gi
            storageClassName: sc-es
      podTemplate:
        spec:
          containers:
            - name: elasticsearch
              resources:
                requests:
                  memory: 8Gi
                  cpu: 4
                limits:
                  memory: 8Gi
                  cpu: 4
          initContainers:
            - name: install-plugins
              securityContext:
                privileged: true
                runAsUser: 0
              command:
                - sh
                - -c
                - |
                  bin/elasticsearch-plugin install https://get.infini.cloud/elasticsearch/analysis-ik/8.12.2

  transport:
    service:
      metadata:
        name: elastic
      spec:
        type: NodePort

sc-es storageClass内容:

apiVersion: storage.k8s.io/v1
kind: StorageClass
provisioner: nfs.csi.k8s.io
metadata:
  name: sc-es
allowVolumeExpansion: true
reclaimPolicy: Retain
parameters:
  server: 10.10.10.110
  share: /nfs/elastic/search

nfs目录权限:

ls -ld /nfs/elastic/search/
drwxrwxrwx 6 root root 4096 Sep 14 12:03 /nfs/elastic/search/
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

1 participant