Skip to content

Commit

Permalink
[helm nats 1.x] leafnode -> leafnodes (#720)
Browse files Browse the repository at this point in the history
Signed-off-by: Caleb Lloyd <[email protected]>
  • Loading branch information
caleblloyd committed May 17, 2023
1 parent 4a87253 commit 52606f1
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 @@ -280,7 +280,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 @@ -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",
Expand Down Expand Up @@ -424,7 +424,7 @@ config:
ContainerPort: 4222,
},
{
Name: "leafnode",
Name: "leafnodes",
ContainerPort: 7422,
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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,
}
Expand All @@ -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",
Expand Down Expand Up @@ -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")
}
Expand All @@ -641,7 +641,7 @@ config:
ContainerPort: 4222,
},
{
Name: "leafnode",
Name: "leafnodes",
ContainerPort: 7422,
},
{
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
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 52606f1

Please sign in to comment.