【问题标题】:Deploying ambassador to kubernetes将大使部署到 Kubernetes
【发布时间】:2019-11-04 06:07:38
【问题描述】:

我一直在通过this 教程学习如何在 minikube 上的 kubernetes 上部署大使,并且我可以看到成功安装大使的页面。主要问题是,当我尝试更改 UI 的图像以使其应该在链接中打开其他应用程序时,它会打开相同的大使成功页面。

以前的tour.yaml

---
apiVersion: v1
kind: Service
metadata:
  name: tour
  annotations:
    getambassador.io/config: |
      ---
      apiVersion: ambassador/v1
      kind: Mapping
      name: tour-ui_mapping
      prefix: /
      service: tour:5000
      ---
      apiVersion: ambassador/v1
      kind: Mapping
      name: tour-backend_mapping
      prefix: /backend/
      service: tour:8080
      labels:
        ambassador:
          - request_label:
            - backend
spec:
  ports:
  - name: ui
    port: 5000
    targetPort: 5000
  - name: backend
    port: 8080
    targetPort: 8080
  selector:
    app: tour
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tour
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tour
  strategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: tour
    spec:
      containers:
      - name: tour-ui
        image: quay.io/datawire/tour:ui-0.2.1
        ports:
        - name: http
          containerPort: 5000
      - name: quote
        image: quay.io/datawire/tour:backend-0.2.1
        ports:
        - name: http
          containerPort: 8080
        resources:
          limits:
            cpu: "0.1"
            memory: 100Mi

修改tour.yaml(去掉后台,改了图片)

---
apiVersion: v1
kind: Service
metadata:
  name: tour
  annotations:
    getambassador.io/config: |
      ---
      apiVersion: ambassador/v1
      kind: Mapping
      name: tour-ui_mapping
      prefix: /
      service: tour:5000
spec:
  ports:
  - name: ui
    port: 5000
    targetPort: 5000
  selector:
    app: tour
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tour
spec:
  replicas: 1
  selector:
    matchLabels:
      app: tour
  strategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: tour
    spec:
      containers:
      - name: tour-ui
        image: quay.io/integreatly/tutorial-web-app:2.10.5
        ports:
        - name: http
          containerPort: 5000
        resources:
          limits:
            cpu: "0.1"
            memory: 100Mi

ambassador-service.yaml

---
apiVersion: v1
kind: Service
metadata:
  name: ambassador
spec:
  type: NodePort
  externalTrafficPolicy: Local
  ports:
   - port: 80
     targetPort: 8080
  selector:
    service: ambassador

请帮忙,我真的很困惑它背后的原因以及如何解决它。

【问题讨论】:

  • 欢迎来到 Stack Overflow Alohomora!这种行为真的很奇怪。你真的在同一个命名空间中再次部署了 tour.yaml 吗?您可以尝试将“名称:tour-ui_mapping”更改为其他内容吗?您还可以查看您的 tour pod (kubectl logs {pod's name}) 的日志以检查请求是否到达那里。
  • @VictorVal,我确实将“name:tour-ui_mapping”的名称更改为“sample-ui_mapping”,但这并没有改变打开大使页面的行为。我还部署了 tour.yaml,通过以下方式对其进行了更改:$ kubectl apply -f tour.yaml 但仍然遇到同样的问题。
  • @VictorVal,当我将图像更改为“quay.io/frank_dasilva/node-js-hello-world:72”并且没有更改名称:tour-ui_mapping 之类的内容时,它有效。

标签: kubernetes kubectl ambassador


【解决方案1】:

您在上面所做的是替换 tour Kubernetes servicedeployment 用您自己的替代方案。这是一种不寻常的模式。我怀疑某处可能存在拼写错误,这意味着 Kubernetes 没有接受您的更改。

我建议创建一个独特的 test Kubernetes servicedeployment,并将您的 deployment 中的 image 指向您的新映像。然后您可以向大使注册一个新前缀。

您还可以查看Ambassador 诊断(请参阅https://www.getambassador.io/reference/diagnostics/),它会告诉您哪些路线已向Ambassador 注册。

【讨论】:

    猜你喜欢
    • 2020-09-21
    • 1970-01-01
    • 1970-01-01
    • 2021-03-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-11
    • 1970-01-01
    相关资源
    最近更新 更多