AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 1022222
Accepted
Red Cricket
Red Cricket
Asked: 2020-06-20 13:13:22 +0800 CST2020-06-20 13:13:22 +0800 CST 2020-06-20 13:13:22 +0800 CST

我应该为 Kubernetes 入口清单中的主机使用什么值?

  • 772

我有这个用于 Ingress 的 yaml:

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: app
  namespace: ingress-controller
... omitted for brevity ...
spec:
  rules:
    - host: ifs-alpha-kube-001.example.com
      http:
        paths:
          - path: /
            pathType: ImplementationSpecific
            backend:
              serviceName: service-nodeport
              servicePort: 80
          - path: /
            pathType: ImplementationSpecific
            backend:
              serviceName: service-nodeport
              servicePort: 443
status:
  loadBalancer:
    ingress:
      - {}

在上面我设置...

    - host: ifs-alpha-kube-001.example.com

该主机恰好是我的节点之一。我有三个节点。我很确定这是不正确的。入口工作,但如果我关闭 ifs-alpha-kube-001 入口停止工作。host如果我想要一个高可用性集群,我应该设置什么?

谢谢

更新:我尝试了duct_tape_coder 的建议,但我仍然必须做错什么。

我需要能够访问端口 80 和 443 上的 Web 服务器,因此我创建了两个“单一服务”入口。

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: port-80-ingress
  namespace: ingress-controller
spec:
  backend:
    serviceName: port-80-service
    servicePort: 80

... 和 ...

apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: port-443-ingress
  namespace: ingress-controller
spec:
  backend:
    serviceName: port-443-service
    servicePort: 443

我删除了我的旧入口。但是我仍然只能访问我的第一个节点 ifs-alpha-kube-001 上的 Web 服务器,而不是 ifs-alpha-kube-002 和 ifs-alpha-kube-003。我验证了我的 Web 服务器正在 Pod 上运行。

更新二:

好的,我尝试了这个:

kind: Ingress
apiVersion: extensions/v1beta1
metadata:
  name: app2
  namespace: ingress-controller

... omitted ...

spec:
  rules:
    - http:
        paths:
          - path: /
            pathType: ImplementationSpecific
            backend:
              serviceName: service-nodeport
              servicePort: 80
          - path: /
            pathType: ImplementationSpecific
            backend:
              serviceName: service-nodeport
              servicePort: 443
status:
  loadBalancer:
    ingress:
      - {}
$ kubectl describe ingress app2 --namespace=ingress-controller
Name:             app2
Namespace:        ingress-controller
Address:
Default backend:  default-http-backend:80 (<error: endpoints "default-http-backend" not found>)
Rules:
  Host        Path  Backends
  ----        ----  --------
  *
              /   service-nodeport:80 (10.233.119.22:80,10.233.123.33:80,10.233.125.29:80)
              /   service-nodeport:443 (10.233.119.22:443,10.233.123.33:443,10.233.125.29:443)
Annotations:  Events:
  Type        Reason  Age   From                Message
  ----        ------  ----  ----                -------
  Normal      CREATE  13m   ingress-controller  Ingress ingress-controller/app2
  Normal      CREATE  13m   ingress-controller  Ingress ingress-controller/app2
  Normal      UPDATE  12m   ingress-controller  Ingress ingress-controller/app2
  Normal      UPDATE  12m   ingress-controller  Ingress ingress-controller/app2

并删除了所有其他入口。但是我仍然只能以奇怪的方式访问主机 ifs-alpha-kube-001 上的 http ...如果我执行:

curl -L --insecure https://ifs-alpha-kube-001.example.com -vvvv

我得到了大量关于重定向的输出。

> GET / HTTP/2
> Host: ifs-alpha-kube-001
> User-Agent: curl/7.64.1
> Accept: */*
>
< HTTP/2 302
< date: Tue, 23 Jun 2020 15:52:28 GMT
< server: Apache/2.4.39 (Unix) OpenSSL/1.0.2k-fips mod_wsgi/4.7.1 Python/3.6
< location: https://ifs-alpha-kube-001/
< content-length: 211
< content-type: text/html; charset=iso-8859-1
< strict-transport-security: max-age=15768000
<
* Ignoring the response-body
* Connection #1 to host ifs-alpha-kube-001 left intact
* Maximum (50) redirects followed
curl: (47) Maximum (50) redirects followed
* Closing connection 0
* Closing connection 1

这里发生了什么?

更新三

以下是我设置的服务:

$ kubectl get service --namespace=ingress-controller  -o wide
NAME                      TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)                                     AGE     SELECTOR
haproxy-ingress           NodePort    10.233.23.21   <none>        80:30032/TCP,443:30643/TCP,1936:30302/TCP   6d4h    run=haproxy-ingress
ingress-default-backend   ClusterIP   10.233.5.224   <none>        8080/TCP                                    6d5h    run=ingress-default-backend
service-nodeport          NodePort    10.233.3.139   <none>        80:30080/TCP,443:30443/TCP                  5d18h   k8s-app=test-caasa-httpd,pod-template-hash=7d79794567

我相信我已将service-nodeport服务绑定到我的 ingress app2。

kubernetes
  • 1 1 个回答
  • 554 Views

1 个回答

  • Voted
  1. Best Answer
    duct_tape_coder
    2020-06-23T14:29:25+08:002020-06-23T14:29:25+08:00

    不要设置主机,它将在所有主机上可用,https://kubernetes.io/docs/concepts/services-networking/ingress/。您还可以指定一个 hostPort 以使其在所有主机上的特定端口上可用。我建议这样做,然后使用外部负载均衡器/代理来访问所有节点上的入口主机端口。

    • 2

相关问题

  • 无法通过 Docker 在本地运行 Hyperkube (kubernetes)

  • 跨 Kubernetes 分散工作负载

  • Kubernetes升级回滚机器类型

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve