Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
具有本地持久性存储的Kubernetes Minikube_Kubernetes_Minikube - Fatal编程技术网

具有本地持久性存储的Kubernetes Minikube

具有本地持久性存储的Kubernetes Minikube,kubernetes,minikube,Kubernetes,Minikube,我目前正试图在Minikube上部署以下内容。我使用配置文件将主机路径用作minikube节点上的持久存储 apiVersion: v1 kind: PersistentVolume metadata: name: "pv-volume" spec: capacity: storage: "20Gi" accessModes: - "ReadWriteOnce" hostPath: path: /data --- apiVersion: v1 kind:

我目前正试图在Minikube上部署以下内容。我使用配置文件将主机路径用作minikube节点上的持久存储

apiVersion: v1
kind: PersistentVolume
metadata:
  name: "pv-volume"
spec:
  capacity:
    storage: "20Gi"
  accessModes:
    - "ReadWriteOnce"
  hostPath:
    path: /data
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: "orientdb-pv-claim"
spec:
  accessModes:
    - "ReadWriteOnce"
  resources:
    requests:
      storage: "20Gi"
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: orientdbservice 
spec:
  #replicas: 1
  template:
    metadata:
     name: orientdbservice
     labels:
       run: orientdbservice
       test: orientdbservice
    spec:
      containers:
        - name: orientdbservice
          image: orientdb:latest
          env:
           - name: ORIENTDB_ROOT_PASSWORD
             value: "rootpwd"
          ports:
          - containerPort: 2480
            name: orientdb
          volumeMounts:
          - name: orientdb-config
            mountPath: /data/orientdb/config
          - name: orientdb-databases
            mountPath: /data/orientdb/databases 
          - name: orientdb-backup
            mountPath: /data/orientdb/backup
      volumes:
          - name: orientdb-config
            persistentVolumeClaim:
              claimName: orientdb-pv-claim
          - name: orientdb-databases
            persistentVolumeClaim:
              claimName: orientdb-pv-claim
          - name: orientdb-backup
            persistentVolumeClaim:
              claimName: orientdb-pv-claim
---
apiVersion: v1
kind: Service
metadata:
  name: orientdbservice
  labels:
    run: orientdbservice
spec:
  type: NodePort
  selector:
    run: orientdbservice
  ports:
   - protocol: TCP
     port: 2480
     name: http
其结果如下

#kubectl get pv
NAME                                       CAPACITY   ACCESSMODES   RECLAIMPOLICY   STATUS      CLAIM                       STORAGECLASS   REASON    AGE
pv-volume                                  20Gi       RWO           Retain          Available                                                        4h
pvc-cd14d593-78fc-11e7-a46d-1277ec3dd2b5   20Gi       RWO           Delete          Bound       default/orientdb-pv-claim   standard                 4h
#kubectl get pvc
NAME                STATUS    VOLUME                                     CAPACITY   ACCESSMODES   STORAGECLASS   AGE
orientdb-pv-claim   Bound     pvc-cd14d593-78fc-11e7-a46d-1277ec3dd2b5   20Gi       RWO 
#kubectl get svc
NAME              CLUSTER-IP   EXTERNAL-IP   PORT(S)          AGE
orientdbservice   10.0.0.16    <nodes>       2480:30552/TCP   4h
#kubectl get pods
NAME                              READY     STATUS              RESTARTS   AGE
orientdbservice-458328598-zsmw5   0/1       ContainerCreating   0          4h
#kubectl describe pod orientdbservice-458328598-zsmw5
Events:
  FirstSeen LastSeen    Count   From            SubObjectPath   TypeReason      Message
  --------- --------    -----   ----            -------------   --------    ------      -------
  4h        1m      37  kubelet, minikube           Warning     FailedMount Unable to mount volumes for pod "orientdbservice-458328598-zsmw5_default(392b1298-78ff-11e7-a46d-1277ec3dd2b5)": timeout expired waiting for volumes to attach/mount for pod "default"/"orientdbservice-458328598-zsmw5". list of unattached/unmounted volumes=[orientdb-databases]
  4h        1m      37  kubelet, minikube           Warning     FailedSync  Error syncing pod
我在节点上创建持久卷和PersistentVolumeClaim的方式是否有错误

minikube version: v0.20.0

感谢所有帮助

您的配置很好。

minikube v0.24.0
minikube v0.25.0
minikube v0.26.1
下测试,没有任何问题

请记住,minikube正在积极开发,特别是在windows下,就像人们说的实验软件

更新至minikube的更新版本并重新部署。这应该可以解决问题

您可以使用
minikube update check
命令检查更新,其结果如下:

$ minikube update-check
CurrentVersion: v0.25.0
LatestVersion: v0.26.1
要升级minikube,只需键入
minikube delete
,即可删除当前的minikube安装,并按说明下载新版本

$ minikube delete
There is a newer version of minikube available (v0.26.1).  Download it here:
https://github.com/kubernetes/minikube/releases/tag/v0.26.1

To disable this notification, run the following:
minikube config set WantUpdateNotification false
Deleting local Kubernetes cluster...
Machine deleted.
对于供应器
provisioner:k8s.io/minikube主机路径
minikube
中的供应器不起作用

因此:

  • 删除默认存储类
    kubectl删除存储类标准
  • 创建以下存储类:
    
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: standard
    provisioner: docker.io/hostpath
    reclaimPolicy: Retain
    

    -现在部署您的yaml:
    kubectl create-f youroorientdb.yaml

    为什么我必须删除标准存储类?为什么不用另一个名称创建另一个StorageClass?
    
    apiVersion: storage.k8s.io/v1
    kind: StorageClass
    metadata:
      name: standard
    provisioner: docker.io/hostpath
    reclaimPolicy: Retain
    
    
    apiVersion: extensions/v1beta1
    kind: Deployment
    metadata:
      name: orientdbservice
    spec:
      #replicas: 1
      template:
        metadata:
         name: orientdbservice
         labels:
           run: orientdbservice
           test: orientdbservice
        spec:
          containers:
            - name: orientdbservice
              image: orientdb:latest
              env:
               - name: ORIENTDB_ROOT_PASSWORD
                 value: "rootpwd"
              ports:
              - containerPort: 2480
                name: orientdb
              volumeMounts:
              - name: orientdb
                mountPath: /data/orientdb/config
                subPath: config
              - name: orientdb
                mountPath: /data/orientdb/databases
                subPath: databases
              - name: orientdb
                mountPath: /data/orientdb/backup
                subPath: backup
          volumes:
              - name: orientdb
                persistentVolumeClaim:
                  claimName: orientdb-pv-claim