我有以下redis.yaml文件,在其中创建GKE持久卷,并尝试将其挂载在redis有状态集中。但是,转接框永远不会出现,并且永远保持在Pending
状态。有帮助吗?
redis.yaml
apiVersion: v1
kind: Service
metadata:
name: my-redis
spec:
ports:
- port: 6379
name: my-redis
type: LoadBalancer
selector:
app: my-redis
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: my-storage-class
provisioner: kubernetes.io/gce-pd
parameters:
type: pd-ssd
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: my-redis-volume-claim
spec:
storageClassName: my-storage-class
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
---
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
name: my-redis
spec:
selector:
matchLabels:
app: my-redis # has to match .spec.template.metadata.labels
serviceName: my-redis
replicas: 1
template:
metadata:
labels:
app: my-redis # has to match .spec.selector.matchLabels
spec:
nodeSelector:
node-name: default
containers:
- name: redis
image: redis:3.2-alpine
args:
[
"--requirepass",
"$(REDIS_PASS)",
"--appendonly",
"yes",
"--save",
"30",
"1",
]
ports:
- containerPort: 6379
name: redis
env:
- name: REDIS_PASS
value: password
volumeMounts:
- name: my-redis-volume
mountPath: /data
volumes:
- name: my-redis-volume
persistentVolumeClaim:
claimName: my-redis-volume-claim
即使10分钟后,窗格仍处于Pending
状态。我认为我在卷创建中缺少某些内容,但无法弄清楚它是什么。
➜ kubectl apply -f redis.yaml
service/my-redis created
storageclass.storage.k8s.io/my-storage-class created
persistentvolumeclaim/my-redis-volume-claim created
statefulset.apps/my-redis created
➜ kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
pvc-bc439c93-881a-11e9-9958-42010a800034 10Gi RWO Delete Bound default/my-redis-volume-claim my-storage-class 14s
➜ kubectl get statefulsets
NAME DESIRED CURRENT AGE
my-redis 1 1 31s
➜ kubectl get pods
NAME READY STATUS RESTARTS AGE
my-redis-0 0/1 Pending 0 36s