似乎无法连接到部署

问题描述 投票:0回答:1

我有以下服务/部署,其中 docker 映像仅使用“hello world”响应端口 80 上的请求

apiVersion: apps/v1
kind: Deployment
metadata:
  name: test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: test
  template:
    metadata:
      labels:
        app: test
    spec:
      containers:
        - name: helloworld
          image: */helloworld:latest
          ports:
          - containerPort: 80
          resources:
            limits:
              cpu: "250m"
              memory: "1Gi"
---
apiVersion: v1
kind: Service
metadata:
  name: test
spec:
  type: LoadBalancer
  selector:
    app: test
  ports:
  - port: 80
    targetPort: 80
    protocol: TCP
  externalIPs:
  - 192.168.0.10
status:
  loadBalancer: {}

我期望能够连接到 192.168.0.10:80,但我得到“响应时间太长”

我可以使用

minikube kubectl get services
来验证服务是否正在运行,这给了我

test         LoadBalancer   10.97.157.242    192.168.0.10   80:31912/TCP     48m

并且服务指向的 pod 已启动。

minikube kubectl get pods
给了我

test-55c8cc69b5-h7xj6       1/1     Running       0             11s

kubernetes networking minikube
1个回答
0
投票

来自文档

LoadBalancer
类型的服务可以通过
minikube tunnel
公开 命令。它必须在单独的终端窗口中运行以保持
LoadBalancer
跑步。

在单独的终端中运行

minikube tunnel
应该可以使您的服务可访问。

© www.soinside.com 2019 - 2024. All rights reserved.