我正在尝试在本地minikube集群的kubernetes https://www.elastic.co/guide/en/cloud-on-k8s/current/index.html上部署 flex 模块。我已经安装了操作员。
当我在下面应用elasticsearch集群时,出现以下pod错误:
数量/声明:
apiVersion: v1
kind: PersistentVolume
metadata:
name: elasticsearch-data
labels:
type: local
spec:
storageClassName: standard
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"
-apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: elasticsearch-data
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
elastic.yml apiVersion: elasticsearch.k8s.elastic.co/v1beta1
kind: Elasticsearch
metadata:
name: data-es
spec:
version: 7.4.2
nodeSets:
- name: default
count: 2
volumeClaimTemplates:
- metadata:
name: elasticsearch-data
spec:
accessModes:
- ReadWriteOnce
storageClassName: standard
resources:
requests:
storage: 10Gi
config:
node.master: true
node.data: true
node.ingest: true
node.store.allow_mmap: false
xpack.security.authc.realms:
native:
native1:
order: 1
---
apiVersion: kibana.k8s.elastic.co/v1beta1
kind: Kibana
metadata:
name: data-kibana
spec:
version: 7.4.2
count: 1
elasticsearchRef:
name: data-es
kubectl获取pvc 最佳答案
上面的错误意味着没有persistentVolume
可以绑定(bind)到PersistentVolumeClaim
。默认情况下,local-storage
不会真正动态创建persistentVolume
。
要使用local-storage
存储类的动态配置机制,您需要配置local-storage
类,以便它可以配置persistentVolume
。检查此讨论Kubernetes: What is the best practice for create dynamic local volume to auto assign PVs for PVCs?。
另外,如果不使用存储类的动态预配置机制,则需要使用可以绑定(bind)到persistentVolume
的hostPath
创建PersistentVolumeClaim
,但这不是推荐用于生产用途的解决方案。检查本指南here。PersistentVolumeClaim
将基于 flex Yaml中的volumeClaimTemplates
自动创建。因此,您不应该创建一个PersistentVolumeClaim
。
由于nodeSets
计数为2,因此创建了两个PersistentVolumeClaim
。因此,您需要创建两个persistentVolume
。
apiVersion: v1
kind: PersistentVolume
metadata:
name: elasticsearch-data1
labels:
type: local
spec:
storageClassName: standard
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: elasticsearch-data2
labels:
type: local
spec:
storageClassName: standard
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/mnt/data"