nats-io / k8s

NATS on Kubernetes with Helm Charts
Apache License 2.0
444 stars 300 forks source link

allow nats service annotations #894

Closed tommyjcarpenter closed 4 months ago

tommyjcarpenter commented 4 months ago

What motivated this proposal?

we need to add an external-dns service annotation if nats.service.enabled is on, for our production setup that gives DNS names to LoadBalancer services.

What is the proposed change?

https://github.com/nats-io/k8s/blob/main/helm/charts/nats/files/service.yaml#L3

this section should include a way to specifiy service annotations

something like

metadata:
  {{- include "nats.metadataNamespace" $ | nindent 2 }}
  name: {{ .Values.service.name }}
  labels:
    {{- include "nats.labels" $ | nindent 4 }}

  # NEW:
  annotations:
     {{- include "Values.service.annotations" $ | nindent 4 }}

Who benefits from this change?

anybody who wants an external-dns annotation or any other service annotations.

What alternatives have you evaluated?

we are turning the builtin service off and instead adding our own custom service on, but this is hacky and we would like to use the builtin.

caleblloyd commented 4 months ago

you can merge/patch any k8s yaml right in:

service:
  merge:
    metadata:
      annotations:
        your-annotation: here

Full reference of resources that support merge/patch: https://artifacthub.io/packages/helm/nats/nats#values

tommyjcarpenter commented 4 months ago

@caleblloyd what if the value of this has to use $.Values? eg

your-annotation: {{ $.Values...}}
caleblloyd commented 4 months ago

https://artifacthub.io/packages/helm/nats/nats#templating-values

example:

service:
  merge:
    metadata:
      annotations:
        your-annotation:
          $tplYaml: |
            {{ $.Values.myValue }}