0

通过本教程,我一直在学习如何在 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

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

4

1 回答 1

0

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

我建议创建一个独特的testKubernetesservicedeployment,并将其指向imagedeployment的新图像。然后您可以向大使注册一个新的前缀。

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

于 2019-06-24T13:11:27.183 回答