Skip to content

Commit

Permalink
[helm nats 1.x] leafnode -> leafnodes
Browse files Browse the repository at this point in the history
Signed-off-by: Caleb Lloyd <[email protected]>
  • Loading branch information
Caleb Lloyd committed May 17, 2023
1 parent 56c3f8c commit f9690a1
Show file tree
Hide file tree
Showing 12 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion helm/charts/nats/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: [email protected]
Expand Down
4 changes: 2 additions & 2 deletions helm/charts/nats/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
8 changes: 4 additions & 4 deletions helm/charts/nats/files/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- with .Values.config.leafnode }}
{{- with .Values.config.leafnodes }}
port: {{ .port }}
no_advertise: true

Expand Down
2 changes: 1 addition & 1 deletion helm/charts/nats/files/headless-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion helm/charts/nats/files/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion helm/charts/nats/files/stateful-set/nats-container.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
2 changes: 1 addition & 1 deletion helm/charts/nats/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -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) }}
Expand Down
34 changes: 17 additions & 17 deletions helm/charts/nats/test/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ config:
spec:
storageClassName: gp3
patch: [{op: add, path: /spec/accessModes/-, value: ReadWriteMany}]
leafnode:
leafnodes:
enabled: true
merge:
no_advertise: false
Expand Down Expand Up @@ -379,7 +379,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",
Expand Down Expand Up @@ -493,7 +493,7 @@ find . -maxdepth 1 -mindepth 1 -not -name 'lost+found' -not -name 'jetstream' -e
ContainerPort: 4222,
},
{
Name: "leafnode",
Name: "leafnodes",
ContainerPort: 7422,
},
{
Expand Down Expand Up @@ -525,9 +525,9 @@ find . -maxdepth 1 -mindepth 1 -not -name 'lost+found' -not -name 'jetstream' -e
TargetPort: intstr.FromString("nats"),
},
{
Name: "leafnode",
Name: "leafnodes",
Port: 7422,
TargetPort: intstr.FromString("leafnode"),
TargetPort: intstr.FromString("leafnodes"),
},
{
Name: "websocket",
Expand Down Expand Up @@ -563,9 +563,9 @@ find . -maxdepth 1 -mindepth 1 -not -name 'lost+found' -not -name 'jetstream' -e
TargetPort: intstr.FromString("nats"),
},
{
Name: "leafnode",
Name: "leafnodes",
Port: 7422,
TargetPort: intstr.FromString("leafnode"),
TargetPort: intstr.FromString("leafnodes"),
},
{
Name: "websocket",
Expand Down Expand Up @@ -600,11 +600,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:
Expand Down Expand Up @@ -632,7 +632,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,
}
Expand All @@ -654,7 +654,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",
Expand Down Expand Up @@ -695,7 +695,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")
}
Expand All @@ -710,7 +710,7 @@ config:
ContainerPort: 4222,
},
{
Name: "leafnode",
Name: "leafnodes",
ContainerPort: 7422,
},
{
Expand Down Expand Up @@ -742,9 +742,9 @@ config:
TargetPort: intstr.FromString("nats"),
},
{
Name: "leafnode",
Name: "leafnodes",
Port: 7422,
TargetPort: intstr.FromString("leafnode"),
TargetPort: intstr.FromString("leafnodes"),
},
{
Name: "websocket",
Expand Down Expand Up @@ -780,9 +780,9 @@ config:
TargetPort: intstr.FromString("nats"),
},
{
Name: "leafnode",
Name: "leafnodes",
Port: 7422,
TargetPort: intstr.FromString("leafnode"),
TargetPort: intstr.FromString("leafnodes"),
},
{
Name: "websocket",
Expand Down
18 changes: 9 additions & 9 deletions helm/charts/nats/test/ports_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ config:
port: 1005
nats:
port: 1001
leafnode:
leafnodes:
enabled: true
port: 1002
websocket:
Expand All @@ -39,7 +39,7 @@ container:
ports:
nats:
hostPort: 2001
leafnode:
leafnodes:
hostPort: 2002
websocket:
hostPort: 2003
Expand All @@ -63,7 +63,7 @@ service:
enabled: true
port: 3001
nodePort: 4001
leafnode:
leafnodes:
enabled: true
port: 3002
nodePort: 4002
Expand Down Expand Up @@ -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,
}
Expand Down Expand Up @@ -133,7 +133,7 @@ service:
HostPort: 2001,
},
{
Name: "leafnode",
Name: "leafnodes",
ContainerPort: 1002,
HostPort: 2002,
},
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
12 changes: 6 additions & 6 deletions helm/charts/nats/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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: []

Expand Down Expand Up @@ -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: {}
Expand Down Expand Up @@ -379,7 +379,7 @@ service:
ports:
nats:
enabled: true
leafnode:
leafnodes:
enabled: true
websocket:
enabled: true
Expand Down

0 comments on commit f9690a1

Please sign in to comment.