diff --git a/.changeset/short-avocados-destroy.md b/.changeset/short-avocados-destroy.md new file mode 100644 index 0000000..4aabc3f --- /dev/null +++ b/.changeset/short-avocados-destroy.md @@ -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. \ No newline at end of file diff --git a/charts/comet-ingress-v1/.helmignore b/charts/comet-ingress-v1/.helmignore new file mode 100644 index 0000000..0e8a0eb --- /dev/null +++ b/charts/comet-ingress-v1/.helmignore @@ -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/ diff --git a/charts/comet-ingress-v1/Chart.yaml b/charts/comet-ingress-v1/Chart.yaml new file mode 100644 index 0000000..931dd54 --- /dev/null +++ b/charts/comet-ingress-v1/Chart.yaml @@ -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 diff --git a/charts/comet-ingress-v1/package.json b/charts/comet-ingress-v1/package.json new file mode 100644 index 0000000..3ddf76a --- /dev/null +++ b/charts/comet-ingress-v1/package.json @@ -0,0 +1,5 @@ +{ + "name": "comet-ingress-v1", + "private": true, + "version": "0.0.0" +} diff --git a/charts/comet-ingress-v1/templates/_helpers.tpl b/charts/comet-ingress-v1/templates/_helpers.tpl new file mode 100644 index 0000000..78597f0 --- /dev/null +++ b/charts/comet-ingress-v1/templates/_helpers.tpl @@ -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 }} diff --git a/charts/comet-ingress-v1/templates/ingress.yaml b/charts/comet-ingress-v1/templates/ingress.yaml new file mode 100644 index 0000000..780f9c8 --- /dev/null +++ b/charts/comet-ingress-v1/templates/ingress.yaml @@ -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 }} diff --git a/charts/comet-ingress-v1/values.yaml b/charts/comet-ingress-v1/values.yaml new file mode 100644 index 0000000..f7c722f --- /dev/null +++ b/charts/comet-ingress-v1/values.yaml @@ -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