Kubernetes MySQL连接超时
我已经为MySQL设置了Kubernetes部署和服务。我无法使用其DNS名称从任何pod访问MySQL服务。。。它只是超时了。任何其他端口都会立即拒绝连接,但我的服务配置中的端口会在约10秒后超时Kubernetes MySQL连接超时,kubernetes,Kubernetes,我已经为MySQL设置了Kubernetes部署和服务。我无法使用其DNS名称从任何pod访问MySQL服务。。。它只是超时了。任何其他端口都会立即拒绝连接,但我的服务配置中的端口会在约10秒后超时 我能够解析MySQL Pod DNS 我不能打电话给主持人 Service.yml apiVersion: v1 kind: Service metadata: name: mysql-service labels: run: mysql-service spec: ports:
apiVersion: v1
kind: Service
metadata:
name: mysql-service
labels:
run: mysql-service
spec:
ports:
- port: 3306
protocol: TCP
- port: 3306
protocol: UDP
selector:
run: mysql-service
部署.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mysql-service
labels:
app: mysql-service
spec:
replicas: 1
selector:
matchLabels:
app: mysql-service
template:
metadata:
labels:
app: mysql-service
spec:
containers:
- name: 'mysql-service'
image: mysql:5.5
env:
- name: MYSQL_ROOT_PASSWORD
value: some_password
- name: MYSQL_DATABASE
value: some_database
ports:
- containerPort: 3306
您的部署(更具体地说是其pod规范)说
但是你的服务说
selector:
run: mysql-service
这些不匹配,因此您的服务未连接到pod。如果您kubectl description service mysql service
,“endpoints”列表将为空
更改服务的选择器以匹配pod的标签(反之亦然),这应该会更好。您的部署(更具体地说是其pod规范)说明
但是你的服务说
selector:
run: mysql-service
这些不匹配,因此您的服务未连接到pod。如果您kubectl description service mysql service
,“endpoints”列表将为空
更改服务的选择器以匹配pod的标签(反之亦然),这样会更好。您已保存了我您已保存了我