如何在kubernetes中安装带有windows容器的卷?

时间:2018-06-07 12:16:43

标签: azure docker kubernetes azure-container-service

我正在尝试将持久性卷安装到我的Windows容器中,但我发现这个错误:

Unable to mount volumes for pod "mssql-with-pv-deployment-3263067711-xw3mx_default(....)": timeout expired waiting for volumes to attach/mount for pod "default"/"mssql-with-pv-deployment-3263067711-xw3mx". list of unattached/unmounted volumes=[blobdisk01]

我创建了一个github gist,其控制台输出为“get events”和“describe sc | pvc | po”,也许有人会找到它的解决方案。

以下是我用于部署的脚本。

我的存储类:

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: azure-disk-sc
provisioner: kubernetes.io/azure-disk
parameters:
  skuname: Standard_LRS

我的PersistentVolumeClaim:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: azure-disk-pvc
spec:
  storageClassName: azure-disk-sc
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi

和我的容器的部署:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: mssql-with-pv-deployment
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: mssql-with-pv
    spec:
      nodeSelector:
        beta.kubernetes.io/os: windows
      terminationGracePeriodSeconds: 10
      containers:
      - name: mssql-with-pv
        image: testacr.azurecr.io/sql/mssql-server-windows-developer
        ports:
        - containerPort: 1433
        env:
        - name: ACCEPT_EULA
          value: "Y"
        - name: SA_PASSWORD
          valueFrom:
            secretKeyRef:
              name: mssql
              key: SA_PASSWORD
        volumeMounts:
        - mountPath: "c:/volume"
          name: blobdisk01
      volumes:
      - name: blobdisk01
        persistentVolumeClaim:
          claimName: azure-disk-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: mssql-with-pv-deployment
spec:
  selector:
    app: mssql-with-pv
  ports:
    - protocol: TCP
      port: 1433
      targetPort: 1433
  type: LoadBalancer
我在做错了什么?还有另一种安装卷的方法吗?

感谢您的帮助:)

2 个答案:

答案 0 :(得分:0)

我会尝试:

  1. 将API版本更改为v1:https://kubernetes.io/docs/concepts/storage/storage-classes/#azure-disk
  2. kubectl get events看到你是否有更详细的错误(我可以弄清楚当我使用NFS观看事件时的原因)
  3. 也许这是bug,我在此阅读post

答案 1 :(得分:0)

Windows容器不支持D:驱动器中的新卷,就像C:中的文件夹一样,请参见:

https://github.com/kubernetes/kubernetes/issues/65060

演示: https://github.com/andyzhangx/demo/tree/master/windows/azuredisk