Kubernetes pod 中的 Azure 文件共享存储检查机密的默认命名空间

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

我正在关注 setting up the Azure File share to the pod

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
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

问题:

可能您正在使用默认命名空间,这就是 Kubelet 首先检查默认命名空间的原因。请尝试使用以下命令切换到您创建的命名空间:

kubens storage-test

再次尝试 运行 您的 pod 在 storage-test 命名空间下。