Skip to content

Commit

Permalink
Add comet-ingress (#106)
Browse files Browse the repository at this point in the history
* Add comet-ingress

* Use correct plural naming
  • Loading branch information
fraxachun authored Sep 5, 2024
1 parent ffce7fa commit 6ae395f
Show file tree
Hide file tree
Showing 7 changed files with 190 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .changeset/short-avocados-destroy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"comet-ingress-v1": major
---

Add `comet-ingress` chart

Provides a centralized configuration for ingresses to avoid confusion on which ingress should point to which service.
23 changes: 23 additions & 0 deletions charts/comet-ingress-v1/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
19 changes: 19 additions & 0 deletions charts/comet-ingress-v1/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v2
name: comet-ingress
description: Helm chart for Ingresses on COMET-Microservices
type: application

home: https://www.comet-dxp.com
icon: https://avatars.githubusercontent.com/u/1012348?s=200&v=4

maintainers:
- name: Daniel Karnutsch
email: daniel.karnutsch@vivid-planet.com
- name: Georg Schreglmann
email: georg.schreglmann@vivid-planet.com
- name: Franz Unger
email: franz.unger@vivid-planet.com
- name: Alexander Kaufmann
email: alexander.kaufmann@vivid-planet.com

version: 0.0.0
5 changes: 5 additions & 0 deletions charts/comet-ingress-v1/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "comet-ingress-v1",
"private": true,
"version": "0.0.0"
}
62 changes: 62 additions & 0 deletions charts/comet-ingress-v1/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "comet-ingress.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "comet-ingress.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "comet-ingress.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "comet-ingress.labels" -}}
helm.sh/chart: {{ include "comet-ingress.chart" . }}
{{ include "comet-ingress.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "comet-ingress.selectorLabels" -}}
app.kubernetes.io/name: {{ include "comet-ingress.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "comet-ingress.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "comet-ingress.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
49 changes: 49 additions & 0 deletions charts/comet-ingress-v1/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
{{- range $index, $i := .Values.ingresses }}
{{ if or (kindIs "string" $i.hostname) (gt (len $i.hostname) 0) }}
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "comet-ingress.fullname" $ }}-{{ $index }}
labels:
{{- include "comet-ingress.labels" $ | nindent 4 }}
annotations:
{{- range $key, $val := $.Values.annotations }}
{{ $key }}: {{ $val | quote }}
{{- end }}
spec:
ingressClassName: nginx
rules:
{{- if kindIs "slice" $i.hostname }}
{{- range $k := $i.hostname }}
- host: {{ $k }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
{{ $i.service | toYaml | nindent 12 }}
{{- end }}
{{- else }}
- host: {{ $i.hostname }}
http:
paths:
- path: /
pathType: Prefix
backend:
service:
{{ $i.service | toYaml | nindent 12 }}
{{- end }}
tls:
- hosts:
{{- if kindIs "slice" $i.hostname }}
{{- range $k := $i.hostname }}
- {{ $k }}
{{- end }}
{{- else }}
- {{ $i.hostname }}
{{- end }}
secretName: {{ $i.service.name }}-cert
{{- end }}
{{- end }}
25 changes: 25 additions & 0 deletions charts/comet-ingress-v1/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Default values for comet-ingress.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

annotations:
cert-manager.io/cluster-issuer: "letsencrypt"
nginx.ingress.kubernetes.io/proxy-buffer-size: "8k"

# Example Ingress configuration:
# ingresses:
# - hostname: admin.comet-dxp.com
# service:
# name: comet-oauth2-proxy
# port:
# number: 3000
# - hostname: preview.comet-dxp.com
# service:
# name: comet-oauth2-proxy-preview
# port:
# number: 3000
# - hostname: ["site.comet-dxp.com"]
# service:
# name: comet-site
# port:
# number: 3000

0 comments on commit 6ae395f

Please sign in to comment.