How to add k8s secret as environment variable for CouchbaseCluster server pod?

The V1 release of the Operator was… somewhat non-intuitive :smile:

env does exist, but as couchbaseEnv, for example:

servers:
  - size: 1
    name: all_services
    services:
      - data
      - index
      - query
    pod:
      couchbaseEnv:
      - name: EXPLICIT_VAR
        value: test
      - name: IMPLICIT_VAR
        valueFrom:
          secretKeyRef:
            name: cb-example-auth
            key: username

And results in…

$ kubectl exec -ti cb-example-0000 -- env | grep EXPLI
EXPLICIT_VAR=test
$ kubectl exec -ti cb-example-0000 -- env | grep IMPL
IMPLICIT_VAR=Administrator

I’ve righted the wrongs of the past in V2, upgrade if you can, it’s a much nicer experience! That said if you can’t follow my guidance above and it will work.

For completeness, envFrom works like this:

    envFrom:
    - prefix: TEST_
      secretRef:
        name: cb-example-auth

And results in:

$  kubectl exec -ti cb-example-0000 -- env | grep TEST
TEST_password=password
TEST_username=Administrator