elasticsearch - 将具有 Elasticsearch 索引的本地目录挂载到 Minikube
问题描述
我正在尝试使用 Elasticsearch 移动我的 Springboot 应用程序以在minikube上运行。但我想在 Kubernetes 上运行的弹性搜索中重用我使用本地弹性搜索创建的现有索引。
我可以看到一些关于 Persistent Volume 的文档,但我找不到任何关于重用本地目录上现有索引的信息。
有人可以建议一些有关如何在 Kubernetes 上挂载包含 Elasticsearch 索引的现有本地目录的信息。
我正在尝试使用 minikube 在本地运行 Kubernetes 集群。这是我第一次尝试使用 Kubernetes。因此,我并不熟悉它的所有方面。我正在尝试部署一个连接到 Elasticsearch 服务器的 Spring Boot 应用程序。
Elasticsearch 服务器 - 部署.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: elasticsearch
spec:
selector:
matchLabels:
run: elasticsearch
replicas: 1
template:
metadata:
labels:
run: elasticsearch
spec:
containers:
- image: docker.elastic.co/elasticsearch/elasticsearch:6.6.1
name: elasticsearch
imagePullPolicy: IfNotPresent
env:
- name: discovery.type
value: single-node
- name: cluster.name
value: elasticsearch
ports:
- containerPort: 9300
name: nodes
- containerPort: 9200
name: client
解决方案
尝试StatefulSet
为 Elasticsearch 创建一个将用作持久卷声明 (PVC)
PVC 参考链接:https ://kubernetes.io/docs/tutorials/stateful-application/basic-stateful-set/
在有状态集配置中,您需要这样提及volumeMounts
:
volumeMounts:
- name: elasticsearch
mountPath: /path/to/local_directory/local_indexes
这可以帮助您发现旧索引(本地创建)以及新索引!
为了访问这些索引,我建议Service
为 Elasticsearch 创建一个负载均衡器。它将生成一个外部 IP 来访问 Kubernetes 集群中的 Elasticsearch 配置和索引。您可以通过将 curl 应用于生成的外部 IP 来访问。
推荐阅读
- java - Java 8如何处理属性为空的情况
- swift - 在 315° 圆弧上绘制圆角
- sql - 无法使用以下查询检索日期
- c# - 无法将 IQueryable 类型隐式转换为类
- python - Weird platform movement in pygame side-scrolling platformer
- c# - How to avoid so many disconnects in IoT-edge module
- python - 我使用偏移量来访问 LMDB 数据库中的元素,但它太慢了。这是为什么?
- swiftui - 如何在 SwiftUI 中使用带有 ObservedObject 的 Picker?
- python - Python script runs flawless when executed in shell, but throws unicode errors when executed as systemd service
- macos - How do I prevent an application from being used as a default opener for ANY file?