[CAO] How can we set annotations on headless service

Hi!

We are using Couchbase Autonomous Operator 2.2.301.
We use Traefik as our ingress controller.
According to Access the Couchbase Server User Interface | Couchbase Docs we need to set session affinity through the headless service.
If not set, the UI remain stuck looping just after the login.
We tried to add annotation traefik.ingress.kubernetes.io/service.sticky.cookie: “true” on the headless service as Traefik do not set persistence on ingress object: Kubernetes Ingress Routing Configuration - Traefik

We tried to use adminConsoleServiceTemplate.metadata.annotations, but this add annotation on the ui service (console.domain), not the headless.
We tried to use then exposedFeatureServiceTemplate.metadata.annotations and all services are annotated but not the headless.
It seems the headless service is not customisable through CR.
Do you plan to add a “headlessServiceTemplate” to do so?

Best regards ^^

Hi @Emmanuel , looks like the traefik ingress differs slightly from the nginx example, but basically what you want is a sticky session to the service. I suggest setting both of the annotations:

traefik.ingress.kubernetes.io/service.sticky.cookie: "true"
traefik.ingress.kubernetes.io/service.sticky.cookie.samesite: "strict"

An referring to Traefik’s docs regarding sticky sessions.

As you’ve noted from the docs “Ingresses are not managed by the Operator because the required configuration is not generic”, and so you will not be able to be able to set this through annotation through the CRD.

Hi @tommie

We used the CR to annotate the cluster UI service:

  networking:
    exposeAdminConsole: true
    adminConsoleServiceTemplate:
      metadata:
        annotations:
          traefik.ingress.kubernetes.io/service.sticky.cookie: "true"
          traefik.ingress.kubernetes.io/service.sticky.cookie.samesite: strict

and we used directly this UI service in the ingress in place of the headless service as mentioned in the documentation.

Thank you for your help.
Best regards.