我在Kubernetes上使用minikube,在我的应用程序上使用Docker和VirtualBox。
我已经为MySQL数据库和phpmyadmin创建了几个服务+部署。它们都是绿色的,表示没有问题:
但是,当我点击phpmyadmin-service的外部端点时,我的浏览器拒绝连接:
以下是我的metallb配置和minikube ip
输出,以防万一:
我的服务和部署的yaml清单文件确实包含正确的端口:
apiVersion: v1
kind: Service
metadata:
name: phpmyadmin-service
labels:
app: phpmyadmin
annotations:
metallb.universe.tf/allow-shared-ip: shared
spec:
type: LoadBalancer
ports:
- port: 5000
targetPort: 5000
selector:
app: phpmyadmin
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: phpmyadmin-deployment
labels:
app: phpmyadmin
spec:
selector:
matchLabels:
app: phpmyadmin
replicas: 1
template:
metadata:
labels:
app: phpmyadmin
spec:
restartPolicy: Always
containers:
- name: phpmyadmin
image: phpmyadmin
imagePullPolicy: Never
ports:
- containerPort: 5000
知道怎么回事吗?
UPD:kubectl get svc
的输出:
c1r10s2% kubectl get svc
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
kubernetes ClusterIP 10.96.0.1 <none> 443/TCP 2m54s
mysql-service ClusterIP 10.109.243.20 <none> 3306/TCP 73s
phpmyadmin-service LoadBalancer 10.103.233.51 192.168.99.100 5000:30348/TCP 73s
kubect describe svc
的输出:
c1r10s2% kubectl describe svc
Name: kubernetes
Namespace: default
Labels: component=apiserver
provider=kubernetes
Annotations: <none>
Selector: <none>
Type: ClusterIP
IP Families: <none>
IP: 10.96.0.1
IPs: 10.96.0.1
Port: https 443/TCP
TargetPort: 8443/TCP
Endpoints: 192.168.99.100:8443
Session Affinity: None
Events: <none>
Name: mysql-service
Namespace: default
Labels: app=mysql
Annotations: <none>
Selector: app=mysql
Type: ClusterIP
IP Families: <none>
IP: 10.109.243.20
IPs: 10.109.243.20
Port: <unset> 3306/TCP
TargetPort: 3306/TCP
Endpoints: 172.17.0.8:3306
Session Affinity: None
Events: <none>
Name: phpmyadmin-service
Namespace: default
Labels: app=phpmyadmin
Annotations: metallb.universe.tf/allow-shared-ip: shared
Selector: app=phpmyadmin
Type: LoadBalancer
IP Families: <none>
IP: 10.103.233.51
IPs: 10.103.233.51
LoadBalancer Ingress: 192.168.99.100
Port: <unset> 5000/TCP
TargetPort: 5000/TCP
NodePort: <unset> 30348/TCP
Endpoints: 172.17.0.2:5000
Session Affinity: None
External Traffic Policy: Cluster
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal IPAllocated 2m1s metallb-controller Assigned IP "192.168.99.100"
Normal nodeAssigned 119s metallb-speaker announcing from node "minikube"
1条答案
按热度按时间jdzmm42g1#
我看到您正在使用MetalLB。问题是,可能没有一个规则来管理到负载平衡器端点的连接。您可以检查以下事项:
您需要在mysql部署的secrets文件中预先启用secrets,并在其中提供加密的凭据。