我正在尝试部署比特纳米/mysql https://github.com/bitnami/charts/tree/master/bitnami/mysql我里面的图表minikube https://minikube.sigs.k8s.io/docs/。
我正在使用 Kubernetes v1.19、Minikube v1.17.1 和Helm 3 https://helm.sh/
我创建了 PVC 和 PV,如下所示:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mysql-pvc
spec:
storageClassName: standard
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 3Gi
selector:
matchLabels:
id: mysql-pv
----
kind: PersistentVolume
apiVersion: v1
metadata:
name: mysql-pv
labels:
type: local
id: mysql-pv
spec:
storageClassName: standard
capacity:
storage: 8Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /var/lib/mysql
我已经创建了目录/var/lib/mysql
通过做sudo mkdir -p /var/lib/mysql
这就是我创建 PVC 和 PC 的方式:
kubectl apply -f mysql-pv-dev.yaml
kubectl apply -f mysql-pvc-dev.yaml
这似乎有效:
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
mysql-pvc Bound mysql-pv 8Gi RWO standard 59s
我正在部署我的mysql
with:
helm upgrade --install dev-mysql -f mysql-dev.yaml bitnami/mysql
自定义值文件 -mysql-dev.yaml
:
auth:
database: dev_db
username: dev_user
password: passworddev
rootPassword: rootpass
image:
debug: true
primary:
persistence:
existingClaim: mysql-pvc
extraVolumeMounts: |
- name: init
mountPath: /docker-entrypoint-initdb.d
extraVolumes: |
- name: init
hostPath:
path: /home/dev/init_db_scripts/
type: Directory
volumePermissions:
enabled: true
部署工作如下:
NAME READY STATUS RESTARTS AGE
dev-mysql-0 0/1 Running 0 8s
问题是 pod 永远不会准备好,因为:
Warning Unhealthy 0s (x2 over 10s) kubelet Readiness probe failed: mysqladmin: [Warning] Using a password on the command line interface can be insecure.
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user 'root'@'localhost' (using password: YES)'
mysqld
正在 pod 内运行,但由于某些原因,root 密码未正确设置,因为当我执行 pod 并尝试连接到mysql
I get:
$ kubectl exec -ti dev-mysql bash
I have no name!@dev-mysql-0:/$ mysql -u root -prootpass
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
I have no name!@dev-mysql-0:/$
相反,它使用默认值 https://github.com/bitnami/charts/blob/master/bitnami/mysql/values.yaml所以如果我尝试:mysql -u root -p
没有密码,效果很好。
Thanks