Kubernetes指南
Linux性能优化实战eBPF 核心技术与实战SDN指南个人博客
中文
中文
  • 序言
  • 基础入门
    • Kubernetes 简介
    • Kubernetes 基本概念
    • Kubernetes 101
    • Kubernetes 201
    • Kubernetes 集群
  • 核心原理
    • 核心原理
    • 架构原理
    • 设计理念
    • 核心组件
      • etcd
      • kube-apiserver
      • kube-scheduler
      • kube-controller-manager
      • kubelet
      • kube-proxy
      • kube-dns
      • Federation
      • kubeadm
      • hyperkube
      • kubectl
    • 资源对象
      • Autoscaling
      • ConfigMap
      • CronJob
      • CustomResourceDefinition
      • DaemonSet
      • Deployment
      • Ingress
      • Job
      • LocalVolume
      • Namespace
      • NetworkPolicy
      • Node
      • PersistentVolume
      • Pod
      • PodPreset
      • ReplicaSet
      • Resource Quota
      • Secret
      • SecurityContext
      • Service
      • ServiceAccount
      • StatefulSet
      • Volume
  • 部署配置
    • 部署指南
    • kubectl 安装
    • 单机部署
    • 特性开关
    • 最佳配置
    • 版本支持
    • 集群部署
      • kubeadm
      • kops
      • Kubespray
      • Azure
      • Windows
      • LinuxKit
      • kubeasz
    • 附加组件
      • Addon-manager
      • DNS
      • Dashboard
      • 监控
      • 日志
      • Metrics
      • GPU
      • Cluster Autoscaler
      • ip-masq-agent
    • Kubernetes-The-Hard-Way
      • 准备部署环境
      • 安装必要工具
      • 创建计算资源
      • 配置创建证书
      • 配置生成配置
      • 配置生成密钥
      • 部署 Etcd 群集
      • 部署控制节点
      • 部署计算节点
      • 配置 Kubectl
      • 配置网络路由
      • 部署 DNS 扩展
      • 烟雾测试
      • 删除集群
  • 插件扩展
    • API 扩展
      • Aggregation
      • CustomResourceDefinition
    • 访问控制
      • 认证
      • RBAC 授权
      • 准入控制
    • Scheduler 扩展
    • 网络插件
      • CNI
      • Flannel
      • Calico
      • Weave
      • Cilium
      • OVN
      • Contiv
      • SR-IOV
      • Romana
      • OpenContrail
      • Kuryr
    • 运行时插件 CRI
      • CRI-tools
      • Frakti
    • 存储插件
      • 容器存储接口 CSI
      • FlexVolume
      • glusterfs
    • 网络策略
    • Ingress Controller
      • Ingress + Letsencrypt
      • minikube Ingress
      • Traefik Ingress
      • Keepalived-VIP
    • Cloud Provider 扩展
    • Device 插件
  • 服务治理
    • 服务治理
      • 一般准则
      • 滚动升级
      • Helm
      • Operator
      • Service Mesh
      • Linkerd
      • Linkerd2
    • Istio
      • 安装
      • 流量管理
      • 安全管理
      • 策略管理
      • 度量管理
      • 排错
      • 社区
    • Devops
      • Draft
      • Jenkins X
      • Spinnaker
      • Kompose
      • Skaffold
      • Argo
      • Flux GitOps
  • 实践案例
    • 实践概览
    • 资源控制
    • 集群高可用
    • 应用高可用
    • 调试
    • 端口映射
    • 端口转发
    • 用户管理
    • GPU
    • HugePage
    • 安全
    • 审计
    • 备份恢复
    • 证书轮换
    • 大规模集群
    • 大数据与机器学习
      • Spark
      • Tensorflow
    • Serverless
  • 排错指南
    • 排错概览
    • 集群排错
    • Pod 排错
    • 网络排错
    • PV 排错
      • AzureDisk
      • AzureFile
    • Windows 排错
    • 云平台排错
      • Azure
    • 排错工具
  • 社区贡献
    • 开发指南
    • 单元测试和集成测试
    • 社区贡献
  • 附录
    • 生态圈
    • 学习资源
    • 国内镜像
    • 如何贡献
    • 参考文档
由 GitBook 提供支持
在本页
  • 访问权限
  • Windows Node 重启后无法访问 AzureFile
  • AzureFile ProvisioningFailed
  • Azure German Cloud 无法使用 AzureFile
  • "could not change permissions" 错误
  • 参考文档
  1. 排错指南
  2. PV 排错

AzureFile

上一页AzureDisk下一页Windows 排错

最后更新于2年前

提供了基于 SMB 协议(也称 CIFS)托管文件共享服务。它支持 Windows 和 Linux 容器,并支持跨主机的共享,可用于多个 Pod 之间的共享存储。AzureFile 的缺点是性能(),并且不提供 Premium 存储。

推荐基于 StorageClass 来使用 AzureFile,即

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: azurefile
provisioner: kubernetes.io/azure-file
mountOptions:
  - dir_mode=0777
  - file_mode=0777
  - uid=1000
  - gid=1000
parameters:
  skuName: Standard_LRS

使用 AzureFile 推荐的版本:

Kubernetes version
Recommended version

1.12

1.12.6 或更高版本

1.13

1.13.4 或更高版本

1.14

1.14.0 或更高版本

>=1.15

>=1.15

访问权限

Kubernetes 版本
fileMode和dirMode

v1.6.x, v1.7.x

0777

v1.8.0-v1.8.5

0700

v1.8.6 or above

0755

v1.9.0

0700

v1.9.1-v1.12.1

0755

>=v1.12.2

0777

按照默认的权限会导致非跟用户无法在目录中创建新的文件,解决方法为

  • v1.8.0-v1.8.5:设置容器以 root 用户运行,如设置 spec.securityContext.runAsUser: 0

  • v1.8.6 以及更新版本:在 AzureFile StorageClass 通过 mountOptions 设置默认权限,比如设置为 0777 的方法为

kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: azurefile
provisioner: kubernetes.io/azure-file
mountOptions:
  - dir_mode=0777
  - file_mode=0777
  - uid=1000
  - gid=1000
  - mfsymlinks
  - nobrl
  - cache=none
parameters:
  skuName: Standard_LRS

Windows Node 重启后无法访问 AzureFile

Warning  Failed                 1m (x7 over 1m)  kubelet, 77890k8s9010  Error: Error response from daemon: invalid bind mount spec "c:\\var\\lib\\kubelet\\pods\\07251c5c-1cfc-11e8-8f70-000d3afd4b43\\volumes\\kubernetes.io~azure-file\\pvc-fb6159f6-1cfb-11e8-8f70-000d3afd4b43:c:/mnt/azure": invalid volume specification: 'c:\var\lib\kubelet\pods\07251c5c-1cfc-11e8-8f70-000d3afd4b43\volumes\kubernetes.io~azure-file\pvc-fb6159f6-1cfb-11e8-8f70-000d3afd4b43:c:/mnt/azure': invalid mount config for type "bind": bind source path does not exist
  Normal   SandboxChanged         1m (x8 over 1m)  kubelet, 77890k8s9010  Pod sandbox changed, it will be killed and re-created.

临时性解决方法为删除并重新创建使用了 AzureFile 的 Pod。当 Pod 使用控制器(如 Deployment、StatefulSet等)时,删除 Pod 后控制器会自动创建一个新的 Pod。

AzureFile ProvisioningFailed

Azure 文件共享的名字最大只允许 63 个字节,因而在集群名字较长的集群(Kubernetes v1.7.10 或者更老的集群)里面有可能会碰到 AzureFile 名字长度超限的情况,导致 AzureFile ProvisioningFailed:

persistentvolume-controller    Warning    ProvisioningFailed Failed to provision volume with StorageClass "azurefile": failed to find a matching storage account

在开启 RBAC 的集群中,由于 AzureFile 需要访问 Secret,而 kube-controller-manager 中并未为 AzureFile 自动授权,从而也会导致 ProvisioningFailed:

Events:
  Type     Reason              Age   From                         Message
  ----     ------              ----  ----                         -------
  Warning  ProvisioningFailed  8s    persistentvolume-controller  Failed to provision volume with StorageClass "azurefile": Couldn't create secret secrets is forbidden: User "system:serviceaccount:kube-syste
m:persistent-volume-binder" cannot create secrets in the namespace "default"
  Warning  ProvisioningFailed  8s    persistentvolume-controller  Failed to provision volume with StorageClass "azurefile": failed to find a matching storage account

解决方法是为 ServiceAccount persistent-volume-binder 授予 Secret 的访问权限:

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: system:azure-cloud-provider
rules:
- apiGroups: ['']
  resources: ['secrets']
  verbs:     ['get','create']
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: system:azure-cloud-provider
roleRef:
  kind: ClusterRole
  apiGroup: rbac.authorization.k8s.io
  name: system:azure-cloud-provider
subjects:
- kind: ServiceAccount
  name: persistent-volume-binder
  namespace: kube-system

Azure German Cloud 无法使用 AzureFile

"could not change permissions" 错误

在 Azure Files 插件上运行 PostgreSQL 时,可能会看到类似于以下内容的错误:

initdb: could not change permissions of directory "/var/lib/postgresql/data": Operation not permitted
fixing permissions on existing directory /var/lib/postgresql/data

此错误是由使用 cifs/SMB 协议的 Azure 文件插件导致的。 使用 cifs/SMB 协议时,无法在装载后更改文件和目录权限。 若要解决此问题,请将子路径与 Azure 磁盘插件结合使用。

参考文档

AzureFile 使用 将其远端存储挂载到 Node 上,而fileMode 和 dirMode 控制了挂载后文件和目录的访问权限。不同的 Kubernetes 版本,fileMode 和 dirMode 的默认选项是不同的

Windows Node 重启后,挂载 AzureFile 的 Pod 可以看到如下错误():

该问题的修复 包含在 v1.10 中。

碰到该问题时可以通过升级集群解决,其修复 已经包含在 v1.7.11、v1.8 以及更新版本中。

Azure German Cloud 仅在 v1.7.11+、v1.8+ 以及更新版本中支持(),升级 Kubernetes 版本即可解决。

AzureFile
较差
AKS#223
mount.cifs
#60624
#60625
#48326
#48460
Known kubernetes issues on Azure
Introduction of Azure File Storage
AzureFile volume examples
Persistent volumes with Azure files
Azure Files scalability and performance targets