apiVersion: v1
kind: Service
metadata:
  name: agent-monitor
  namespace: agent-monitor
  labels:
    app.kubernetes.io/name: agent-monitor
    app.kubernetes.io/instance: agent-monitor
    app.kubernetes.io/version: "1.0.0"
    app.kubernetes.io/component: server
    app.kubernetes.io/managed-by: kustomize
  annotations:
    # Document which slot is currently active
    # To switch traffic: kubectl patch svc agent-monitor -n agent-monitor \
    #   -p '{"spec":{"selector":{"slot":"green"}}}'
    agent-monitor.io/active-slot: blue
spec:
  type: ClusterIP
  sessionAffinity: ClientIP
  sessionAffinityConfig:
    clientIP:
      timeoutSeconds: 10800
  selector:
    app.kubernetes.io/name: agent-monitor
    app.kubernetes.io/instance: agent-monitor
    # Toggle this value between "blue" and "green" to switch traffic
    slot: blue
  ports:
    - name: http
      port: 80
      targetPort: http
      protocol: TCP
