diff --git a/charts/common/Chart.yaml b/charts/common/Chart.yaml index 52aacef5..e2287f1d 100644 --- a/charts/common/Chart.yaml +++ b/charts/common/Chart.yaml @@ -21,3 +21,8 @@ version: 0.11.1-beta.5 # incremented each time you make changes to the application. Versions are not expected to # follow Semantic Versioning. They should reflect the version the application is using. appVersion: 1.17.0 + +dependencies: +- name: ingress + version: 0.1.0 + repository: "file://./charts/ingress" diff --git a/charts/common/charts/ingress/.helmignore b/charts/common/charts/ingress/.helmignore new file mode 100644 index 00000000..0e8a0eb3 --- /dev/null +++ b/charts/common/charts/ingress/.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/common/charts/ingress/Chart.yaml b/charts/common/charts/ingress/Chart.yaml new file mode 100644 index 00000000..c9e26271 --- /dev/null +++ b/charts/common/charts/ingress/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: ingress +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 0.1.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.16.0" diff --git a/charts/common/templates/ingress.yaml b/charts/common/charts/ingress/templates/main.yaml similarity index 92% rename from charts/common/templates/ingress.yaml rename to charts/common/charts/ingress/templates/main.yaml index 22b9c9f7..c85e9ada 100644 --- a/charts/common/templates/ingress.yaml +++ b/charts/common/charts/ingress/templates/main.yaml @@ -1,7 +1,7 @@ -{{- if .Values.ingress.enabled -}} +{{- if .Values.enabled -}} {{- $labels := include "common.labels" . -}} -{{- $svcport := .Values.service.port -}} -{{- range .Values.ingress.hosts }} +{{- $svcport := .Values.fromCommon.service.port -}} +{{- range .Values.hosts }} {{- $hostwithdashes := printf "%s" .host | replace "." "-" -}} {{- $hostwithdashestls := printf "%s-tls" .host | replace "." "-" }} --- diff --git a/charts/common/charts/ingress/values.yaml b/charts/common/charts/ingress/values.yaml new file mode 100644 index 00000000..378f0445 --- /dev/null +++ b/charts/common/charts/ingress/values.yaml @@ -0,0 +1,27 @@ +enabled: false + + +fromCommon: + service: + port: 8080 + +hosts: + - host: chart-example.local + # The name is optional, If not set, a name is generated using host + # name: "" + annotations: + kubernetes.io/ingress.class: nginx-internal + kubernetes.io/tls-acme: "true" + paths: + - backend: + service: + name: chart-service + port: + number: + path: / + pathType: ImplementationSpecific + +tls: + - secretName: chart-example-tls + hosts: + - chart-example.local diff --git a/charts/common/schemas/ingress.schema.yaml b/charts/common/schemas/ingress.schema.yaml index 71c85155..868184f4 100644 --- a/charts/common/schemas/ingress.schema.yaml +++ b/charts/common/schemas/ingress.schema.yaml @@ -11,6 +11,12 @@ properties: enabled: type: boolean default: false + fromCommon: + type: object + properties: {} + global: + type: object + properties: {} hosts: type: array items: diff --git a/charts/common/templates/_helpers.tpl b/charts/common/templates/_helpers.tpl index 9b5535c7..ef76ecd8 100644 --- a/charts/common/templates/_helpers.tpl +++ b/charts/common/templates/_helpers.tpl @@ -4,7 +4,7 @@ Expand the name of the chart. */}} {{- define "common.name" -}} -{{- default .Release.Name ( required ".Values.name is missing, this can be caused by a mismatch in chart alias reference" .Values.name ) | trunc 63 | trimSuffix "-" }} +{{- default .Release.Name ( required ".Values.name is missing, this can be caused by a mismatch in chart alias reference" .Values.global.name ) | trunc 63 | trimSuffix "-" }} {{- end }} {{/* @@ -38,9 +38,9 @@ helm.sh/chart: {{ include "common.chart" . }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} -{{- if .Values.additionalLabels }} +{{- if .Values.global.additionalLabels }} {{- println "" }} - {{- toYaml .Values.additionalLabels }} + {{- toYaml .Values.global.additionalLabels }} {{- end }} {{- end }} diff --git a/charts/common/values.schema.json b/charts/common/values.schema.json index 39bb4dcf..40788192 100644 --- a/charts/common/values.schema.json +++ b/charts/common/values.schema.json @@ -610,6 +610,14 @@ "type": "boolean", "default": false }, + "fromCommon": { + "type": "object", + "properties": {} + }, + "global": { + "type": "object", + "properties": {} + }, "hosts": { "type": "array", "items": { diff --git a/charts/common/values.yaml b/charts/common/values.yaml index 84781245..d76d35c2 100644 --- a/charts/common/values.yaml +++ b/charts/common/values.yaml @@ -1,3 +1,10 @@ +global: + name: null + + # This is used to apply additional labels on deployment, pods and services + # to properly tag the team and environment + additionalLabels: {} + # Default values for common. # This is a YAML-formatted file. # Declare variables to be passed into your templates. @@ -649,11 +656,6 @@ verticalPodAutoscaler: podSelectorLabelsOverride: {} -# This is used to apply additional labels on deployment, pods and services -# to properly tag the team and environment - -additionalLabels: {} - # This section enables by default the topologySpreadConstraits to spread same deployment pods to multiple nodes # and multiple AZ when possible, rules are soft enforced by default. # The next are the only values that can be edited, labelSelector are set by the template.