简体   繁体   English

k8s 大使入口样本不起作用

[英]k8s ambassador ingress sample not working

I'm currently on OSX (Catalina) with Docker Desktop (19.03.5) running k8s (v.14.8)我目前在 OSX (Catalina) 上运行 k8s (v.14.8) Docker Desktop (19.03.5)

Following the ambassador getting started article, I've done the following:大使入门文章之后,我做了以下工作:

Created a file called ambassador-ingress.yaml创建了一个名为ambassador-ingress.yaml的文件

---
apiVersion: v1
kind: Service
metadata:
  labels:
    service: ambassador
  name: ambassador
spec:
  type: LoadBalancer
  ports:
  - port: 80
    targetPort: 80
  selector:
    service: ambassador
---
apiVersion: v1
kind: Service
metadata:
  name: google
  annotations:
    getambassador.io/config: |
      ---
      apiVersion: ambassador/v0
      kind:  Mapping
      name:  google_mapping
      prefix: /google/
      service: https://google.com:443
      host_rewrite: www.google.com
spec:
  type: ClusterIP
  clusterIP: None

And I've run the following我已经运行了以下

$ kubectl apply -f https://www.getambassador.io/yaml/ambassador/ambassador-rbac.yaml
$ kubectl apply -f ambassador-ingress.yaml

I can now look at kubectl get pods and kubectl get service我现在可以查看kubectl get podskubectl get service

$ kubectl get pods
NAME                                         READY   STATUS    RESTARTS   AGE
ambassador-74fb8f5668-2b85z                  1/1     Running   0          20m
ambassador-74fb8f5668-r6jrf                  1/1     Running   0          20m
ambassador-74fb8f5668-vrmjg                  1/1     Running   0          20m
$ kubectl get service
NAME                 TYPE           CLUSTER-IP       EXTERNAL-IP   PORT(S)          AGE
ambassador           LoadBalancer   10.97.166.229    localhost     80:31327/TCP     18m
ambassador-admin     NodePort       10.96.1.56       <none>        8877:30080/TCP   18m
google               ClusterIP      None             <none>        <none>           18m
kubernetes           ClusterIP      10.96.0.1        <none>        443/TCP          13d

Everything looks like it is setup correctly, however, whenever I attempt to curl k8s I can't get anything but an empty server response even though I can hit google directly:一切看起来都设置正确,但是,每当我尝试 curl k8s 时,即使我可以直接点击 google,我也只能得到一个空的服务器响应:

$ curl localhost/google/
> curl: (52) Empty reply from server
$ curl www.google.com
> <!doctype html> ............

The question I have is, where do I begin troubleshooting?我的问题是,我从哪里开始故障排除? I don't know where the failure lies or how to begin digging to find what has gone wrong.我不知道失败在哪里,也不知道如何开始挖掘以找出问题所在。 What is the right direction?什么是正确的方向?

Based on "The Kubernetes network model" [1] there are 2 important rules:基于“Kubernetes 网络模型”[1] 有 2 条重要规则:

  • pods on a node can communicate with all pods on all nodes without NAT节点上的 pod 可以与所有节点上的所有 pod 通信,无需 NAT
  • agents on a node (eg system daemons, kubelet) can communicate with all pods on that node节点上的代理(例如系统守护进程、kubelet)可以与该节点上的所有 pod 通信

So basically it says that since your K8s cluster is located on your machine, you can directly communicate to the service ip "10.97.166.229" and POD IP.所以基本上它说,由于您的K8s集群位于您的机器上,您可以直接与服务ip“10.97.166.229”和POD IP通信。

So, regarding how to begin your troubleshooting steps, since your PODs are up and running, most likely this is a network error.因此,关于如何开始您的故障排除步骤,由于您的 POD 已启动并正在运行,这很可能是网络错误。 You can try this:你可以试试这个:

a) Try to connect to your pod directly. a) 尝试直接连接到您的 Pod。 You can get your IP by executing the command:您可以通过执行以下命令来获取您的 IP:

kubectl get pod -o wide

b) Get the LOGs of your POD and search for any error: b) 获取您的 POD 的日志并搜索任何错误:

kubectl logs ambassador-74fb8f5668-2b85z

c) Go inside your POD and check if you can test connectivity inside your POD. c) 进入您的 POD 并检查您是否可以测试 POD 内的连通性。 [2] [2]

kubectl exec -it ambassador-74fb8f5668-2b85z -- /bin/bash

[1] https://kubernetes.io/docs/concepts/cluster-administration/networking/ [1] https://kubernetes.io/docs/concepts/cluster-administration/networking/

[2] https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/ [2] https://kubernetes.io/docs/tasks/debug-application-cluster/get-shell-running-container/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM