Azure file inline volume mount secret lookup is broken in aks 1.19.7
What happened: Upgrading to 1.19.7 broke azure files secret namespace lookup.
What you expected to happen: When creating a azure files volume i expect the pod to search in its own namespace not default.
How to reproduce it (as minimally and precisely as possible):
apiVersion: v1
kind: namespace
metadata:
name: test
--
apiVersion: v1
kind: Secret
metadata:
name: test-azure-files
name: test
data:
azurestorageaccountkey: <your-key-here>
azurestorageaccountname: <your-accountname-here>
--
apiVersion: v1
kind: Pod
metadata:
name: example
namespace: test
spec:
containers:
- name: test
image: 'ubuntu:latest'
volumeMounts:
- mountPath: /test
name: test
volumes:
- azureFile:
secretName: test-azure-files
shareName: <your-share-here>
name: test
Anything else we need to know?:
Environment:
- Kubernetes version (use
kubectl version): aks 1.19.7 - Size of cluster (how many worker nodes are in the cluster?) differs per environment.
- General description of workloads in the cluster (e.g. HTTP microservices, Java app, Ruby on Rails, machine learning, etc.) Http microservice.
- Others:
Hi tehho, AKS bot here :wave: Thank you for posting on the AKS Repo, I'll do my best to get a kind human from the AKS team to assist you.
I might be just a bot, but I'm told my suggestions are normally quite good, as such:
- If this case is urgent, please open a Support Request so that our 24/7 support team may help you faster.
- Please abide by the AKS repo Guidelines and Code of Conduct.
- If you're having an issue, could it be described on the AKS Troubleshooting guides or AKS Diagnostics?
- Make sure your subscribed to the AKS Release Notes to keep up to date with all that's new on AKS.
- Make sure there isn't a duplicate of this issue already reported. If there is, feel free to close this one and '+1' the existing issue.
- If you have a question, do take a look at our AKS FAQ. We place the most common ones there!
@andyzhangx
that is actually a bug fixed in 1.19.7: https://github.com/kubernetes/kubernetes/pull/97417
pls specify secretNamespace in azure file PV or azure file storage class if pod needs to specify a different namespace other than default, here is an example: https://github.com/andyzhangx/demo/blob/master/pv/pv-azurefile.yaml#L12
In tree azure file driver storage class parameters: https://github.com/kubernetes-sigs/azurefile-csi-driver/blob/master/docs/driver-parameters-intree.md
@andyzhangx We dont use pv or cis. Following https://github.com/kubernetes/examples/tree/master/staging/volumes/azure_file we use the "Mount volume directly in Pod" option. Tried to add secretNamespace to the azureFiles block but got an error saying the field is not supported. Is there anyway to do a direct volume on the pod or do we need to switch to pv?
@andyzhangx We dont use pv or cis. Following https://github.com/kubernetes/examples/tree/master/staging/volumes/azure_file we use the "Mount volume directly in Pod" option. Tried to add secretNamespace to the azureFiles block but got an error saying the field is not supported. Is there anyway to do a direct volume on the pod or do we need to switch to pv?
@tehho pod spec(using inline volume) does not have secretNamespace field, why do you want to use pod, if node is down, pod would disappear, right? Use deployment + PV/PVC is common solution in production.
We use deployments but would like to use it inline on the deployment for least effort on the fix :)
This very same issue bit me just an hour ago and was a PITA to figure out. Please at least add a line or two in the documentation about this.
We use deployments but would like to use it inline on the deployment for least effort on the fix :)
My problem exactly. The volume is directly specified in the deployment w/o any PV/PVC. It used to work, and now suddenly it doesn't.
one workaround is create secret in default namespace, we are in the process of moving to Azure File CSI driver, in CSI driver, it cannot get the namespace of pod, so anyway it will break at last, if secret is not in default namespace, the secretNamespace must be specified.
one workaround is create secret in
defaultnamespace, we are in the process of moving to Azure File CSI driver, in CSI driver, it cannot get the namespace of pod, so anyway it will break at last, if secret is not indefaultnamespace, thesecretNamespacemust be specified.
Yeah, in the end I ended up moving the secret to the default namespace. My criticism was directed towards changing the current working implementation silently to something that works differently.
Now, when do you expect this Azure File CSI Driver becomes available? I'm currently considering updating the rest of my clusters and I need to decide between moving the secret to the default namespace vs. moving to PV+PVC vs. waiting for the CSI Driver.
one workaround is create secret in
defaultnamespace, we are in the process of moving to Azure File CSI driver, in CSI driver, it cannot get the namespace of pod, so anyway it will break at last, if secret is not indefaultnamespace, thesecretNamespacemust be specified.Yeah, in the end I ended up moving the secret to the default namespace. My criticism was directed towards changing the current working implementation silently to something that works differently.
Now, when do you expect this Azure File CSI Driver becomes available? I'm currently considering updating the rest of my clusters and I need to decide between moving the secret to the default namespace vs. moving to PV+PVC vs. waiting for the CSI Driver.
@pbloigu I think you could move to PV+PVC with in-tree(default) azure file driver first, and set azureFile.secretNamespace in your config, does not need to wait for CSI driver, here is an example:
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-azurefile
spec:
capacity:
storage: 5Gi
accessModes:
- ReadWriteMany
azureFile:
secretName: azure-secret
secretNamespace: default
shareName: k8stest
readOnly: false
Inline volume only supports default namespace, original behavior(search for pod namespace) is actually an incorrect behavior(fixed by https://github.com/kubernetes/kubernetes/pull/97417), when CSI migration switch is turned on, there is no way to migrate to CSI driver since in CSI driver, it is not aware of pod namespace.
Finding out this issue the hard way has been very disappointing. I can understand that it was a "bug", but it's been around for so long that fixing it now, this way, in a minor update, and with absolutely no heads up, was completely unacceptable.
I've now had to spend multiple hours sorting the mess this created on our system, and completely rewriting chunks of our provisioning infrastructure. I would have been happy to do this properly, if MS had only bothered to communicate costumers of this change.
What a mess.
Triage required from @Azure/aks-pm
Action required from @Azure/aks-pm
Hit the same issue yesterday and found out the hard way too. Also i didnt make use of pvc/pv for azurefile as the documentation on both ms and k8s states
Hit this problem today the hard way as well. The 1.19.7 version should still be in preview considering this kind of issue.
@andyzhangx
Getting the following: error validating data: ValidationError(Deployment.spec.template.spec.volumes[1].azureFile): unknown field "secretNamespace" in io.k8s.api.core.v1.AzureFileVolumeSource
Is there something we need to update to support this?
@andyzhangx Getting the following:
error validating data: ValidationError(Deployment.spec.template.spec.volumes[1].azureFile): unknown field "secretNamespace" in io.k8s.api.core.v1.AzureFileVolumeSourceIs there something we need to update to support this?
"secretNamespace" is not supported on the direct volume mount, only with persistent volume mount. I have made a PR (https://github.com/kubernetes/kubernetes/pull/98967) to fix this but since this would introduce a API change and direct volume is to be deprecated with the support for CSI it's not likely to be merged
This completely breaks our system. We can't use the default namespace to host that secret since it conflicts and we rely on namespace isolation.
@winromulus could you please try to recreate the PV ( delete then create it )
@amjadaljunaidi - We managed to fix this by moving away from directly attached volumes (inline) to PV+PVC but we had to break a lot of other things to work around this issue:
- PVs are cluster-level resources so we had to break the namespace level permissions in order to allow the deployment of the PVs (this defeats the entire purpose of Azure DevOps Environments for Kubernetes where the serviceAccount has access to only one namespace)
- We had to update everything on the fly (templates etc. and workaround third party Helm charts) to make changes to deployments to use PVCs
Personally I'm extremely disappointed in the lack of visibility into this breaking change done by AKS team for a Kubernetes revision bump. If this was in a minor version bump and in preview, I could have understood and I would have expected this. We checked our application for Kubernetes changes that might be affected in the new stable version, not AKS specific hidden gems.
For inline volumes it would have been good to have secretNamespace support as well so AKS would support a normal Kubernetes feature instead of adding a limitation. Even if this was still a breaking change, it would have been easier to fix than saying "Do not use Pods, go with Deployments". We might want Pods.
I want to thank the AKS support team that found this ticket for us.