Using go template with Kots and kustomize

Hello There,
We would like to add a block of code based on if condition. Something like we want to add a bunch of annotations only for cloud deployments like below.

apiVersion: v1
kind: Service
  {{repl if not IsKurl}}
  annotations: tcp 'true' nlb
  {{repl end}}
  labels: ingress-nginx-3.30.0 ingress-nginx ingress-nginx 0.46.0 Helm controller
  name: ingress-nginx-controller
  namespace: ingress-nginx
  type: "{{repl ternary NodePort LoadBalancer IsKurl}}"
    - name: http
      nodePort: 80
      port: 80
      protocol: TCP
      targetPort: http
    - name: https
      nodePort: 443
      port: 443
      protocol: TCP
      targetPort: https
  selector: ingress-nginx ingress-nginx controller

When we tried doing that and used kustomize to build it throws validation errors. yaml: line 5: mapping values are not allowed in this context'.
Is there a way of making this work so that we can leverage the use of kots templte functions?

Did you ever determine a solution to this question?

Hey Mike - I am sorry you did not get a reply. In your case, I would define separate yamls, like a aws-service.yaml, a gke-service.yaml, etc… and then you could use the ‘’ label annotation to only deploy the correct yaml based on the cloud provider.

For example you could have a config option that the user selects which cloud environment they are deploying to, and then based on the selection, deploy the corresponding manifest I.e., if they select ‘aws’, then you deploy the ‘aws-ingress.yaml’.

Here is an example of a service for postgres that only gets deployed if the config option is set to use ‘embedded postgres’ vs ‘external postgres’

Here is the documenation on how to optionally deploy a service Including Optional and Conditional Resources | Replicated Docs