首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AppMesh在EKS上的简单前端应用

AppMesh在EKS上的简单前端应用
EN

Stack Overflow用户
提问于 2021-04-09 09:26:03
回答 1查看 460关注 0票数 0

请您帮忙找出我的配置问题。这是在AWS WorkShop示例的范围内完成的,只需在另一个HTTP容器上重写即可。现在,在实施之后,一切都结束了,但是当北草坪会议大楼继续下去的时候,“没有健康的上游”。

已经检查了日志,只看到了503个错误在我的网关侵入。我根本没有收到任何请求。我在哪里做错了配置?

代码语言:javascript
复制
apiVersion: appmesh.k8s.aws/v1beta2
kind: VirtualGateway
metadata:
  name: ingress-gw
  namespace: shared
spec:
  namespaceSelector:
    matchLabels:
      gateway: shared-gw
  podSelector:
    matchLabels:
      app: ingress-gw
  listeners:
    - portMapping:
        port: 8088
        protocol: http
  logging:
    accessLog:
      file:
        path: /dev/stdout
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: httpd-echo-deployment
  namespace: shared
  labels:
    app: httpd-echo1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: httpd-echo1
  template:
    metadata:
      labels:
        app: httpd-echo1
      annotations:
        appmesh.k8s.aws/mesh: shared-mesh
    spec:
      containers:
      - name: httpd
        image: hashicorp/http-echo
        args:
          - "-text=test"
        ports:
        - containerPort: 5678
---
apiVersion: v1
kind: Service
metadata:
  namespace: shared
  name: httpd-echo-service
  labels:
    app: httpd-echo1
spec:
  ports:
    - name: "http"
      port: 5678
      targetPort: 5678
  selector:
    app: httpd-echo1
---
apiVersion: appmesh.k8s.aws/v1beta2
kind: VirtualNode
metadata:
  name: shared-virtual-node-1
  namespace: shared
spec:
  podSelector:
    matchLabels:
      app: httpd-echo1
  listeners:
    - portMapping:
        port: 5678
        protocol: http
      healthCheck:
        protocol: http
        path: '/'
        healthyThreshold: 5
        unhealthyThreshold: 5
        timeoutMillis: 2000
        intervalMillis: 5000
  serviceDiscovery:
    dns:
      hostname: httpd-echo1.test.com
  logging:
    accessLog:
      file:
        path: /dev/stdout
---
apiVersion: appmesh.k8s.aws/v1beta2
kind: VirtualService
metadata:
  name: shared-virtual-service-1
  namespace: shared
spec:
  awsName: httpd-echo1.test.com
  provider:
    virtualNode:
      virtualNodeRef:
        name: shared-virtual-node-1
---
apiVersion: appmesh.k8s.aws/v1beta2
kind: GatewayRoute
metadata:
  name: shared-gw-route-1
  namespace: shared
spec:
  httpRoute:
    match:
      prefix: "/"
    action:
      target:
        virtualService:
          virtualServiceRef:
            name: shared-virtual-service-1
---
apiVersion: v1
kind: Service
metadata:
  name: ingress-gw
  namespace: shared
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
    service.beta.kubernetes.io/aws-load-balancer-subnets : subnet-1,subnet-2,subnet-3
    service.beta.kubernetes.io/aws-load-balancer-internal: "false"
spec:
  type: LoadBalancer
  ports:
    - port: 80
      targetPort: 8088
      name: http
  selector:
    app: ingress-gw
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ingress-gw
  namespace: shared
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ingress-gw
  template:
    metadata:
      labels:
        app: ingress-gw
    spec:
      containers:
        - name: envoy
          image: 422531588944.dkr.ecr.eu-south-1.amazonaws.com/aws-appmesh-envoy:v1.16.1.1-prod
          ports:
            - containerPort: 8088

我尝试使用的示例:https://github.com/aws-containers/eks-app-mesh-polyglot-demo/tree/cf15e0d8e10c019d332f5378d132a8d620131df8/deployment

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-04-09 18:22:59

我试着在我身边复制同样的东西,而且效果很好。我对上面的yaml做了一些配置更改。

  1. 将网关标签“网关:共享-gw”添加到VirtualGateway中。请确保在名称空间中将此标签作为well.
  2. Corrected主机名。这应该是您的应用程序clusterIp服务名称serviceDiscovery: dns: hostname: clusterIp

此外,确保您的Laodbalancer处于活动状态,并且此LB的目标组侦听器显示了健康状态。

我在下面添加更新的yaml。你可以试试这个,看看它是否有效。

代码语言:javascript
复制
---
apiVersion: v1
kind: Namespace
metadata:
  name: shared
  labels:
    mesh: shared-mesh
    gateway: ingress-gw
    appmesh.k8s.aws/sidecarInjectorWebhook: enabled
---
apiVersion: appmesh.k8s.aws/v1beta2
kind: Mesh
metadata:
  name: shared-mesh
spec:
  namespaceSelector:
    matchLabels:
      mesh: shared-mesh
---

apiVersion: apps/v1
kind: Deployment
metadata:
  name: httpd-echo1
  namespace: shared
  labels:
    app: httpd-echo1
spec:
  replicas: 1
  selector:
    matchLabels:
      app: httpd-echo1
  template:
    metadata:
      labels:
        app: httpd-echo1
      annotations:
        appmesh.k8s.aws/mesh: shared-mesh
    spec:
      containers:
      - name: httpd
        image: hashicorp/http-echo
        args:
          - "-text=test"
        ports:
        - containerPort: 5678
---
apiVersion: v1
kind: Service
metadata:
  namespace: shared
  name: httpd-echo1
  labels:
    app: httpd-echo1
spec:
  ports:
    - name: "http"
      port: 5678
      targetPort: 5678
  selector:
    app: httpd-echo1
---
apiVersion: appmesh.k8s.aws/v1beta2
kind: VirtualNode
metadata:
  name: shared-virtual-node-1
  namespace: shared
spec:
  podSelector:
    matchLabels:
      app: httpd-echo1
  listeners:
    - portMapping:
        port: 5678
        protocol: http
      healthCheck:
        protocol: http
        path: '/'
        healthyThreshold: 5
        unhealthyThreshold: 5
        timeoutMillis: 2000
        intervalMillis: 5000
  serviceDiscovery:
    dns:
      hostname: httpd-echo1.shared.svc.cluster.local
  logging:
    accessLog:
      file:
        path: /dev/stdout
---
apiVersion: appmesh.k8s.aws/v1beta2
kind: VirtualService
metadata:
  name: shared-virtual-service-1
  namespace: shared
spec:
  awsName: httpd-echo1.shared.svc.cluster.local
  provider:
    virtualNode:
      virtualNodeRef:
        name: shared-virtual-node-1
---

apiVersion: appmesh.k8s.aws/v1beta2
kind: VirtualGateway
metadata:
  name: ingress-gw
  namespace: shared
spec:
  namespaceSelector:
    matchLabels:
      gateway: ingress-gw
  podSelector:
    matchLabels:
      app: ingress-gw
  listeners:
    - portMapping:
        port: 8088
        protocol: http
  logging:
    accessLog:
      file:
        path: /dev/stdout
---
apiVersion: v1
kind: Service
metadata:
  name: ingress-gw
  namespace: shared
  annotations:
    service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
spec:
  type: LoadBalancer
  ports:
    - port: 80
      targetPort: 8088
      name: http
  selector:
    app: ingress-gw
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: ingress-gw
  namespace: shared
spec:
  replicas: 1
  selector:
    matchLabels:
      app: ingress-gw
  template:
    metadata:
      labels:
        app: ingress-gw
    spec:
      containers:
        - name: envoy
          image: 422531588944.dkr.ecr.eu-south-1.amazonaws.com/aws-appmesh-envoy:v1.16.1.1-prod
          ports:
            - containerPort: 8088
---
apiVersion: appmesh.k8s.aws/v1beta2
kind: GatewayRoute
metadata:
  name: shared-gw-route-1
  namespace: shared
spec:
  httpRoute:
    match:
      prefix: "/"
    action:
      target:
        virtualService:
          virtualServiceRef:
            name: shared-virtual-service-1
---
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67018506

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档