已完成以下步骤:- 1. 我创建了一个持久卷声明并在我的 mysql 部署中使用它 2. 在配置中创建了一个通用密钥并将其设置在 env 中以进行部署
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: my-db-pass
key: password
3.使用以下cmd连接到我的实例mysql --host= --user=root -p 之后发生以下错误-
ERROR 1045 (28000): Access denied for user 'root'@'10.128.0.18' (using password: YES)
mysql 的 kubectl pod 日志是 -
2020-04-05 19:49:47+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started.
2020-04-05 19:49:47+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql'
2020-04-05 19:49:47+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.19-1debian10 started.
2020-04-05T19:49:48.139557Z 0 [Warning] [MY-011070] [Server] 'Disabling symbolic links using --skip-symbolic-links (or equivalent) is the default. Consider not using this option as it' is deprecated and will be removed in a future release.
2020-04-05T19:49:48.139759Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.19) starting as process 1
2020-04-05T19:49:50.599641Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2020-04-05T19:49:50.606508Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory.
2020-04-05T19:49:50.850478Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.19' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL.
2020-04-05T19:49:50.894674Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/run/mysqld/mysqlx.sock' bind-address: '::' port: 33060
2020-04-05T20:01:09.664184Z 17 [Warning] [MY-013360] [Server] Plugin sha256_password reported: ''sha256_password' is deprecated and will be removed in a future release. Please use caching_sha2_password instead'
还提供了用于 mysql-deployment 的 yaml 文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql
labels:
app: mysql
spec:
replicas: 1
selector:
matchLabels:
app: mysql
template:
metadata:
labels:
app: mysql
spec:
containers:
- name: mysql
image: mysql:8
args:
- "--default-authentication-plugin=mysql_native_password"
env:
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: my-db-pass
key: password
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-persistent-storage
persistentVolumeClaim:
claimName: mysql-volumeclaim