diff --git a/helm/charts/nats/Chart.yaml b/helm/charts/nats/Chart.yaml index 3e9b61b0..35bb391a 100644 --- a/helm/charts/nats/Chart.yaml +++ b/helm/charts/nats/Chart.yaml @@ -6,7 +6,7 @@ keywords: - nats - messaging - cncf -version: 1.0.0-beta.3 +version: 1.0.0-beta.4 home: http://github.com/nats-io/k8s maintainers: - email: info@nats.io diff --git a/helm/charts/nats/README.md b/helm/charts/nats/README.md index 7a8dfc6b..6cc146d8 100644 --- a/helm/charts/nats/README.md +++ b/helm/charts/nats/README.md @@ -32,8 +32,8 @@ Everything in the NATS Config or Kubernetes Resources can be overridden by `merg | `config.jetstream` | [NATS JetStream](https://docs.nats.io/running-a-nats-service/configuration#jetstream) | no | | `config.jetstream.fileStore.pvc` | [k8s PVC](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#persistentvolumeclaim-v1-core) | yes, when `config.jetstream` is enabled | | `config.nats.tls` | [NATS TLS](https://docs.nats.io/running-a-nats-service/configuration/securing_nats/tls) | no | -| `config.leafnode` | [NATS LeafNode](https://docs.nats.io/running-a-nats-service/configuration/leafnode/leafnode_conf) | no | -| `config.leafnode.tls` | [NATS TLS](https://docs.nats.io/running-a-nats-service/configuration/securing_nats/tls) | no | +| `config.leafnodes` | [NATS LeafNodes](https://docs.nats.io/running-a-nats-service/configuration/leafnodes/leafnodes_conf) | no | +| `config.leafnodes.tls` | [NATS TLS](https://docs.nats.io/running-a-nats-service/configuration/securing_nats/tls) | no | | `config.websocket` | [NATS WebSocket](https://docs.nats.io/running-a-nats-service/configuration/websocket/websocket_conf) | no | | `config.websocket.tls` | [NATS TLS](https://docs.nats.io/running-a-nats-service/configuration/securing_nats/tls) | no | | `config.websocket.ingress` | [k8s Ingress](https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#ingress-v1-networking-k8s-io) | no | diff --git a/helm/charts/nats/files/config/config.yaml b/helm/charts/nats/files/config/config.yaml index 912bffad..3cf3e7eb 100644 --- a/helm/charts/nats/files/config/config.yaml +++ b/helm/charts/nats/files/config/config.yaml @@ -21,12 +21,12 @@ tls: {{- end }} ######################################## -# leafnode +# leafnodes ######################################## -{{- with .leafnode }} +{{- with .leafnodes }} {{- if .enabled }} -leafnode: - {{- include "nats.loadMergePatch" (merge (dict "file" "config/leafnode.yaml" "ctx" $) .) | nindent 2 }} +leafnodes: + {{- include "nats.loadMergePatch" (merge (dict "file" "config/leafnodes.yaml" "ctx" $) .) | nindent 2 }} {{- end }} {{- end }} diff --git a/helm/charts/nats/files/config/leafnode.yaml b/helm/charts/nats/files/config/leafnodes.yaml similarity index 86% rename from helm/charts/nats/files/config/leafnode.yaml rename to helm/charts/nats/files/config/leafnodes.yaml index 67c7c4a6..3a1d9a14 100644 --- a/helm/charts/nats/files/config/leafnode.yaml +++ b/helm/charts/nats/files/config/leafnodes.yaml @@ -1,4 +1,4 @@ -{{- with .Values.config.leafnode }} +{{- with .Values.config.leafnodes }} port: {{ .port }} no_advertise: true diff --git a/helm/charts/nats/files/headless-service.yaml b/helm/charts/nats/files/headless-service.yaml index 5a19e7cf..beaabe54 100644 --- a/helm/charts/nats/files/headless-service.yaml +++ b/helm/charts/nats/files/headless-service.yaml @@ -10,7 +10,7 @@ spec: clusterIP: None publishNotReadyAddresses: true ports: - {{- range $protocol := list "nats" "leafnode" "websocket" "mqtt" "cluster" "gateway" "monitor" "profiling" }} + {{- range $protocol := list "nats" "leafnodes" "websocket" "mqtt" "cluster" "gateway" "monitor" "profiling" }} {{- $configProtocol := get $.Values.config $protocol }} {{- if or (eq $protocol "nats") $configProtocol.enabled }} - {{ dict "name" $protocol "port" $configProtocol.port "targetPort" $protocol | toYaml | nindent 4 }} diff --git a/helm/charts/nats/files/service.yaml b/helm/charts/nats/files/service.yaml index 5d2626bb..823f2a20 100644 --- a/helm/charts/nats/files/service.yaml +++ b/helm/charts/nats/files/service.yaml @@ -8,7 +8,7 @@ spec: selector: {{- include "nats.selectorLabels" $ | nindent 4 }} ports: - {{- range $protocol := list "nats" "leafnode" "websocket" "mqtt" "cluster" "gateway" "monitor" "profiling" }} + {{- range $protocol := list "nats" "leafnodes" "websocket" "mqtt" "cluster" "gateway" "monitor" "profiling" }} {{- $configProtocol := get $.Values.config $protocol }} {{- $servicePort := get $.Values.service.ports $protocol }} {{- if and (or (eq $protocol "nats") $configProtocol.enabled) $servicePort.enabled }} diff --git a/helm/charts/nats/files/stateful-set/nats-container.yaml b/helm/charts/nats/files/stateful-set/nats-container.yaml index 3bbc27ae..a0bbc03e 100644 --- a/helm/charts/nats/files/stateful-set/nats-container.yaml +++ b/helm/charts/nats/files/stateful-set/nats-container.yaml @@ -3,7 +3,7 @@ name: nats {{ include "nats.image" (merge (pick $.Values "global") .Values.container.image) }} ports: -{{- range $protocol := list "nats" "leafnode" "websocket" "mqtt" "cluster" "gateway" "monitor" "profiling" }} +{{- range $protocol := list "nats" "leafnodes" "websocket" "mqtt" "cluster" "gateway" "monitor" "profiling" }} {{- $configProtocol := get $.Values.config $protocol }} {{- $containerPort := get $.Values.container.ports $protocol }} {{- if or (eq $protocol "nats") $configProtocol.enabled }} diff --git a/helm/charts/nats/files/stateful-set/prom-exporter-container.yaml b/helm/charts/nats/files/stateful-set/prom-exporter-container.yaml index dc843b46..c3e1b6fb 100644 --- a/helm/charts/nats/files/stateful-set/prom-exporter-container.yaml +++ b/helm/charts/nats/files/stateful-set/prom-exporter-container.yaml @@ -21,7 +21,7 @@ args: {{- if .Values.config.jetstream.enabled }} - -jsz=all {{- end }} -{{- if .Values.config.leafnode.enabled }} +{{- if .Values.config.leafnodes.enabled }} - -leafz {{- end }} {{- if .Values.config.gateway.enabled }} diff --git a/helm/charts/nats/templates/_helpers.tpl b/helm/charts/nats/templates/_helpers.tpl index aa37461c..b7e0bd64 100644 --- a/helm/charts/nats/templates/_helpers.tpl +++ b/helm/charts/nats/templates/_helpers.tpl @@ -142,7 +142,7 @@ imagePullPolicy: {{ .pullPolicy | default .global.image.pullPolicy }} {{- define "nats.secretNames" -}} {{- $secrets := list }} -{{- range $protocol := list "nats" "leafnode" "websocket" "mqtt" "cluster" "gateway" }} +{{- range $protocol := list "nats" "leafnodes" "websocket" "mqtt" "cluster" "gateway" }} {{- $configProtocol := get $.Values.config $protocol }} {{- if and (or (eq $protocol "nats") $configProtocol.enabled) $configProtocol.tls.enabled $configProtocol.tls.secretName }} {{- $secrets = append $secrets (merge (dict "name" (printf "%s-tls" $protocol)) $configProtocol.tls) }} diff --git a/helm/charts/nats/test/config_test.go b/helm/charts/nats/test/config_test.go index a04672c8..d40653fa 100644 --- a/helm/charts/nats/test/config_test.go +++ b/helm/charts/nats/test/config_test.go @@ -280,7 +280,7 @@ config: spec: storageClassName: gp3 patch: [{op: add, path: /spec/accessModes/-, value: ReadWriteMany}] - leafnode: + leafnodes: enabled: true merge: no_advertise: false @@ -333,7 +333,7 @@ config: "max_file_store": int64(1073741824), "max_outstanding_catchup": int64(67108864), } - expected.Conf.Value["leafnode"] = map[string]any{ + expected.Conf.Value["leafnodes"] = map[string]any{ "port": int64(7422), "no_advertise": false, "advertise": "demo.nats.io:7422", @@ -424,7 +424,7 @@ config: ContainerPort: 4222, }, { - Name: "leafnode", + Name: "leafnodes", ContainerPort: 7422, }, { @@ -456,9 +456,9 @@ config: TargetPort: intstr.FromString("nats"), }, { - Name: "leafnode", + Name: "leafnodes", Port: 7422, - TargetPort: intstr.FromString("leafnode"), + TargetPort: intstr.FromString("leafnodes"), }, { Name: "websocket", @@ -494,9 +494,9 @@ config: TargetPort: intstr.FromString("nats"), }, { - Name: "leafnode", + Name: "leafnodes", Port: 7422, - TargetPort: intstr.FromString("leafnode"), + TargetPort: intstr.FromString("leafnodes"), }, { Name: "websocket", @@ -531,11 +531,11 @@ config: merge: verify_cert_and_check_known_urls: true patch: [{op: add, path: /verify_and_map, value: true}] - leafnode: + leafnodes: enabled: true tls: enabled: true - secretName: leafnode-tls + secretName: leafnodes-tls websocket: enabled: true tls: @@ -563,7 +563,7 @@ config: "tls://nats-2.nats-headless:6222", }, } - expected.Conf.Value["leafnode"] = map[string]any{ + expected.Conf.Value["leafnodes"] = map[string]any{ "port": int64(7422), "no_advertise": true, } @@ -585,7 +585,7 @@ config: volumes := expected.StatefulSet.Value.Spec.Template.Spec.Volumes natsVm := expected.StatefulSet.Value.Spec.Template.Spec.Containers[0].VolumeMounts reloaderVm := expected.StatefulSet.Value.Spec.Template.Spec.Containers[1].VolumeMounts - for _, protocol := range []string{"nats", "leafnode", "websocket", "mqtt", "cluster", "gateway"} { + for _, protocol := range []string{"nats", "leafnodes", "websocket", "mqtt", "cluster", "gateway"} { tls := map[string]any{ "cert_file": "/etc/nats-certs/" + protocol + "/tls.crt", "key_file": "/etc/nats-certs/" + protocol + "/tls.key", @@ -626,7 +626,7 @@ config: // reloader certs are alphabetized reloaderArgs := expected.StatefulSet.Value.Spec.Template.Spec.Containers[1].Args - for _, protocol := range []string{"cluster", "gateway", "leafnode", "mqtt", "nats", "websocket"} { + for _, protocol := range []string{"cluster", "gateway", "leafnodes", "mqtt", "nats", "websocket"} { if protocol == "nats" { reloaderArgs = append(reloaderArgs, "-config", "/etc/nats-certs/"+protocol+"/tls.ca") } @@ -641,7 +641,7 @@ config: ContainerPort: 4222, }, { - Name: "leafnode", + Name: "leafnodes", ContainerPort: 7422, }, { @@ -673,9 +673,9 @@ config: TargetPort: intstr.FromString("nats"), }, { - Name: "leafnode", + Name: "leafnodes", Port: 7422, - TargetPort: intstr.FromString("leafnode"), + TargetPort: intstr.FromString("leafnodes"), }, { Name: "websocket", @@ -711,9 +711,9 @@ config: TargetPort: intstr.FromString("nats"), }, { - Name: "leafnode", + Name: "leafnodes", Port: 7422, - TargetPort: intstr.FromString("leafnode"), + TargetPort: intstr.FromString("leafnodes"), }, { Name: "websocket", diff --git a/helm/charts/nats/test/ports_test.go b/helm/charts/nats/test/ports_test.go index e376ecd4..db5733bb 100644 --- a/helm/charts/nats/test/ports_test.go +++ b/helm/charts/nats/test/ports_test.go @@ -17,7 +17,7 @@ config: port: 1005 nats: port: 1001 - leafnode: + leafnodes: enabled: true port: 1002 websocket: @@ -39,7 +39,7 @@ container: ports: nats: hostPort: 2001 - leafnode: + leafnodes: hostPort: 2002 websocket: hostPort: 2003 @@ -63,7 +63,7 @@ service: enabled: true port: 3001 nodePort: 4001 - leafnode: + leafnodes: enabled: true port: 3002 nodePort: 4002 @@ -94,7 +94,7 @@ service: ` expected := DefaultResources(t, test) expected.Conf.Value["port"] = int64(1001) - expected.Conf.Value["leafnode"] = map[string]any{ + expected.Conf.Value["leafnodes"] = map[string]any{ "port": int64(1002), "no_advertise": true, } @@ -133,7 +133,7 @@ service: HostPort: 2001, }, { - Name: "leafnode", + Name: "leafnodes", ContainerPort: 1002, HostPort: 2002, }, @@ -176,9 +176,9 @@ service: TargetPort: intstr.FromString("nats"), }, { - Name: "leafnode", + Name: "leafnodes", Port: 1002, - TargetPort: intstr.FromString("leafnode"), + TargetPort: intstr.FromString("leafnodes"), }, { Name: "websocket", @@ -221,10 +221,10 @@ service: TargetPort: intstr.FromString("nats"), }, { - Name: "leafnode", + Name: "leafnodes", Port: 3002, NodePort: 4002, - TargetPort: intstr.FromString("leafnode"), + TargetPort: intstr.FromString("leafnodes"), }, { Name: "websocket", diff --git a/helm/charts/nats/values.yaml b/helm/charts/nats/values.yaml index f8fbfc89..fc415175 100644 --- a/helm/charts/nats/values.yaml +++ b/helm/charts/nats/values.yaml @@ -95,14 +95,14 @@ config: merge: {} patch: [] - leafnode: + leafnodes: enabled: false port: 7422 tls: enabled: false # set secretName in order to mount an existing secret to dir secretName: - dir: /etc/nats-certs/leafnode + dir: /etc/nats-certs/leafnodes cert: tls.crt key: tls.key ca: @@ -111,8 +111,8 @@ config: merge: {} patch: [] - # merge or patch the leafnode config - # https://docs.nats.io/running-a-nats-service/configuration/leafnode/leafnode_conf + # merge or patch the leafnodes config + # https://docs.nats.io/running-a-nats-service/configuration/leafnodes/leafnode_conf merge: {} patch: [] @@ -282,7 +282,7 @@ container: # https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.24/#containerport-v1-core ports: nats: {} - leafnode: {} + leafnodes: {} websocket: {} mqtt: {} cluster: {} @@ -379,7 +379,7 @@ service: ports: nats: enabled: true - leafnode: + leafnodes: enabled: true websocket: enabled: true