我用谷歌搜索和谷歌搜索,但不確定我做錯了什么。似乎我如何嘗試為 mysql 設定 root 密碼,它似乎不起作用。我目前正在測驗下面的內容(我在互聯網上看到過),但這也不起作用。我沒有收到任何錯誤,日志沒有顯示任何錯誤,老實說,在這一點上,我有點迷茫,希望得到一些幫助。
secrets.yaml 檔案:
apiVersion: v1
kind: Secret
metadata:
name: mysqlpass
namespace: gitea
type: Opaque
data:
password: "cGFzc3dvcmQxMjM="
并且我的部署檔案具有以下設定:
spec:
containers:
- image: mysql/mysql-server:latest
imagePullPolicy: IfNotPresent
name: gitea-mysql
env:
# Use secret in real usage
- name: MYSQL_ROOT_PASSWORD
valueFrom:
secretKeyRef:
name: mysqlpass
key: password
我當前的 pod 日志:
[Entrypoint] MySQL Docker Image 8.0.26-1.2.4-server
[Entrypoint] Starting MySQL 8.0.26-1.2.4-server
2021-10-15T18:28:06.975937Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.26) starting as process 1
2021-10-15T18:28:07.005554Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2021-10-15T18:28:08.608453Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2021-10-15T18:28:09.158261Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1 is enabled for channel mysql_main
2021-10-15T18:28:09.158974Z 0 [Warning] [MY-013746] [Server] A deprecated TLS version TLSv1.1 is enabled for channel mysql_main
2021-10-15T18:28:09.163684Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
2021-10-15T18:28:09.164583Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel.
2021-10-15T18:28:09.245312Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock
2021-10-15T18:28:09.245708Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.26' socket: '/var/lib/mysql/mysql.sock' port: 3306 MySQL Community Server - GPL.
最后是對 pod 的描述,然后是對秘密的描述:
kubectl describe pods gitea-mysql-54d544489b-6dp52 -n gitea
Name: gitea-mysql-54d544489b-6dp52
Namespace: gitea
Priority: 0
Node: node02.iad/10.15.15.202
Start Time: Fri, 15 Oct 2021 18:28:04 0000
Labels: app=gitea-mysql
pod-template-hash=54d544489b
Annotations: kubectl.kubernetes.io/restartedAt: 2021-10-15T18:27:54Z
Status: Running
IP: 10.42.1.57
IPs:
IP: 10.42.1.57
Controlled By: ReplicaSet/gitea-mysql-54d544489b
Containers:
gitea-mysql:
Container ID: containerd://01419c4eb94b0fc787ee8160f42ec16a7d8299daef07a1d591230b731a5c8cac
Image: mysql/mysql-server:latest
Image ID: docker.io/mysql/mysql-server@sha256:5241f7de0483a70f5856da995fea98904cfce8f1c51734b7f3836c1663eead17
Port: 3306/TCP
Host Port: 0/TCP
State: Running
Started: Fri, 15 Oct 2021 18:28:06 0000
Ready: True
Restart Count: 0
Environment:
MYSQL_ROOT_PASSWORD: <set to the key 'password' in secret 'mysqlpass'> Optional: false
Mounts:
/var/lib/mysql from mysql-persistent-storage (rw)
/var/run/secrets/kubernetes.io/serviceaccount from kube-api-access-r7k5x (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
kube-api-access-r7k5x:
Type: Projected (a volume that contains injected data from multiple sources)
TokenExpirationSeconds: 3607
ConfigMapName: kube-root-ca.crt
ConfigMapOptional: <nil>
DownwardAPI: true
QoS Class: BestEffort
Node-Selectors: <none>
Tolerations: node.kubernetes.io/not-ready:NoExecute op=Exists for 300s
node.kubernetes.io/unreachable:NoExecute op=Exists for 300s
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Scheduled 7m36s default-scheduler Successfully assigned gitea/gitea-mysql-54d544489b-6dp52 to node02.iad
Normal Pulled 7m36s kubelet Container image "mysql/mysql-server:latest" already present on machine
Normal Created 7m36s kubelet Created container gitea-mysql
Normal Started 7m35s kubelet Started container gitea-mysql
秘密描述:
kubectl describe secrets mysqlpass -n gitea
Name: mysqlpass
Namespace: gitea
Labels: <none>
Annotations: <none>
Type: Opaque
Data
====
password: 11 bytes
我真的很感激任何和所有的幫助。謝謝!
uj5u.com熱心網友回復:
我記得 Docker 也有類似的問題。我結束洗掉(在此小心)在創建前一個 mysql docker 容器期間創建的任何檔案夾。其中一個檔案夾具有 root 用戶的密碼,除非將其洗掉或更改,否則它將繼續使用用于替換舊的任何其他 mysql 容器。
uj5u.com熱心網友回復:
修復!原來這是我設定持久卷的方式的問題。我的集群設定方式是所有 pod 在 nfs 驅動器上都有一個 pv。我忘記指定 nfs 驅動器要安裝在哪個服務器上。進行修復后,我看到檔案填充了 pv,并且設定的密碼可以作業。
在我的辯護中,我責怪我沒有將空 pv 目錄的點與我的睡眠剝奪聯系起來。
對于遇到此類似問題的其他任何人,請檢查以確保其他所有設定都正確。即使您的 PV 可能不會出錯,它仍然可能設定不正確。
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/323709.html
