mysql-operator icon indicating copy to clipboard operation
mysql-operator copied to clipboard

Create a cluster with a persistent volume failed

Open linqingping opened this issue 6 years ago • 6 comments

Is this a BUG REPORT or FEATURE REQUEST?

BUG REPORT

Versions

MySQL Operator Version:8.0.12

Environment:

  • Kubernetes version (use kubectl version):Client Version:v1.13.4,Server Version:v1.13.4
  • Cloud provider or hardware configuration:Bare metal ,k8s run in docker container(Deployed via rancher2.0),Single Node Cluster
  • OS (e.g. from /etc/os-release):CentOS Linux 7 (Core)
  • Kernel (e.g. uname -a):3.10.0-957.5.1.el7.x86_64
  • Others:Docker version 18.06.0-ce,

What happened?

When I refer to the tutorial(https://github.com/oracle/mysql-operator/blob/master/docs/user/clusters.md#clusters) to Create a cluster with a persistent volume,An error has occurred: Error: stat /tmp/data no such file or directory

But,I had create the directory " /tmp/data" on each k8s worker node.

What you expected to happen?

persistent volume can use arbitrary path

How to reproduce it (as minimally and precisely as possible)?

1.Create the MySQL passwordcd kubectl create secret generic wordpress-mysql-root-password --from-literal=password=password 2.Create the database kubectl apply -f wordpress-database.yaml the yaml file image 3.get pod info image 4.describe pod image 5.get pv and pvc image 6.ls -ld /tmp/data image

Anything else we need to know?

Why is it possible to create success with "/tmp" and nothing else?

linqingping avatar Mar 19 '19 13:03 linqingping

@linqingping If I understand correctly this looks like a permissions / Kubernetes cluster configuration issue as the Pod isn't starting. I suggest first trying to manually create a Pod that mounts your PVC and seeing if you run into the same problem.

prydie avatar Mar 19 '19 14:03 prydie

@prydie Thanks for you help!But create a Pod that mounts my PVC not have this problem! how can I do? the detail info: image image

kubectl describe po mysql-7879778879-b64mn Name: mysql-7879778879-b64mn Namespace: default Priority: 0 PriorityClassName: Node: 192.168.33.11/192.168.33.11 Start Time: Tue, 19 Mar 2019 23:07:39 +0800 Labels: app=mysql pod-template-hash=7879778879 Annotations: cni.projectcalico.org/podIP: 10.42.0.128/32 Status: Running IP: 10.42.0.128 Controlled By: ReplicaSet/mysql-7879778879 Containers: mysql: Container ID: docker://ccfe2bc9ec7230c7145ae70445fe8d7331ca4e4768ca39266db1851b2e2b602f Image: mysql:5.7 Image ID: docker-pullable://mysql@sha256:de482b2b0fdbe5bb142462c07c5650a74e0daa31e501bc52448a2be10f384e6d Port: 3306/TCP Host Port: 0/TCP State: Running Started: Tue, 19 Mar 2019 23:07:41 +0800 Ready: True Restart Count: 0 Environment: MYSQL_ROOT_PASSWORD: <set to the key 'password' in secret 'mysql-pass'> Optional: false Mounts: /var/lib/mysql from mysql-persistent-storage (rw) /var/run/secrets/kubernetes.io/serviceaccount from default-token-xd9hn (ro) Conditions: Type Status Initialized True Ready True ContainersReady True PodScheduled True Volumes: mysql-persistent-storage: Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace) ClaimName: mysql-pvc ReadOnly: false default-token-xd9hn: Type: Secret (a volume populated by a Secret) SecretName: default-token-xd9hn Optional: false QoS Class: BestEffort Node-Selectors: Tolerations: node.kubernetes.io/not-ready:NoExecute for 300s node.kubernetes.io/unreachable:NoExecute for 300s Events: Type Reason Age From Message


Normal Scheduled 6m2s default-scheduler Successfully assigned default/mysql-7879778879-b64mn to 192.168.33.11 Normal Pulled 6m1s kubelet, 192.168.33.11 Container image "mysql:5.7" already present on machine Normal Created 6m1s kubelet, 192.168.33.11 Created container Normal Started 6m kubelet, 192.168.33.11 Started container

linqingping avatar Mar 19 '19 15:03 linqingping

Interesting. Would you mind trying with a subpath on the VolumeMount to mimic what the operator is doing?

https://github.com/oracle/mysql-operator/blob/c98210b2c7b176befa00aa0751db184088adfc39/pkg/resources/statefulsets/statefulset.go#L61-L65

prydie avatar Mar 19 '19 17:03 prydie

@prydie thank you!As you said, am I right in doing so? image image image image

linqingping avatar Mar 20 '19 01:03 linqingping

You have to create the directory on your host first, or use a different hostPath.type.

See https://kubernetes.io/docs/concepts/storage/volumes/#hostpath

I'm personally experimenting with the Operator using hostpath-provisioner for dynamic PV provisioning instead of manual, and it's working great so far!

adamelliotfields avatar Mar 21 '19 19:03 adamelliotfields

I got same problem, how to resolve this problem??

ruanshudong avatar Oct 23 '19 13:10 ruanshudong