我正在尝试按照文档中所述设置Kubernetes PetSet。创建PetSet时,似乎无法获得“持久卷声明”绑定(bind)到持久卷。这是我的用于定义PetSet的Yaml文件:
apiVersion: apps/v1alpha1
kind: PetSet
metadata:
name: 'ml-nodes'
spec:
serviceName: "ml-service"
replicas: 1
template:
metadata:
labels:
app: marklogic
tier: backend
annotations:
pod.alpha.kubernetes.io/initialized: "true"
spec:
containers:
- name: 'ml'
image: "192.168.201.7:5000/dcgs-sof/ml8-docker-final:v1"
imagePullPolicy: Always
ports:
- containerPort: 8000
name: ml8000
protocol: TCP
- containerPort: 8001
name: ml8001
- containerPort: 7997
name: ml7997
- containerPort: 8002
name: ml8002
- containerPort: 8040
name: ml8040
- containerPort: 8041
name: ml8041
- containerPort: 8042
name: ml8042
volumeMounts:
- name: ml-data
mountPath: /data/vol-data
lifecycle:
preStop:
exec:
# SIGTERM triggers a quick exit; gracefully terminate instead
command: ["/etc/init.d/MarkLogic stop"]
volumes:
- name: ml-data
persistentVolumeClaim:
claimName: ml-data
terminationGracePeriodSeconds: 30
volumeClaimTemplates:
- metadata:
name: ml-data
annotations:
volume.alpha.kubernetes.io/storage-class: anything
spec:
accessModes: [ "ReadWriteOnce" ]
resources:
requests:
storage: 2Gi
如果我对创建的PetSet进行“描述”,则会看到以下内容:
Name: ml-nodes
Namespace: default
Image(s): 192.168.201.7:5000/dcgs-sof/ml8-docker-final:v1
Selector: app=marklogic,tier=backend
Labels: app=marklogic,tier=backend
Replicas: 1 current / 1 desired
Annotations: <none>
CreationTimestamp: Tue, 20 Sep 2016 13:23:14 -0400
Pods Status: 0 Running / 1 Waiting / 0 Succeeded / 0 Failed
No volumes.
Events:
FirstSeen LastSeen Count From SubobjectPath Type Reason Message
--------- -------- ----- ---- ------------- -------- ------ -------
33m 33m 1 {petset } Warning FailedCreate pvc: ml-data-ml-nodes-0, error: persistentvolumeclaims "ml-data-ml-nodes-0" not found
33m 33m 1 {petset } Normal SuccessfulCreate pet: ml-nodes-0
我正在尝试在本地计算机的minikube环境中运行此程序。不确定我在这里缺少什么???
最佳答案
在minikube上有一个open issue。目前,minikube中尚未完成持久性卷配置支持。
为了使其能够与本地存储一起使用,它需要在 Controller 管理器上具有以下标志,并且在minikube上当前未启用该标志。
参考:http://kubernetes.io/docs/admin/kube-controller-manager/
对于本地开发/测试,如果在设置环境变量之后使用hack/local_up_cluster.sh
启动本地集群,则可以使用:
export ENABLE_HOSTPATH_PROVISIONER=true
关于docker - Kubernetes PetSet-永久卷创建失败,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/39600848/