gpt4 book ai didi

amazon-web-services - istio 为特定服务创建外部 ip

转载 作者:行者123 更新时间:2023-12-02 11:38:43 25 4
gpt4 key购买 nike

我已使用 istio 成功将应用程序部署到 K8s
我们有我们使用的 gw 和虚拟服务,如下所示:

apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: bher-virtualservice
namespace: ba-trail
spec:
gateways:
- bher-gateway
hosts:
- trialio.cloud.str
http:
- match:
- uri:
prefix: "/"
- uri:
prefix: "/login"
- uri:
prefix: "/static"
- uri:
regex: '^.*\.(ico|png|jpg)$'
route:
- destination:
host: bsa.ba-trail.svc.cluster.local service.namespace.svc.cluster.local
port:
number: 5000
我还定义了一个 servicedeployment .
我想在我可以访问的外部公开服务
喜欢:
https://myapp.host:5000
当我运行时:
kubectl get svc istio-ingressgateway -n istio-system


NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
istio-ingressgateway LoadBalancer 100.61.114.202 a7151b2063cb-200880.eu-central-1.elb.amazonaws.com 150210:31161/TCP,80:31280/TCP,443:31190/TCP 41d
怎么做?
我能够通过端口转发运行该应用程序,但我想要一个直接的外部链接。

最佳答案

因此,在您的情况下,您有一个 ELB 为您的 istio 入口网关提供服务,该网关转到 VirtualService,该服务将流量引导至端口 5000。在容器中。
我假设你有它与🤔💭一起工作:

  • a7151b2063cb-200880.eu-central-1.elb.amazonaws.com:80
  • a7151b2063cb-200880.eu-central-1.elb.amazonaws.com:443

  • 你想要这样的东西:
  • a7151b2063cb-200880.eu-central-1.elb.amazonaws.com:5000

  • 但具有映射到的特定名称
  • myapp.host

  • 首先,您必须创建一个映射 myapp.host 的 DNS CNAME 记录。至 a7151b2063cb-200880.eu-central-1.elb.amazonaws.com .
    然后在 Kubernetes 服务 istio-ingressgateway你可能有这样的事情:
    apiVersion: v1
    kind: Service
    metadata:
    name: istio-ingressgateway
    namespace: istio-system
    labels:
    name: istio-ingress-service
    annotations:
    ... (❓)
    spec:
    type: LoadBalancer
    ports:
    - port: 80
    targetPort: ❓
    protocol: TCP
    - port: 443
    targetPort: ❓
    protocol: TCP
    selector:
    name: something-that-matches-your-istio-ingress
    您可以将额外的端口添加到服务中,以便它在外部监听该端口。
    apiVersion: v1
    kind: Service
    metadata:
    name: istio-ingressgateway
    namespace: istio-system
    labels:
    name: istio-ingress-service
    annotations:
    ... (❓)
    spec:
    type: LoadBalancer
    ports:
    - port: 80
    targetPort: ❓
    protocol: TCP
    - port: 443
    targetPort: ❓
    protocol: TCP
    - port: 5000
    targetPort: ❓
    selector:
    name: something-that-matches-your-istio-ingress
    最后,虚拟服务需要匹配您的主机名 myapp.host
    apiVersion: networking.istio.io/v1alpha3
    kind: VirtualService
    metadata:
    name: bher-virtualservice
    namespace: ba-trail
    spec:
    gateways:
    - bher-gateway
    hosts:
    - myapp.host
    ...
    ✌️

    关于amazon-web-services - istio 为特定服务创建外部 ip,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63021871/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com