pod mount azure files failed

William A Wang 236 Reputation points
2022-03-14T09:05:57.273+00:00

wanna deploy a mysql in cluster, and pod need a persistent storage, here are yaml & pictures:
The pod:
apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
containers:
- image: mysql:5.7
name: mypod
ports:
- containerPort: 3306
protocol: TCP
env:
- name: MYSQL_ROOT_PASSWORD
value: THEROOTPWD
volumeMounts:
- name: azure
mountPath: /var/lib/mysql/
volumes:
- name: azure
csi:
driver: file.csi.azure.com
volumeAttributes:
secretName: williamstoragekey
shareName: mysql
mountOptions: "dir_mode=0777,file_mode=0777,cache=strict,actimeo=30"

The secret:
kind: Secret
apiVersion: v1
metadata:
name: williamstoragekey
namespace: default
uid: 0e164956-2e2c-47ef-adc3-ffed8089a4a7
resourceVersion: '20976434'
creationTimestamp: '2022-03-14T07:13:38Z'
managedFields:
- manager: kubectl-create
operation: Update
apiVersion: v1
time: '2022-03-14T07:13:38Z'
fieldsType: FieldsV1
fieldsV1:
f:data:
.: {}
f:azurestorageaccountkey: {}
f:azurestorageaccountname: {}
f:type: {}
data:
azurestorageaccountkey: >-
TWYrMFRaQ0ZLQVIxcEtVMFJGNUdCSEFGcXVnREdYZDZ5V2JMd2hFeGJFeTd0Z1pmNWNFQjM2d3FQM1EwY0VkeExRckhKWVZMZnJvYlN0QlIzcEJOeHc9PQ==
azurestorageaccountname: a3ViZXRlc3RpbmcwMDk=
type: Opaque

The pod status:
182764-wechat-screenshot-20220314170655.png

And the inside the file share:
182720-wechat-screenshot-20220314170213.png

It's obviously the files inside mysql file share are created by mysql, but the pod seems crashed many times to start and terminated.

Azure Files
Azure Files
An Azure service that offers file shares in the cloud.
1,188 questions
Azure Kubernetes Service (AKS)
Azure Kubernetes Service (AKS)
An Azure service that provides serverless Kubernetes, an integrated continuous integration and continuous delivery experience, and enterprise-grade security and governance.
1,902 questions
0 comments No comments
{count} votes

Accepted answer
  1. Manu Philip 17,006 Reputation points MVP
    2022-03-15T03:41:25.433+00:00

    As it reports about the directory, just try a different path like mountPath: /var/lib/mysqla/
    Also, are you able to remove the folder rm -rf /usr/local/var/mysql within the container and try a start again


    --please don't forget to upvote and Accept as answer if the reply is helpful--

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Manu Philip 17,006 Reputation points MVP
    2022-03-14T11:28:06.72+00:00

    We may get more details to troubleshoot the issue by examining the pod logs
    Find the pods - kubectl get pods
    If the pods are occupied in a separate namespace use : kubectl --namespace my-namespace get pods
    Get the logs: kubectl logs pod-name

    Logs may have many lines.. To narrow down the issue, check the point where the error starts and pods failing