Azure file shared storage in Kubernetes pod checks default namespace for secrets

Viewed 174

I am following setting up the Azure File share to the pod.

  • created the namespace
  • created the secrets as specified
  • pod configuration
apiVersion: v1
kind: Pod
metadata:
  name: test-storage-pod
  namespace: storage-test 
spec:
  containers:
  - image: nginx:latest 
    name: test-storage-pod
    resources:
      requests:
        cpu: 100m
        memory: 128Mi
      limits:
        cpu: 250m
        memory: 256Mi
    volumeMounts:
      - name: azure
        mountPath: /mnt/azure-filestore
  volumes:
  - name: azure
    azureFile:
      secretName: azure-storage-secret
      shareName: appdata/data
      readOnly: false
  • kubectl describe -n storage-test pod/<pod-name> or kubectl get -n storage-test event
LAST SEEN   TYPE      REASON        OBJECT                 MESSAGE
2m13s       Normal    Scheduled     pod/test-storage-pod   Successfully assigned storage-test/test-storage-pod to aks-default-1231523-vmss00001a
6s          Warning   FailedMount   pod/test-storage-pod   MountVolume.SetUp failed for volume "azure" : Couldn't get secret default/azure-storage-secret
11s         Warning   FailedMount   pod/test-storage-pod   Unable to attach or mount volumes: unmounted volumes=[azure], unattached volumes=[default-token-gzxk8 azure]: timed out waiting for the condition

Question:

  • the secret is created under the namespace storage-test as well, is that Kubelet first checks the storage under default namespace?
1 Answers

Probably you are working default namespace, that's why Kubelet first checks the default namespace. Please try to switch to your created namespace with the command:

kubens storage-test

Try to run your pod under storage-test namespace once again.

Related