如何配置手动配置的Azure托管磁盘以用作Kubernetes永久卷? [英] How to configure a manually provisioned Azure Managed Disk to use as a Kubernetes persistent volume?

查看:163
本文介绍了如何配置手动配置的Azure托管磁盘以用作Kubernetes永久卷?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试运行 Jenkins Helm图表.作为此设置的一部分,我想传入一个我提前配置的永久卷(或在迁移过程中从另一个集群导出的永久卷).

I'm trying to run the Jenkins Helm chart. As part of this setup, I'd like to pass in a persistent volume that I provisioned ahead of time (or perhaps exported from another cluster during a migration).

我正在尝试以这样的一种方式来设置我的永久卷(PV)和永久卷声明(PVC),即在Jenkins启动时,它将使用我预定义的PV和PVC.

I'm trying to get my persistent volume (PV) and persistent volume claim (PVC) setup in a such a way that when Jenkins starts, it uses my predefined PV and PVC.

我认为问题出在Azure磁盘指向存储帐户中的VHD的持久存储定义上.有什么办法可以将其指向现有的托管磁盘-而不是blob?

I think the problem originates from the persistent storage definition for the Azure disk points to a VHD in my storage account. Is there any way to point it to an existing managed disk -and not a blob?

这是我使用Azure托管磁盘设置持久性存储的方式

This is how I setup my persistent storage using Azure Managed Disk

apiVersion: v1
kind: PersistentVolume
metadata:
  name: jenkins-home
spec:
  capacity:
    storage: 10Gi
  storageClassName: default
  azureDisk:
    diskName: jenkins-home
    diskURI: https://<storageaccount>.blob.core.windows.net/jenkins-data/jenkins-home.vhd
    fsType: ext4
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  claimRef:
    name: jenkins-home-pvc
    namespace: default
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jenkins-home-pvc
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  storageClassName: default

然后我像这样开始掌舵...

I then start helm like this...

helm install --name jenkins stable/jenkins --values=values.yaml

我的values.yaml文件的外观

Persistence:
  ExistingClaim: jenkins-home-pvc

这是詹金斯(Jenkins)的吊舱启动时收到的错误.

Here is the error I receive when the Jenkins' pod starts.

AttachVolume.Attach对卷"jenkins-home"的附加失败:将卷"jenkins-home"附加到实例"aks-agentpool-40897452-0",而compute.VirtualMachinesClient#CreateOrUpdate:对请求的响应失败:StatusCode = 409- -原始错误:autorest/azure:服务返回了错误. Status = 409 Code ="OperationNotAllowed" Message =不支持将基于Blob的磁盘添加到具有托管磁盘的VM."

AttachVolume.Attach failed for volume "jenkins-home" : Attach volume "jenkins-home" to instance "aks-agentpool-40897452-0" failed with compute.VirtualMachinesClient#CreateOrUpdate: Failure responding to request: StatusCode=409 -- Original Error: autorest/azure: Service returned an error. Status=409 Code="OperationNotAllowed" Message="Addition of a blob based disk to VM with managed disks is not supported."

推荐答案

我向Azure团队提出了这个问题

I posed this question to the Azure team here.

在他们的帮助下,我得出了以下解决方案...

Through their help I arrived at the following solution...

我以前曾尝试使用托管磁盘资源ID,但是它对我大吼,说它期望使用.vhd文件.但是在添加了"kind:Managed"后,非常高兴地获得了托管磁盘资源ID.

I had tried to use the managed disk resource ID before but it yelled at me saying it expected a .vhd file. But after adding 'kind: Managed', it was perfectly happy to take the managed disk resource id.

创建一个空的且格式化的托管磁盘当然是实现此功能的先决条件.还需要将托管磁盘复制到与AKS群集相同的资源组中.

Creating an empty and formatted managed disk is of course a pre-requisite for this to work. Copying the managed disk into the same resource group as the AKS cluster was also required.

所以现在我的PV和PVC看起来像这样,并且正在工作...

So now my PV and PVC look like this and it's working...

apiVersion: v1
kind: PersistentVolume
metadata:
  name: jenkins-home
spec:
  capacity:
    storage: 10Gi
  storageClassName: default
  azureDisk:
    kind: Managed
    diskName: jenkins-home
    diskURI: /subscriptions/{subscription-id}/resourceGroups/{aks-controlled-resource-group-name}/providers/Microsoft.Compute/disks/jenkins-home
    fsType: ext4
  accessModes:
  - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  claimRef:
    name: jenkins-home-pvc
    namespace: default
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: jenkins-home-pvc
  annotations:
    volume.beta.kubernetes.io/storage-class: default
spec:
  accessModes:
  - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi
  storageClassName: default

这篇关于如何配置手动配置的Azure托管磁盘以用作Kubernetes永久卷?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆