|
|
|
@ -0,0 +1,54 @@
|
|
|
|
|
+++
|
|
|
|
|
title = "Traefik Ingress发布gRPC服务"
|
|
|
|
|
date = 2022-09-01
|
|
|
|
|
[taxonomies]
|
|
|
|
|
tags=["kubernetes","coding"]
|
|
|
|
|
+++
|
|
|
|
|
jina框架使用gPRC协议通讯,部署到k8s中对外暴露服务需要配置ingress注解。
|
|
|
|
|
|
|
|
|
|
k3s中默认使用Traefik Ingress,参考yaml配置如下:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
```YAML
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
# Service
|
|
|
|
|
apiVersion: v1
|
|
|
|
|
kind: Service
|
|
|
|
|
metadata:
|
|
|
|
|
name: grpc-demo
|
|
|
|
|
annotations:
|
|
|
|
|
traefik.ingress.kubernetes.io/service.serversscheme: h2c
|
|
|
|
|
spec:
|
|
|
|
|
ports:
|
|
|
|
|
- port: 8080
|
|
|
|
|
selector:
|
|
|
|
|
app.kubernetes.io/name: grpc-demo
|
|
|
|
|
app.kubernetes.io/instance: grpc-demo
|
|
|
|
|
type: ClusterIP
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
# Ingress
|
|
|
|
|
apiVersion: networking.k8s.io/v1
|
|
|
|
|
kind: Ingress
|
|
|
|
|
metadata:
|
|
|
|
|
annotations:
|
|
|
|
|
ingress.kubernetes.io/protocol: http
|
|
|
|
|
labels:
|
|
|
|
|
app: grpc-demo
|
|
|
|
|
name: grpc-demo
|
|
|
|
|
namespace: grpc-namespace
|
|
|
|
|
spec:
|
|
|
|
|
rules:
|
|
|
|
|
- host: grpc.example.org
|
|
|
|
|
http:
|
|
|
|
|
paths:
|
|
|
|
|
- backend:
|
|
|
|
|
service:
|
|
|
|
|
name: grpc-demo
|
|
|
|
|
port:
|
|
|
|
|
number: 8080
|
|
|
|
|
path: /
|
|
|
|
|
pathType: Prefix
|
|
|
|
|
```
|