Skip to content

Commit

Permalink
Update klat ingress to handle root -> www forwarding (#56)
Browse files Browse the repository at this point in the history
Rename default Klat TLS Secret
Add configuration prompt to configure additional `www` subdomain for Klat

Co-authored-by: Daniel McKnight <[email protected]>
  • Loading branch information
NeonDaniel and NeonDaniel authored Dec 22, 2023
1 parent 50945a0 commit 04067b7
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 3 deletions.
9 changes: 9 additions & 0 deletions neon_diana_utils/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -696,6 +696,10 @@ def configure_klat_chat(external_url: str = None,
confirmed = click.confirm(f"Is '{api_url}' correct?")
api_subdomain = api_url.split('://', 1)[1].split('.', 1)[0]

forward_www = False
if subdomain != "www":
forward_www = click.prompt(f"Route www.{domain} traffic to Klat?")

# Get Libretranslate HTTP API URL
libretranslate_url = "https://libretranslate.2022.us"
confirmed = False
Expand Down Expand Up @@ -790,6 +794,11 @@ def configure_klat_chat(external_url: str = None,
{'host': api_subdomain, 'serviceName': 'klat-chat-server',
'servicePort': 8010}
]
if forward_www:
helm_values['klat']['ingress']['rules'].append({
{'host': 'www', 'serviceName': 'klat-chat-client',
'servicePort': 8001}
})
with open(join(output_path, "klat-chat", "values.yaml"), 'w') as f:
yaml.safe_dump(helm_values, f)
else:
Expand Down
2 changes: 1 addition & 1 deletion neon_diana_utils/helm_charts/klat/klat-chat/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ name: klat-chat
description: Deploy Klat Services

type: application
version: 0.0.4
version: 0.0.5
appVersion: "1.0.1a13"
13 changes: 13 additions & 0 deletions neon_diana_utils/helm_charts/klat/klat-chat/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,30 @@ metadata:
annotations:
kubernetes.io/ingress.class: {{ .Values.ingress.ingressClassName }}
cert-manager.io/issuer: {{ .Values.ingress.certIssuer }}
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
spec:
tls:
- secretName: {{ .Values.ingress.tlsSecretName }}
hosts:
{{- range .Values.ingress.rules }}
{{- if eq .host "*" }}
- "*.{{ $.Values.domain }}"
{{- else if eq .host $.Values.domain }}
- {{ $.Values.domain}}
{{- else }}
- {{ printf "%s.%s " .host $.Values.domain }}
{{- end }}
{{- end }}

rules:
{{- range .Values.ingress.rules }}
{{- if eq .host "*" }}
- host: "*.{{ $.Values.domain }}"
{{- else if eq .host $.Values.domain }}
- host: {{ $.Values.domain}}
{{- else }}
- host: {{ printf "%s.%s " .host $.Values.domain }}
{{- end }}
http:
paths:
- path: /
Expand Down
2 changes: 1 addition & 1 deletion neon_diana_utils/helm_charts/klat/klat-chat/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ resources:
ingress:
enabled: True
ingressClassName: nginx
tlsSecretName: tls-letsencrypt-prod
tlsSecretName: tls-letsencrypt-klat
certIssuer: letsencrypt-private-key
rules:
- host: klat
Expand Down
2 changes: 1 addition & 1 deletion neon_diana_utils/templates/klat/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ appVersion: "1.0.1a5"
dependencies:
- name: klat-chat
alias: klat
version: 0.0.4
version: 0.0.5
repository: https://neongeckocom.github.io/neon-diana-utils

0 comments on commit 04067b7

Please sign in to comment.