如何解决Kubernetes - 尝试部署时“挂载卷失败”
我部署了我的第一个容器,我得到了信息:
deployment.apps/frontarena-ads-deployment created
但后来我看到我的容器创建卡在等待状态。
然后我看到了使用 kubectl describe pod frontarena-ads-deployment-5b475667dd-gzmlp
的日志并看到了 MountVolume 错误,我无法弄清楚为什么会抛出它:
警告 FailedMount 9m24s kubelet MountVolume.SetUp 卷“ads-filesharevolume”失败:挂载失败:退出状态 32 挂载命令: systemd-run 挂载参数:--description=Kubernetes 瞬态 安装为 /var/lib/kubelet/pods/85aa3bfa-341a-4da1-b3de-fb1979420028/volumes/kubernetes.io~azure-file/ads-filesharevolume --scope -- mount -t cifs -o username=frontarenastorage,password=mypassword,file_mode=0777,dir_mode=0777,vers=3.0 //frontarenastorage.file.core.windows.net/azurecontainershare /var/lib/kubelet/pods/85aa3bfa-341a-4da1-b3de-fb1979420028/volumes/kubernetes.io~azure-file/ads-filesharevolume 输出:运行范围为单位 运行-rf54d5b5f84854777956ae0e25810bb94.scope。安装错误(115): 操作正在进行中 请参阅 mount.cifs(8) 手册页(例如 man mount.cifs)
在运行部署之前,我使用已创建的 azure 文件共享在 Azure 中创建了一个机密,我在 YAML 中引用了该共享文件。
$AKS_PERS_STORAGE_ACCOUNT_NAME="frontarenastorage"
$STORAGE_KEY="mypassword"
kubectl create secret generic fa-fileshare-secret --from-literal=azurestorageaccountname=$AKS_PERS_STORAGE_ACCOUNT_NAME --from-literal=azurestorageaccountkey=$STORAGE_KEY
在该文件共享中,我有需要挂载的文件夹和文件,我在 YAML 中引用了 azurecontainershare:
我的 YAML 看起来像这样:
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontarena-ads-deployment
labels:
app: frontarena-ads-deployment
spec:
replicas: 1
template:
metadata:
name: frontarena-ads-aks-test
labels:
app: frontarena-ads-aks-test
spec:
containers:
- name: frontarena-ads-aks-test
image: faselect-docker.dev/frontarena/ads:test1
imagePullPolicy: Always
ports:
- containerPort: 9000
volumeMounts:
- name: ads-filesharevolume
mountPath: /opt/front/arena/host
volumes:
- name: ads-filesharevolume
azureFile:
secretName: fa-fileshare-secret
shareName: azurecontainershare
readOnly: false
imagePullSecrets:
- name: fa-repo-secret
selector:
matchLabels:
app: frontarena-ads-aks-test
解决方法
问题是由于部署 AKS 群集和 Azure 文件共享的不同 Azure 区域造成的。如果他们在同一个地区,你就不会遇到这个问题。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。