向kubernetes部署大使

时间:2019-06-21 11:31:14

标签: kubernetes kubectl ambassador

我一直在通过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

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

1 个答案:

答案 0 :(得分:0)

您在上面所做的是替换 tour Kubernetes servicedeployment并使用自己的替代方法。这有点不寻常。我怀疑某个地方可能有错字,这意味着Kubernetes不会接受您的更改。

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

您还可以查看大使诊断程序(请参阅https://www.getambassador.io/reference/diagnostics/),该诊断程序将告诉您哪些路线已向大使注册。