Skip to content

Commit 6987736

Browse files
kharkevichCopilot
andauthored
feat: add ingress chart (#1)
* feat: add ingress chart * fix: charts/application-ingress/values.yaml Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * chore: charts/application-ingress/readme.md Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent dd98d35 commit 6987736

5 files changed

Lines changed: 122 additions & 0 deletions

File tree

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v2
2+
name: ingress
3+
version: 1.1.1
4+
description: A Helm chart for Ingress
5+
type: application
6+
home: https://github.com/technicaldomain/helm
7+
sources:
8+
- https://github.com/technicaldomain/helm
9+
maintainers:
10+
- email: alex@kharkevich.org
11+
name: Alexander Kharkevich
12+
icon: file://icon.png
13+
appVersion: "1.0"
14+
15+
dependencies:
16+
- name: common
17+
repository: https://technicaldomain.github.io/helm/
18+
version: 2.1.4
5.04 KB
Loading
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Manage Ingress in a Simple Way
2+
3+
See [values.yaml](./values.yaml) for more details
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{{- $fullName := include "common.fullname" . }}
2+
{{- $appLabels := include "common.labels.standard" . -}}
3+
{{- range .Values.services }}
4+
{{- $contextPath := .contextPath }}
5+
{{- $serviceName := .name }}
6+
{{- $servicePort := .port | default 80 }}
7+
{{- $annotations := .annotations }}
8+
{{- $useRewrite := .useRewrite }}
9+
{{- $ingressClass := .ingressClass | default $.Values.ingressClass | default "traefik" }}
10+
{{- /* Define default annotations */}}
11+
{{- $defaultAnnotations := dict }}
12+
{{- if eq $ingressClass "nginx" }}
13+
{{- $_ := set $defaultAnnotations "kubernetes.io/ingress.class" "nginx" }}
14+
{{- $_ := set $defaultAnnotations "nginx.ingress.kubernetes.io/service-upstream" "true" }}
15+
{{- $_ := set $defaultAnnotations "nginx.ingress.kubernetes.io/upstream-vhost" (printf "%s.%s.svc.cluster.local" $serviceName $.Release.Namespace) }}
16+
{{- $_ := set $defaultAnnotations "nginx.ingress.kubernetes.io/use-regex" "true" }}
17+
{{- if (default $useRewrite false) }}
18+
{{- $_ := set $defaultAnnotations "nginx.ingress.kubernetes.io/rewrite-target" "/$2" }}
19+
{{- end }}
20+
{{- else if eq $ingressClass "traefik" }}
21+
{{- $_ := set $defaultAnnotations "kubernetes.io/ingress.class" "traefik" }}
22+
{{- $_ := set $defaultAnnotations "traefik.ingress.kubernetes.io/router.entrypoints" "web" }}
23+
{{- if (default $useRewrite false) }}
24+
{{- $_ := set $defaultAnnotations "traefik.ingress.kubernetes.io/router.middlewares" (printf "%s-rewrite" $serviceName) }}
25+
{{- end }}
26+
{{- end }}
27+
28+
{{- /* Merge annotations from values file, overriding defaults */}}
29+
{{- $mergedAnnotations := mergeOverwrite $defaultAnnotations $annotations }}
30+
31+
---
32+
apiVersion: networking.k8s.io/v1
33+
kind: Ingress
34+
metadata:
35+
name: {{ $fullName}}-{{ $serviceName }}
36+
labels: {{ $appLabels | nindent 4 }}
37+
annotations:
38+
{{- range $key, $value := $mergedAnnotations }}
39+
{{ $key }}: {{ $value | quote }}
40+
{{- end }}
41+
spec:
42+
tls:
43+
- hosts:
44+
{{- range $.Values.hosts }}
45+
- {{ . | quote }}
46+
{{- end }}
47+
{{- if $.Values.explicitTLS }}
48+
secretName: {{ $.Values.explicitTLS }}
49+
{{- end }}
50+
rules:
51+
{{- range $.Values.hosts }}
52+
- host: {{ . | quote }}
53+
http:
54+
paths:
55+
{{- range $contextPath }}
56+
- path: {{ . }}
57+
pathType: Prefix
58+
backend:
59+
service:
60+
name: {{ $serviceName }}
61+
port:
62+
number: {{ $servicePort }}
63+
{{- end }}
64+
{{- end }}
65+
{{- end }}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
# ingressClass: nginx
3+
4+
solution:
5+
component: ingress
6+
7+
servicePort: 80
8+
9+
hosts: []
10+
# - "cluster.example.com"
11+
12+
explicitTLS:
13+
14+
services: {}
15+
# - name: serviceA
16+
# port: 8081
17+
# useRewrite: true
18+
# contextPath:
19+
# - /
20+
# - name: serviceB
21+
# ingressClass: nginx
22+
# annotations:
23+
# nginx.ingress.kubernetes.io/proxy-body-size: 100m
24+
# nginx.ingress.kubernetes.io/use-regex: "false"
25+
# contextPath:
26+
# - /serviceB
27+
28+
# use rewrites
29+
# useRewrite: true
30+
# services:
31+
# - name: frontend
32+
# contextPath:
33+
# - ()(/.*)
34+
# - name: api
35+
# contextPath:
36+
# - (/api)(/.*)

0 commit comments

Comments
 (0)