Aks-engine: (question): how to reference precreated static managed disk in StorageClass ?

Created on 29 Jul 2020  路  6Comments  路  Source: Azure/aks-engine

How can I reference static (precreated) managed disk for storageClass ?

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: mySA
provisioner: kubernetes.io/azure-disk
parameters:
  storageaccounttype: Premium_LRS
  kind: Managed
  resourceGroup: myRG
reclaimPolicy: Retain
allowVolumeExpansion: true

This ^ will create pvc-* ( not sure what id suffix mean ) managed disk in myRG group, but what if I delete AKS and I want to reference this managed disk in mySA storageclass in another AKS ?

Something like this:

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: mySA
provisioner: kubernetes.io/azure-disk
parameters:
  id: /subscriptions/<subscription>/resourceGroups/myRG/providers/Microsoft.Compute/disks/kubernetes-dynamic-pvc-2961592c-5737-4751-8fa9-279f3948730f
reclaimPolicy: Retain
allowVolumeExpansion: true

Thanks

bug

All 6 comments

馃憢 Thanks for opening your first issue here! If you're reporting a 馃悶 bug, please make sure you include steps to reproduce it.

Hi @lukasmrtvy. You could reference it via a combination of PersistentVolume (https://github.com/andyzhangx/demo/blob/master/pv/pv-azuredisk-managed.yaml) + PVC (https://github.com/andyzhangx/demo/blob/master/pv/pvc-azuredisk-static.yaml) or inline volume (https://docs.microsoft.com/en-us/azure/aks/azure-disk-volume#mount-disk-as-volume).

@chewong
Thanks.

Can You help with this use case ?

Helm chart, that I am using can set only ( statefulset ):

  • storageClassName
  • matchLabels
  • matchExpressions
  • accessModes
  • annotations
  • size

But I want to use/reference static disk file ( precreated ). Which is not possible with storageClassName.

I tried to simulate this:

---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: test-pv
  labels:
    foo: bar
spec:
  accessModes:
    - ReadWriteMany
  capacity:
    storage: "1Gi" 
  persistentVolumeReclaimPolicy: Retain
  azureDisk: 
    kind: Managed
    diskName: DISK
    diskURI: /subscriptions/SUBS/resourceGroups/RG/providers/Microsoft.Compute/disks/DISK
---
apiVersion: v1
kind: Namespace
metadata
   name: foobar
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: test-pvc
  namespace: foobar
spec:
  accessModes:
    - ReadWriteOnce 
  storageClassName: ""
  resources:
    requests:
      storage: 5Gi
  selector:
    matchLabels:
      foo: bar

but I am getting:
Normal FailedBinding 11s (x3 over 30s) persistentvolume-controller no persistent volumes available for this claim and no storage class is set

Thanks

You will probably need to modify your helm chart so that you can point volumeName in your pvc spec to your test-pv. You should also create the pv and pvc first before you create the statefulset, then point volumeClaimTemplates in the statefulset spec to test-pvc.

This is working for me:

---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: meta-only
provisioner: kubernetes.io/azure-disk
---
apiVersion: v1
kind: PersistentVolume
metadata:
  name: test-pv
  labels:
    app: static 
spec:
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteOnce
  persistentVolumeReclaimPolicy: Retain
  azureDisk:
    kind: Managed
    diskName: DISK
    diskURI: /subscriptions/SUBS/resourceGroups/RG/providers/Microsoft.Compute/disks/DISK
    fsType: ext4
    readOnly: false
    cachingMode: ReadOnly
  storageClassName: meta-only
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: test-pvc
spec:
  selector:
     matchLabels:
       app: static
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
  storageClassName: meta-only

Cool, feel free to re-open the issue if you have any more questions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sylus picture sylus  路  5Comments

javierprovecho picture javierprovecho  路  5Comments

sylr picture sylr  路  4Comments

UncleTawnos picture UncleTawnos  路  3Comments

serbrech picture serbrech  路  5Comments