Stickiness没有为驻Kubernetes大使处理请求标头



问题:我想在名为"ORDER_ID";。这样,如果特定的订单请求应该由Kubernetes中的特定pod提供服务。但在我的情况下,它不起作用,因为请求没有被固定到特定的pod,而是被分发到不同的pod。

这就是我如何安装大使:

  1. helm repo添加数据线https://www.getambassador.io
  2. kubectl创建命名空间大使
  3. helm install大使--namespace大使datawire/a大使

以下是yaml文件:

部署.yml

apiVersion: apps/v1
kind: Deplyment
metadata:
name: order-service
spec:
replicas: 2
selector:
matchLabels:
app: order-service
strategy:
type: RollingUpdate
template:
metadata:
labels:
app: order-service
spec:
containers:
- name: orderservice
image: xyz.io/orderservice
imagePullPolicy: Always
ports:
- containerPort: 3000

2项服务.yml

apiVersion: v1
kind: Service
metadata:
name: order-service
spec:
ports:
- protocol: TCP
port: 3000
targetPort: 3000
selector:
app: order-service

3映射.yml

apiVersion: getambassador.io/v2
kind: Mapping
metadata:
name: ambassador-backend
spec:
prefix: /
service: order-service:3000
resolver: endpoint
load_balancer:
policy: least_request
header: ORDER_ID

测试

curl --insecure --location --request GET 'http://.../backend/orders' --header 'Content-Type: application/json' --header 'ORDER_ID: 1234'

是我遗漏了什么还是做错了什么?

要设置粘性,需要ingress控制器通过Ambassador Load Balancer将请求路由到订单服务。端点级服务发现也需要EndpointResolver,该服务发现在映射中用于覆盖Ambassador的配置。

缺少的部件是-

  1. ingress.yml
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: ambassador
name: order-service-ingress
spec:
rules:
- http:
paths:
- path: /v1/orders/*
backend:
serviceName: order-service
servicePort: 4000
  1. endpoint_resolver.yml
apiVersion: getambassador.io/v2
kind: KubernetesEndpointResolver
metadata:
name: endpoint

相关内容

  • 没有找到相关文章

最新更新