Warm tip: This article is reproduced from serverfault.com, please click

kubernetes-如何使用负载均衡器(或直接)从外部访问Pod?

(kubernetes - How to make a pod accessible from outide with a Load Balancer (or directly)?)

发布于 2020-11-27 02:04:15

这是我要使用Kubernetes配置文件执行的操作:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: selenium-hub
  labels:
    app: selenium-hub
spec:
  replicas: 1
  strategy:
    type: Recreate
  selector:
    matchLabels:
      app: selenium-hub
  template:
    metadata:
      labels:
        app: selenium-hub
    spec:
      containers:
      - name: selenium-hub
        image: selenium/hub
        ports:
          - containerPort: 4444
        resources:
          limits:
            memory: "1000Mi"
            cpu: ".5"
        livenessProbe:
          httpGet:
            path: /wd/hub/status
            port: 4444
          initialDelaySeconds: 30
          timeoutSeconds: 5
        readinessProbe:
          httpGet:
            path: /wd/hub/status
            port: 4444
          initialDelaySeconds: 30
          timeoutSeconds: 5
---
apiVersion: v1
kind: Service
metadata:
  name: nginx
  labels:
    app: nginx
spec:
  externalTrafficPolicy: Local
  ports:
  - name: http
    port: 4444
    protocol: TCP
    targetPort: 4444
  selector:
    app: selenium-hub
  type: LoadBalancer

在GKE中,它将创建一个具有Pod的应用程序,然后创建一个具有外部IP的负载均衡器。但是,当我尝试从外部访问该应用程序时http://LBIP:port不起作用。

那么,如何展示我最初创建的Pod?如果仅使用一个副本,是否需要LB?

Questioner
jscoys
Viewed
0
jscoys 2020-11-30 03:23:57

哼哼……哼哼……你会笑的!在我这边,我没有笑...

这是一个网络问题。不知道为什么,但是由于一个晦涩的原因,我的房屋IP地址似乎被禁止访问GCP上的任何实例。控制台没有问题,但是当尝试通过我的浏览器浏览http时,它根本无法连接。

使用nordvpn正常工作!到目前为止,一切都很好。

无论如何,为你提供帮助!