[英]How to provision persistent volume claim for software install in kubernetes
I am trying to provision PVC for Solr deployment in k8s and mount it as /opt/solr, which is default Solr installation directory. 我正在尝试为在k8s中进行Solr部署提供PVC,并将其安装为/ opt / solr,这是默认的Solr安装目录。 This way I plan to target both Solr installation and data under it on PVC. 通过这种方式,我计划同时针对PVC上的Solr安装和数据。 However, while storage gets provisioned just fine and statefulset gets created, my deployment doesn't work because /opt/solr ends up empty. 但是,尽管可以很好地配置存储并创建statefulset,但是我的部署无法正常工作,因为/ opt / solr最终为空。 What is a proper way to do it? 正确的做法是什么? Here my deployment.yaml: 这是我的deployment.yaml:
apiVersion: apps/v1beta1
kind: StatefulSet
metadata:
name: solr
labels:
app: solr
spec:
volumeClaimTemplates:
- metadata:
name: datadir
annotations:
volume.alpha.kubernetes.io/storage-class: slow
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 2Gi
serviceName: solr-svc
replicas: 1
template:
metadata:
labels:
app: solr
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- solr-pool
topologyKey: "kubernetes.io/hostname"
terminationGracePeriodSeconds: 300
containers:
- name: solr
image: solr:6.5.1
imagePullPolicy: IfNotPresent
resources:
requests:
memory: 512M
cpu: 500m
ports:
- containerPort: 8983
name: solr-port
protocol: TCP
env:
- name: VERBOSE
value: "yes"
command:
- bash
- -c
- "exec /opt/solr/bin/solr start"
volumeMounts:
- name: solr-script
mountPath: /docker-entrypoint-initdb.d/
- name: datadir
mountPath: /opt/solr/
volumes:
- name: solr-script
configMap:
name: solr-configs
nodeSelector:
pool: solr-pool
Provisioned storage is empty by default and there might be a Deleting
retain policy on provisioned storage be sure to check those configurations. 预置存储默认情况下为空,并且在预置存储上可能存在“ Deleting
保留”策略,请务必检查这些配置。 You can also exec
to your pod and examine mounted volume and see if it's working properly or not (permission issues, read only file system) 您还可以exec
到Pod并检查已装入的卷,并查看其是否正常工作(权限问题,只读文件系统)
In may case there was a conflict with docker container configuration which used /opt/solr as a location for solr install and my attempt to mount separate PV under same location. 在可能的情况下,与使用/ opt / solr作为solr安装位置的docker容器配置发生冲突,并且我尝试在同一位置安装单独的PV。 Once this PV is mounted obviously I loose solr install. 一旦安装了该PV,显然我会松散安装solr。 The fixes for this are: 解决方法是:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.