简体   繁体   English

如何在 kubernetes 中使用 Windows 容器挂载卷?

[英]How to mount a volume with a windows container in kubernetes?

i'm trying to mount a persistent volume into my windows container, but i alwys get this error:我正在尝试将持久卷安装到我的 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]

i've created a github gist with the console output of "get events" and "describe sc | pvc | po" maybe someone will find the solution with it.我已经创建了一个github gist ,其中包含“get events”和“describe sc | pvc | po”的控制台输出,也许有人会找到解决方案。

Below are my scripts that I'm using for deployment.下面是我用于部署的脚本。

my storageclass:我的存储类:

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

my PersistentVolumeClaim:我的 PersistentVolumeClaim:

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

and the deployment of my container:以及我的容器的部署:

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

what am i doing wrong?我究竟做错了什么? is there another way to mount a volume?还有另一种方法来安装卷吗?

thank for every help :)感谢每一个帮助:)

I would try:我会尝试:

  1. Change API version to v1: https://kubernetes.io/docs/concepts/storage/storage-classes/#azure-disk将 API 版本更改为 v1: https : //kubernetes.io/docs/concepts/storage/storage-classes/#azure-disk
  2. kubectl get events to see you if have a more detailed error (I could figure out the reason when I used NFS watching events) kubectl get events看看你是否有更详细的错误(当我使用 NFS 监视事件时,我可以找出原因)
  3. maybe is this bug , I read in this post ?也许是这个错误,我在这篇文章中读到了?

You will need a new volume in D: drive, looks like folders in C: are not supported for Windows Containers, see here:您将需要 D: 驱动器中的新卷,看起来 Windows 容器不支持 C: 中的文件夹,请参见此处:

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

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在容器kubernetes中挂载文件并从应用程序访问文件 - How to mount a file and access it from application in a container kubernetes Kubernetes - 尝试部署时“安装卷失败” - Kubernetes - “Mount Volume Failed” when trying to deploy 如何使用REST API将文件存储卷安装到azure容器实例 - How to mount a File Storage volume to an azure container instance using REST api 如何在Azure(容器Web应用程序)上将卷(Azure文件共享)安装到基于Bitnami的Docker映像? - How to mount a volume (Azure File Share) to a bitnami-based docker image on Azure (Web App for Container)? Azure 容器实例 - 如何通过 Azure 门户从 Azure 文件共享挂载卷? - Azure Container Instances - how to mount volume from Azure File Share through the Azure Portal? 如何使用 docker-compose 将 Azure 文件共享挂载为容器组的卷? - How to mount Azure File Share as Volume for Container Group using docker-compose? 无法使用 Azure 文件配置器将卷安装到 Kubernetes 中的 pod - Cannot mount volume to pod in Kubernetes using Azure file provisioner 在 Azure kubernetes 上安装 PVC 卷需要一个多小时 - PVC volume mount on Azure kubernetes takes over an hour Azure kube.netes - 将 Azure blob 安装为一个卷并使用 python 写入? - Azure kubernetes - mount Azure blob as a volume and write using python? 在Azure App Service中使用docker容器时装入卷 - Mount a volume while using a docker container in Azure App Service
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM