k8s nfs pv StatefulSet volumeClaimTemplates
k8s nfs pv StatefulSetvolumeClaimTemplates
·
文章目录
一、pv
apiVersion: v1
kind: PersistentVolume
metadata:
name: redis-pv
labels:
app: redis
spec:
capacity:
storage: 1Gi
volumeMode: Filesystem
storageClassName: redis-storage
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
nfs:
path: /home/data/redis
server: k8snfs
二、StatefulSet
## kubectl apply -f redis.yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: redis
spec:
selector:
matchLabels:
app: redis
serviceName: "redis"
replicas: 1
template:
metadata:
labels:
app: redis
spec:
terminationGracePeriodSeconds: 10
containers:
- name: redis
image: redis:latest
imagePullPolicy: IfNotPresent
command: ["/bin/sh","-c","redis-server /redis/redis.conf "]
ports:
- containerPort: 6379
volumeMounts:
- name: redis-persistent-storage
mountPath: /redis
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: nodeType
operator: In
values:
- middleware
volumeClaimTemplates:
- metadata:
name: redis-persistent-storage
spec:
storageClassName: redis-storage
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
更多推荐
已为社区贡献7条内容
所有评论(0)