<p>I'm trying to set a new default storage class in our Azure Kubernetes Service. (1.15.10). I've tried a few things but the behavior is strange to me. </p>

<p>I've created a new storage class <code>custom</code>, set it to be the default storage class and then I remove the is-default-class from the <code>default</code> storageclass. </p>

<p>default-storage-class.yml:</p>

<pre><code>apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: custom
parameters:
  cachingmode: ReadOnly
  kind: Managed
  storageaccounttype: Standard_LRS
provisioner: kubernetes.io/azure-disk
reclaimPolicy: Delete
volumeBindingMode: Immediate
</code></pre>

<p>and the commands:</p>

<pre><code># create new storage class "custom"
kubectl apply -f ./default-storage-class.yml
# set storageclass as new default
kubectl patch storageclass custom -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}'
# remove default storage class from default
kubectl patch storageclass default -p '{"metadata": {"annotations":{"storageclass.beta.kubernetes.io/is-default-class":"false"}}}'
</code></pre>

<p>At first, it seems to be working fine: </p>

<pre><code>$kubectl get sc
custom (default)   kubernetes.io/azure-disk   6d23h
default            kubernetes.io/azure-disk   14m
</code></pre>

<p>But within a minute, without changing anything: </p>

<pre><code>$kubectl get sc
custom (default)   kubernetes.io/azure-disk   6d23h
default (default)  kubernetes.io/azure-disk   16m
</code></pre>

<p>I'm probably missing something here, but no idea what. </p>

<p>If I do a <code>kubectl describe sc default</code> in the minute it hasn't changed back : </p>

<pre><code>storageclass.beta.kubernetes.io/is-default-class=false,storageclass.kubernetes.io/is-default-class=false
</code></pre>

<p>And a moment later: </p>

<pre><code>storageclass.beta.kubernetes.io/is-default-class=true,storageclass.kubernetes.io/is-default-class=false
</code></pre>

<p>After a lot of testing, found the only way to make the default to be not default was by updating not only the <code>storageclass.beta.kubernetes.io/is-default-class</code> annotation but <code>kubectl.kubernetes.io/last-applied-configuration</code> annotation as well.</p>
<pre><code>kubectl patch storageclass default -p '{&quot;metadata&quot;: {&quot;annotations&quot;:{&quot;storageclass.beta.kubernetes.io/is-default-class&quot;:&quot;false&quot;, &quot;kubectl.kubernetes.io/last-applied-configuration&quot;: &quot;{\&quot;allowVolumeExpansion\&quot;:true,\&quot;apiVersion\&quot;:\&quot;storage.k8s.io/v1beta1\&quot;,\&quot;kind\&quot;:\&quot;StorageClass\&quot;,\&quot;metadata\&quot;:{\&quot;annotations\&quot;:{\&quot;storageclass.beta.kubernetes.io/is-default-class\&quot;:\&quot;false\&quot;},\&quot;labels\&quot;:{\&quot;kubernetes.io/cluster-service\&quot;:\&quot;true\&quot;},\&quot;name\&quot;:\&quot;default\&quot;},\&quot;parameters\&quot;:{\&quot;cachingmode\&quot;:\&quot;ReadOnly\&quot;,\&quot;kind\&quot;:\&quot;Managed\&quot;,\&quot;storageaccounttype\&quot;:\&quot;StandardSSD_LRS\&quot;},\&quot;provisioner\&quot;:\&quot;kubernetes.io/azure-disk\&quot;}&quot;}}}'
</code></pre>
<p>After applying this, default StorageClass stayed non-default.</p>
