Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

310
Visualizações
How to set sticky session for multiple services in kubernetes?

I have 2 services:

  1. Restful/websocket API service with Nginx (2 replicas)

  2. Daemon service (1 replica)

The daemon service will emit a websocket event to the frontend at some point. However, the event doesn't seem to be emitted successfully to the frontend from the daemon service.

I also tried to emit events from the API server to the frontend, and the event was successfully emitted to the front end. (maybe because the frontend is connected to the API WebSocket server).

What I have done for sticky-session:

---
apiVersion: "v1"
kind: "Service"
metadata:
  name: "daemon"
  namespace: app
spec:
  ports:
  - protocol: "TCP"
    port: 80
    targetPort: 80
  selector:
    app: "daemon"
  type: "NodePort"
  sessionAffinity: ClientIP  
---
---
apiVersion: "v1"
kind: "Service"
metadata:
  name: "api"
  namespace: app
spec:
  ports:
  - protocol: "TCP"
    port: 80
    targetPort: 80
  selector:
    app: "api"
  type: "NodePort"
  sessionAffinity: ClientIP
---
apiVersion: getambassador.io/v2
kind: Mapping
metadata:
  annotations:
    getambassador.io/resource-downloaded: '2020-03-30T16:10:34.466Z'
  name: api
  namespace: app
spec:
  prefix: /api
  service: api:80
load_balancer:
  policy: ring_hash
  cookie:
    name: sticky-cookie
    ttl: 60s
---
apiVersion: getambassador.io/v2
kind: Mapping
metadata:
  annotations:
    getambassador.io/resource-downloaded: '2020-03-30T16:10:34.466Z'
  name: api-ws
  namespace: app
spec:
  prefix: /private
  service: api:80
  use_websocket: true
load_balancer:
  policy: ring_hash
  cookie:
    name: sticky-cookie
    ttl: 60s
---
apiVersion: getambassador.io/v2
kind: Mapping
metadata:
  annotations:
    getambassador.io/resource-downloaded: '2020-03-30T16:10:34.466Z'
  name: api-daemon
  namespace: app
spec:
  prefix: /daemon
  service: daemon:80
  use_websocket: true
load_balancer:
  policy: ring_hash
  cookie:
    name: sticky-cookie
    ttl: 60s

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

From kubernetes.io DaemonSet docs:

Service: Create a service with the same Pod selector, and use the service to reach a daemon on a random node. (No way to reach specific node.)

So I think sessionAffinity cannot work with DaemonSet.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda