Problem : I want to implement stickiness on request header called "ORDER_ID". So that if specific order request should be served by specific pod in Kubernetes. But in my case it is not working as requests are not getting stick to specific pod instead getting distributed to different pods as well.
This is how i have installed Ambassador :
- helm repo add datawire https://www.getambassador.io
- kubectl create namespace ambassador
- helm install ambassador --namespace ambassador datawire/ambassador
Below are yaml files :
Deployment.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 service.yml
apiVersion: v1
kind: Service
metadata:
name: order-service
spec:
ports:
- protocol: TCP
port: 3000
targetPort: 3000
selector:
app: order-service
3 mapping.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
Testing by -
curl --insecure --location --request GET 'http://.../backend/orders' --header 'Content-Type: application/json' --header 'ORDER_ID: 1234'
Is there something which i am missing or doing something wrong?
To setup stickiness, It needs ingress controller to route request to order-service through Ambassador Load Balancer. Also EndpointResolver is needed for Endpoint level Service Discovery which is being used in mapping for overriding the Ambassador's configuration.
The missing parts are -