Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor updates to the ziti-router service template #281

Open
wants to merge 3 commits into
base: kevinlmadison-router-proxy-services
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions charts/ziti-router/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ spec:
{{- if and .Values.tunnel.mode (eq .Values.tunnel.mode "proxy" ) (gt (len .Values.tunnel.proxyAdditionalK8sServices) 0) }}
{{- $root := . }}
{{- range .Values.tunnel.proxyAdditionalK8sServices }}
---
qrkourier marked this conversation as resolved.
Show resolved Hide resolved
apiVersion: v1
kind: Service
metadata:
Expand Down Expand Up @@ -237,9 +238,9 @@ spec:
ports:
{{- $service_name := .name }}
kevinlmadison marked this conversation as resolved.
Show resolved Hide resolved
{{- range $root.Values.tunnel.proxyServices }}
{{- if and .k8sService (eq .k8sService $service_name) }}
- port: {{ .advertisedrPort }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow. I'm surprised I missed those typos! I definitely tested this, so now I'm wondering how it ever worked. I could only have tested the default service. 🤔

targetPort: {{ .containerPortPort }}
{{- if and .zitiService (eq .zitiService $service_name) }}
Copy link
Member

@qrkourier qrkourier Nov 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Matching the zitiService instead of k8sService isn't crazy. 🤪 It will work either way. With those typos, I don't see how anyone could use this feature successfully, so I'm guessing the contributor tweaked it further to get it working in their fork, and that makes the risk of a breaking change vanishingly small.

Instead of matching proxyAdditionalK8sServices[].name , it would be more obvious how this works to use the exact property that needs to match a member of proxyServices, i.e., let proxyAdditionalK8sServices[].name become proxyAdditionalK8sServices[].zitiService in the template and update values.yaml example/inline comment guidance to reflect the new pattern.

If you agree, then the values.yaml would look something like this:

  # -- if tunnel mode is "proxy", define an inventory of Ziti services this router's tunneler identity has permission to dial that may be published as a ClusterIP, NodePort, or LoadBalancer service
  proxyServices: []
    #  # -- name of the Openziti service to publish as a cluster service
    #- zitiService: my_ziti_service
    #  # -- create a cluster service named {{ release }}-proxy-{{ .k8sService}} when this item matches proxyAdditionalK8sServices
    #  k8sService: my_k8s_suffix
    #  # -- TCP port on which the cluster service listens for clients
    #  advertisedPort: 80
    #  # -- override the container port (default: advertisedPort)
    #  containerPort: 8443
  # -- if tunnel mode is "proxy", create a single cluster service named {{ release }}-proxy-default listening on each "advertisedPort" defined in "proxyServices" (one cluster service and type with many ports)
  proxyDefaultK8sService:
    enabled: true
    type: ClusterIP
  # -- if tunnel mode is "proxy", create a cluster service for each of "proxyServices" where zitiService == zitiService (many cluster services with distinct types, each with one port)
  proxyAdditionalK8sServices: []
    #- zitiService: my_ziti_service
    #  type: ClusterIP

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I definitely agree, I forgot to revisit this naming after getting things working.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool. Thanks for those two commits to line up the names. Will you please edit the values.yaml with something like that example above? If that snippet works for you I could add it in my branch after this merges.

kevinlmadison marked this conversation as resolved.
Show resolved Hide resolved
- port: {{ .advertisedPort }}
targetPort: {{ .containerPort }}
protocol: {{ .serviceProtocol | default "TCP" }}
name: {{ regexReplaceAll "\\W+" .zitiService "-" }}
{{- if eq $type "NodePort" }}
Expand Down
Loading