在 Kubernetes 上部署 Elasticsearch 时出现“只读文件系统”错误

在 Kubernetes 上部署 Elasticsearch 时出现“只读文件系统”错误

我正在尝试在 Kubernetes 上部署 Elasticsearch 7.12.0 并将其配置为单节点集群运行。

但是部署之后,遇到了以下错误:

Exception in thread "main" org.elasticsearch.bootstrap.BootstrapException: java.nio.file.FileSystemException: /usr/share/elasticsearch/config/elasticsearch.keystore.tmp: Read-only file system
Likely root cause: java.nio.file.FileSystemException: /usr/share/elasticsearch/config/elasticsearch.keystore.tmp: Read-only file system

以下是我的配置的相关部分:

部署 YAML:

apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: elasticsearch
  name: elasticsearch
spec:
  replicas: 1
  selector:
    matchLabels:
      app: elasticsearch
  template:
    metadata:
      labels:
        app: elasticsearch
    spec:
      containers:
        - image: docker.elastic.co/elasticsearch/elasticsearch:7.12.0
          name: elasticsearch
          env:
            - name: discovery.type
              value: single-node
          ports:
            - containerPort: 9200
            - containerPort: 9300
          volumeMounts:
            - mountPath: /usr/share/elasticsearch/config
              name: elasticsearch-config
            - mountPath: /usr/share/elasticsearch/data
              name: elasticsearch-data
          resources:
            limits:
              memory: 2Gi
              cpu: "1"
            requests:
              memory: 1Gi
              cpu: "1"
      volumes:
        - name: elasticsearch-config
          configMap:
            name: elasticsearch-config
        - name: elasticsearch-data
          persistentVolumeClaim:
            claimName: elasticsearch
      securityContext:
        fsGroup: 1000        
      restartPolicy: Always

配置地图 YAML:

apiVersion: v1
kind: ConfigMap
metadata:
  name: elasticsearch-config
data:
  elasticsearch.yml: |
    cluster.name: "docker-cluster"
    network.host: 0.0.0.0
    path.data: /usr/share/elasticsearch/data
  jvm.options: |
    -Xms512m
    -Xmx512m

持久卷声明 YAML:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  labels:
    app: elasticsearch
  name: elasticsearch
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 100Mi

我认为该问题可能与卷的挂载方式或权限设置有关。如何解决 Kubernetes 中 Elasticsearch 配置的“只读文件系统”错误?

相关内容