diff --git a/charts/k8s-resources/.helmignore b/charts/k8s-resources/.helmignore new file mode 100644 index 0000000..fa84c3b --- /dev/null +++ b/charts/k8s-resources/.helmignore @@ -0,0 +1,22 @@ +# 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 +*~ +# Various IDEs +.project +.idea/ +*.tmproj +.vscode diff --git a/charts/k8s-resources/Chart.yaml b/charts/k8s-resources/Chart.yaml new file mode 100644 index 0000000..de12de8 --- /dev/null +++ b/charts/k8s-resources/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +version: 1.0.0 +appVersion: 1.0.0 +type: library +name: k8s-resources +description: K8s resources diff --git a/charts/k8s-resources/templates/_ingress.tpl b/charts/k8s-resources/templates/_ingress.tpl new file mode 100644 index 0000000..1b7ace9 --- /dev/null +++ b/charts/k8s-resources/templates/_ingress.tpl @@ -0,0 +1,33 @@ +{{/* +Return the appropriate apiVersion for ingress. +*/}} +{{- define "k8s.ingress.apiVersion" -}} + {{- if and (.Capabilities.APIVersions.Has "networking.k8s.io/v1") (semverCompare ">= 1.19-0" .Capabilities.KubeVersion.Version) -}} + {{- print "networking.k8s.io/v1" -}} + {{- else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" -}} + {{- print "networking.k8s.io/v1beta1" -}} + {{- else -}} + {{- print "extensions/v1beta1" -}} + {{- end -}} +{{- end -}} + +{{/* +Return if ingress is stable. +*/}} +{{- define "k8s.ingress.isStable" -}} + {{- eq (include "k8s.ingress.apiVersion" .) "networking.k8s.io/v1" -}} +{{- end -}} + +{{/* +Return if ingress supports ingressClassName. +*/}} +{{- define "k8s.ingress.supportsIngressClassName" -}} + {{- or (eq (include "k8s.ingress.isStable" .) "true") (and (eq (include "k8s.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}} +{{- end -}} + +{{/* +Return if ingress supports pathType. +*/}} +{{- define "k8s.ingress.supportsPathType" -}} + {{- or (eq (include "k8s.ingress.isStable" .) "true") (and (eq (include "k8s.ingress.apiVersion" .) "networking.k8s.io/v1beta1") (semverCompare ">= 1.18-0" .Capabilities.KubeVersion.Version)) -}} +{{- end -}}