rpc错误:代码=未知desc =永久移动:HTTP状态代码301

时间:2019-05-27 12:04:42

标签: grpc cloudflare nginx-ingress aws-eks grpc-go

我已经编写了GRPC服务,我需要在AWS-EKS上部署该服务,我们正在使用nginx-ingress和cloudflare指向我们的集群网关(nginx)。

但是当我尝试使用以下命令grpcurl grpc.fd-admin.com:443 list来部署服务并对其进行测试时 我总是收到以下错误:

Failed to list services: rpc error: code = Unknown desc = Moved Permanently: HTTP status code 301; transport: missing content-type field

这就是我对kubernetes资源所做的:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: grpc
  labels:
    k8s-app: grpc
spec:
  replicas: 1
  template:
    metadata:
      labels:
        k8s-app: grpc
    spec:
      containers:
      - name: grpc
        image: quay.io/kubernetes-ingress-controller/grpc-fortune-teller:0.1
        ports:
        - containerPort: 50051
          name: grpc
---
apiVersion: v1
kind: Service
metadata:
  name: grpc
  namespace: grpc
spec:
  selector:
    k8s-app: grpc
  ports:
  - port: 50051
    targetPort: 50051
    protocol: TCP
    name: grpc
  type: ClusterIP
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
    nginx.ingress.kubernetes.io/ssl-redirect: "true"
  name: grpc
  namespace: grpc
spec:
  rules:
  - host: grpc.fd-admin.com
    http:
      paths:
      - backend:
          serviceName: grpc
          servicePort: grpc
  tls:
  - secretName: grpc
    hosts:
      - grpc.fd-admin.com

那么任何人都可以解释为什么我得到这个错误,或者是什么原因可能导致这种错误?

1 个答案:

答案 0 :(得分:0)

尝试下面的nginx入口注释,

kind: Ingress
metadata:
  annotations:
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/backend-protocol: "GRPC"
    nginx.ingress.kubernetes.io/grpc-backend-for-port: "grpc"
  name: grpc