Skip to content

Commit 7d9dfd3

Browse files
committed
feat: add extra services ingresses and httproutes
1 parent 82304ac commit 7d9dfd3

10 files changed

Lines changed: 310 additions & 11 deletions

File tree

charts/app-starter/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: app-starter
33
description: A streamlined, extensible Helm chart for deploying applications on Kubernetes
44
type: application
5-
version: 1.2.2
5+
version: 1.3.0
66
appVersion: "1.0.0"
77
kubeVersion: ">=1.22.0-0"
88
home: https://github.com/synkube/

charts/app-starter/templates/deployment.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ spec:
149149
{{- end }}
150150
{{- end }}
151151
{{- end }}
152-
{{- with .Values.additionalContainers }}
152+
{{- with .Values.extraContainers }}
153153
{{- toYaml . | nindent 8 }}
154154
{{- end }}
155155
{{- if or (.Values.configMaps) (.Values.secretMounts) (.Values.container.volumes) (.Values.persistence.enabled)}}

charts/app-starter/templates/httproute.yaml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,63 @@ spec:
5555
# Install Gateway API CRDs to use HTTPRoute resources
5656
# https://gateway-api.sigs.k8s.io/guides/#installing-gateway-api
5757
{{- end }}
58+
{{/* Extra HTTPRoutes - for additional routes with different rules/filters */}}
59+
{{- range .Values.extraHTTPRoutes }}
60+
{{- if (include "common.hasApi" (list "gateway.networking.k8s.io/v1/HTTPRoute" $)) }}
61+
---
62+
apiVersion: gateway.networking.k8s.io/v1
63+
kind: HTTPRoute
64+
metadata:
65+
name: {{ printf "%s-%s" (include "app-starter.fullname" $) (.name | default (randAlphaNum 4 | lower)) }}
66+
{{- with .annotations }}
67+
annotations:
68+
{{- toYaml . | nindent 4 }}
69+
{{- end }}
70+
labels:
71+
{{ include "app-starter.labels" $ | indent 4 }}
72+
spec:
73+
{{- if .parentRefs }}
74+
parentRefs:
75+
{{- toYaml .parentRefs | nindent 4 }}
76+
{{- else if $.Values.gateway.parentRefs }}
77+
parentRefs:
78+
{{- toYaml $.Values.gateway.parentRefs | nindent 4 }}
79+
{{- end }}
80+
{{- if .hostnames }}
81+
hostnames:
82+
{{- range .hostnames }}
83+
- {{ tpl . $ }}
84+
{{- end }}
85+
{{- end }}
86+
rules:
87+
{{- range .rules }}
88+
- matches:
89+
{{- toYaml .matches | nindent 8 }}
90+
{{- with .filters }}
91+
filters:
92+
{{- toYaml . | nindent 8 }}
93+
{{- end }}
94+
{{- with .timeouts }}
95+
timeouts:
96+
{{- toYaml . | nindent 8 }}
97+
{{- end }}
98+
{{- if .backendRefs }}
99+
backendRefs:
100+
{{- range .backendRefs }}
101+
- name: {{ .name | default (include "app-starter.fullname" $) }}
102+
port: {{ .port | default $.Values.gateway.servicePort | default 80 }}
103+
{{- with .weight }}
104+
weight: {{ . }}
105+
{{- end }}
106+
{{- with .namespace }}
107+
namespace: {{ . }}
108+
{{- end }}
109+
{{- end }}
110+
{{- else }}
111+
backendRefs:
112+
- name: {{ include "app-starter.fullname" $ }}
113+
port: {{ $.Values.gateway.servicePort | default 80 }}
114+
{{- end }}
115+
{{- end }}
116+
{{- end }}
117+
{{- end }}

charts/app-starter/templates/ingress.yaml

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
{{- if .Values.ingress.enabled -}}
21
{{- $fullName := include "app-starter.fullname" . -}}
2+
{{- if .Values.ingress.enabled -}}
33
apiVersion: networking.k8s.io/v1
44
kind: Ingress
55
metadata:
@@ -44,3 +44,49 @@ spec:
4444
{{- end }}
4545
{{- end }}
4646
{{- end }}
47+
{{/* Extra Ingresses - for additional subdomains/endpoints */}}
48+
{{- range .Values.extraIngresses }}
49+
---
50+
apiVersion: networking.k8s.io/v1
51+
kind: Ingress
52+
metadata:
53+
name: {{ printf "%s-%s" $fullName (.name | default (randAlphaNum 4 | lower)) }}
54+
labels:
55+
{{ include "app-starter.labels" $ | indent 4 }}
56+
{{- with .annotations }}
57+
annotations:
58+
{{- toYaml . | nindent 4 }}
59+
{{- end }}
60+
spec:
61+
{{- if .className }}
62+
ingressClassName: {{ .className }}
63+
{{- else if $.Values.ingress.className }}
64+
ingressClassName: {{ $.Values.ingress.className }}
65+
{{- end }}
66+
{{- if .tls }}
67+
tls:
68+
{{- range .tls }}
69+
- hosts:
70+
{{- range .hosts }}
71+
- {{ tpl . $ | quote }}
72+
{{- end }}
73+
secretName: {{ tpl .secretName $ }}
74+
{{- end }}
75+
{{- end }}
76+
rules:
77+
{{- range .hosts }}
78+
- host: {{ tpl .host $ | quote }}
79+
http:
80+
paths:
81+
{{- $pathType := .pathType }}
82+
{{- range .paths }}
83+
- pathType: {{ default "Prefix" $pathType }}
84+
path: {{ . | quote }}
85+
backend:
86+
service:
87+
name: {{ $fullName }}
88+
port:
89+
name: {{ $.Values.ingress.servicePortName | default "http" }}
90+
{{- end }}
91+
{{- end }}
92+
{{- end }}

charts/app-starter/templates/service.yaml

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,38 @@ spec:
2727
{{- end }}
2828
selector:
2929
{{- include "app-starter.selectorLabels" . | nindent 4 }}
30-
{{- end -}}
30+
{{- end }}
31+
{{/* Extra Services - for additional service types/configurations */}}
32+
{{- range .Values.extraServices }}
33+
---
34+
apiVersion: v1
35+
kind: Service
36+
metadata:
37+
name: {{ printf "%s-%s" (include "app-starter.fullname" $) (.name | default (randAlphaNum 4 | lower)) }}
38+
{{- with .annotations }}
39+
annotations:
40+
{{- toYaml . | nindent 4 }}
41+
{{- end }}
42+
labels:
43+
{{ include "app-starter.labels" $ | indent 4 }}
44+
{{- with .labels }}
45+
{{- toYaml . | nindent 4 }}
46+
{{- end }}
47+
spec:
48+
type: {{ .type | default "ClusterIP" }}
49+
{{- if .headless }}
50+
clusterIP: None
51+
{{- end }}
52+
ports:
53+
{{- range .ports }}
54+
- port: {{ .port }}
55+
targetPort: {{ .targetPort | default .port }}
56+
protocol: {{ .protocol | default "TCP" }}
57+
name: {{ .name }}
58+
{{- if and (eq (default "ClusterIP" $.type) "NodePort") .nodePort }}
59+
nodePort: {{ .nodePort }}
60+
{{- end }}
61+
{{- end }}
62+
selector:
63+
{{- include "app-starter.selectorLabels" $ | nindent 4 }}
64+
{{- end }}

charts/app-starter/templates/statefullset.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ spec:
152152
{{- end }}
153153
{{- end }}
154154
{{- end }}
155-
{{- with .Values.additionalContainers }}
155+
{{- with .Values.extraContainers }}
156156
{{- toYaml . | nindent 8 }}
157157
{{- end }}
158158
{{- with .Values.nodeSelector }}

charts/app-starter/test-values/08-gateway-advanced.yaml

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Test 8: Advanced Gateway API with traffic splitting and timeouts
1+
# Test 8: Advanced Gateway API with traffic splitting, timeouts, and extraHTTPRoutes
22
replicaCount: 2
33

44
image:
@@ -79,3 +79,39 @@ resources:
7979
cpu: 500m
8080
memory: 512Mi
8181

82+
# Extra HTTPRoutes (for additional routes with different rules)
83+
extraHTTPRoutes:
84+
- name: webhooks
85+
annotations:
86+
gateway.networking.k8s.io/rate-limit: "1000"
87+
hostnames:
88+
- webhooks.example.com
89+
rules:
90+
- matches:
91+
- path:
92+
type: Exact
93+
value: /webhook/github
94+
- path:
95+
type: Exact
96+
value: /webhook/slack
97+
timeouts:
98+
request: 60s
99+
backendRequest: 55s
100+
101+
- name: internal-api
102+
parentRefs: # Override to use different gateway
103+
- name: internal-gateway
104+
namespace: gateway-system
105+
hostnames:
106+
- internal-api.local
107+
rules:
108+
- matches:
109+
- path:
110+
type: PathPrefix
111+
value: /internal
112+
filters:
113+
- type: RequestHeaderModifier
114+
requestHeaderModifier:
115+
add:
116+
- name: X-Internal
117+
value: "true"

charts/app-starter/test-values/09-with-sidecars.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ container:
5555
emptyDir: {}
5656

5757
# Additional sidecar containers
58-
additionalContainers:
58+
extraContainers:
5959
- name: log-shipper
6060
image: fluent/fluent-bit:latest
6161
env:

charts/app-starter/test-values/15-service-types-and-ingress.yaml

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Test case: Different service types and ingress configurations
2-
# Tests: LoadBalancer service, ingress className, multiple ingress paths
2+
# Tests: LoadBalancer service, ingress className, multiple ingress paths, extraIngresses, extraServices
33

44
deployment:
55
enabled: true
@@ -63,3 +63,54 @@ ingress:
6363
hosts:
6464
- admin.example.com
6565

66+
# Extra Ingresses (for subdomains with different middleware/auth)
67+
extraIngresses:
68+
- name: api
69+
annotations:
70+
nginx.ingress.kubernetes.io/auth-type: basic
71+
nginx.ingress.kubernetes.io/auth-secret: api-auth
72+
nginx.ingress.kubernetes.io/auth-realm: "API Authentication"
73+
hosts:
74+
- host: api.example.com
75+
pathType: Prefix
76+
paths:
77+
- /v1
78+
- /v2
79+
tls:
80+
- secretName: api-example-com-tls
81+
hosts:
82+
- api.example.com
83+
84+
- name: webhooks
85+
className: "traefik" # Override className for this ingress
86+
annotations:
87+
traefik.ingress.kubernetes.io/router.middlewares: "network-rate-limit@kubernetescrd"
88+
hosts:
89+
- host: "{{ .Release.Name }}-webhooks.example.com" # Templated hostname
90+
pathType: Exact
91+
paths:
92+
- /webhook
93+
tls:
94+
- secretName: "{{ .Release.Name }}-webhooks-tls"
95+
hosts:
96+
- "{{ .Release.Name }}-webhooks.example.com"
97+
98+
# Extra Services (for additional service configurations)
99+
extraServices:
100+
- name: external
101+
type: LoadBalancer
102+
annotations:
103+
service.beta.kubernetes.io/aws-load-balancer-type: "nlb"
104+
labels:
105+
exposure: external
106+
ports:
107+
- port: 443
108+
targetPort: 8080
109+
name: https
110+
111+
- name: metrics
112+
type: ClusterIP
113+
ports:
114+
- port: 9090
115+
targetPort: 8081
116+
name: metrics

0 commit comments

Comments
 (0)