Sync Gateway sync function in Helm values.yaml

How do you define the sync gateway sync function in a values.yaml to configure a Helm release? I get an error like Error: failed to parse values.yaml: error converting YAML to JSON: yaml: line 112: could not find expected ':'.

I’ve tried:

syncGateway:
  config:
    databases:
      db:
        ...
        sync: |-
function synctos(doc, oldDoc) {
    ...
}

as well as:

syncGateway:
  config:
    databases:
      db:
        ...
        sync: "function synctos(doc, oldDoc) {\n    ...\n}"

I was unable to find an answer either here or here in the documentation.

Also, is it possible to store the Helm sync gateway configuration as a secret, as described in the tutorial?

Normally the sync function is enclosed in a pair of backticks `` – so:
`function synctos(doc, oldDoc) {\n …\n}`

@jeff.lockhart looks like your indentation is messed up and that is critical when using .yaml

Here’s an example

syncGateway:
   # name of the sync gatway pod.
   # defaults to name of chart
   name: sync-gateway-helm
   exposeServiceType: LoadBalancer
   config:
    databases:
     db:
       # bucket replicated to sync gateway
       bucket: travel-sample
       # server to connect db to, defaults to cluster server
       server: couchbases://cb-example-srv
       # username of db admin, defaults to cluster admin username
       username: admin
       # password of db admin, defaults to cluster admin password
       password: password
       #cacertpath: /etc/sync_gateway/ca.pem
       sync: |-
              function sync(doc, oldDoc) {
                console.log("in sync");
              }

Also, is it possible to store the Helm sync gateway configuration as a secret, as described in the tutorial ?

There is a configSecret that you can use in your helm specification

@priya.rajagopal thank you! The indentation was the key. And thank you for pointing me in the right direction for the configSecret documentation.

I have another question. How can you specify the number of sync gateway pods to run to horizontally scale?

I know exactly how to specify it outside of helm when you define your own Deployment but I am not as familiar with helm charts so I will have to defer to @tommie on that one.

That said, once you have your sync gateway running you can scale (up/down) your deployment on demand using the following command

kubectl scale --replicas=2 deployments/sync-gateway-helm

Looks like replicas is hardcoded to 1 in the helm chart. Could this be added to the values spec?

I also noticed the chart name is incorrectly shown as stable/couchbase instead of couchbase/couchbase-operator.

Yes - You can override any of the values In the chart template using the methods defined here

@priya.rajagopal yes, I’m doing this. But the problem is that the replicas value in the deployment yaml in the helm chart is hardcoded to 1. So I’m asking if this can be made a variable value that can be overridden.

I created a pull request with this change to expose the sync gateway replicas value in the helm chart.