-
Notifications
You must be signed in to change notification settings - Fork 270
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[AMORO-2938] Add common dependency chart (#2939)
* [AMORO-2938] Add common dependency chart * move files to common folder
- Loading branch information
Showing
9 changed files
with
422 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
{{/* | ||
Copyright VMware, Inc. | ||
SPDX-License-Identifier: APACHE-2.0 | ||
// This file under the http://www.apache.org/licenses/LICENSE-2.0, copied from | ||
// https://github.com/bitnami/charts/blob/common/2.11.1/bitnami/common/templates/_capabilities.tpl | ||
*/}} | ||
|
||
{{/* vim: set filetype=mustache: */}} | ||
|
||
{{/* | ||
Return the target Kubernetes version | ||
*/}} | ||
{{- define "common.capabilities.kubeVersion" -}} | ||
{{- if .Values.global }} | ||
{{- if .Values.global.kubeVersion }} | ||
{{- .Values.global.kubeVersion -}} | ||
{{- else }} | ||
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}} | ||
{{- end -}} | ||
{{- else }} | ||
{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the appropriate apiVersion for poddisruptionbudget. | ||
*/}} | ||
{{- define "common.capabilities.policy.apiVersion" -}} | ||
{{- if semverCompare "<1.21-0" (include "common.capabilities.kubeVersion" .) -}} | ||
{{- print "policy/v1beta1" -}} | ||
{{- else -}} | ||
{{- print "policy/v1" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the appropriate apiVersion for networkpolicy. | ||
*/}} | ||
{{- define "common.capabilities.networkPolicy.apiVersion" -}} | ||
{{- if semverCompare "<1.7-0" (include "common.capabilities.kubeVersion" .) -}} | ||
{{- print "extensions/v1beta1" -}} | ||
{{- else -}} | ||
{{- print "networking.k8s.io/v1" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the appropriate apiVersion for cronjob. | ||
*/}} | ||
{{- define "common.capabilities.cronjob.apiVersion" -}} | ||
{{- if semverCompare "<1.21-0" (include "common.capabilities.kubeVersion" .) -}} | ||
{{- print "batch/v1beta1" -}} | ||
{{- else -}} | ||
{{- print "batch/v1" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the appropriate apiVersion for daemonset. | ||
*/}} | ||
{{- define "common.capabilities.daemonset.apiVersion" -}} | ||
{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}} | ||
{{- print "extensions/v1beta1" -}} | ||
{{- else -}} | ||
{{- print "apps/v1" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the appropriate apiVersion for deployment. | ||
*/}} | ||
{{- define "common.capabilities.deployment.apiVersion" -}} | ||
{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}} | ||
{{- print "extensions/v1beta1" -}} | ||
{{- else -}} | ||
{{- print "apps/v1" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the appropriate apiVersion for statefulset. | ||
*/}} | ||
{{- define "common.capabilities.statefulset.apiVersion" -}} | ||
{{- if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}} | ||
{{- print "apps/v1beta1" -}} | ||
{{- else -}} | ||
{{- print "apps/v1" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the appropriate apiVersion for ingress. | ||
*/}} | ||
{{- define "common.capabilities.ingress.apiVersion" -}} | ||
{{- if .Values.ingress -}} | ||
{{- if .Values.ingress.apiVersion -}} | ||
{{- .Values.ingress.apiVersion -}} | ||
{{- else if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}} | ||
{{- print "extensions/v1beta1" -}} | ||
{{- else if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}} | ||
{{- print "networking.k8s.io/v1beta1" -}} | ||
{{- else -}} | ||
{{- print "networking.k8s.io/v1" -}} | ||
{{- end }} | ||
{{- else if semverCompare "<1.14-0" (include "common.capabilities.kubeVersion" .) -}} | ||
{{- print "extensions/v1beta1" -}} | ||
{{- else if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}} | ||
{{- print "networking.k8s.io/v1beta1" -}} | ||
{{- else -}} | ||
{{- print "networking.k8s.io/v1" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the appropriate apiVersion for RBAC resources. | ||
*/}} | ||
{{- define "common.capabilities.rbac.apiVersion" -}} | ||
{{- if semverCompare "<1.17-0" (include "common.capabilities.kubeVersion" .) -}} | ||
{{- print "rbac.authorization.k8s.io/v1beta1" -}} | ||
{{- else -}} | ||
{{- print "rbac.authorization.k8s.io/v1" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the appropriate apiVersion for CRDs. | ||
*/}} | ||
{{- define "common.capabilities.crd.apiVersion" -}} | ||
{{- if semverCompare "<1.19-0" (include "common.capabilities.kubeVersion" .) -}} | ||
{{- print "apiextensions.k8s.io/v1beta1" -}} | ||
{{- else -}} | ||
{{- print "apiextensions.k8s.io/v1" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the appropriate apiVersion for APIService. | ||
*/}} | ||
{{- define "common.capabilities.apiService.apiVersion" -}} | ||
{{- if semverCompare "<1.10-0" (include "common.capabilities.kubeVersion" .) -}} | ||
{{- print "apiregistration.k8s.io/v1beta1" -}} | ||
{{- else -}} | ||
{{- print "apiregistration.k8s.io/v1" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the appropriate apiVersion for Horizontal Pod Autoscaler. | ||
*/}} | ||
{{- define "common.capabilities.hpa.apiVersion" -}} | ||
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .context) -}} | ||
{{- if .beta2 -}} | ||
{{- print "autoscaling/v2beta2" -}} | ||
{{- else -}} | ||
{{- print "autoscaling/v2beta1" -}} | ||
{{- end -}} | ||
{{- else -}} | ||
{{- print "autoscaling/v2" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return the appropriate apiVersion for Vertical Pod Autoscaler. | ||
*/}} | ||
{{- define "common.capabilities.vpa.apiVersion" -}} | ||
{{- if semverCompare "<1.23-0" (include "common.capabilities.kubeVersion" .context) -}} | ||
{{- if .beta2 -}} | ||
{{- print "autoscaling/v2beta2" -}} | ||
{{- else -}} | ||
{{- print "autoscaling/v2beta1" -}} | ||
{{- end -}} | ||
{{- else -}} | ||
{{- print "autoscaling/v2" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Returns true if the used Helm version is 3.3+. | ||
A way to check the used Helm version was not introduced until version 3.3.0 with .Capabilities.HelmVersion, which contains an additional "{}}" structure. | ||
This check is introduced as a regexMatch instead of {{ if .Capabilities.HelmVersion }} because checking for the key HelmVersion in <3.3 results in a "interface not found" error. | ||
**To be removed when the catalog's minimun Helm version is 3.3** | ||
*/}} | ||
{{- define "common.capabilities.supportsHelmVersion" -}} | ||
{{- if regexMatch "{(v[0-9])*[^}]*}}$" (.Capabilities | toString ) }} | ||
{{- true -}} | ||
{{- end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
{{/* | ||
Copyright VMware, Inc. | ||
SPDX-License-Identifier: APACHE-2.0 | ||
// This file under the http://www.apache.org/licenses/LICENSE-2.0, copied from | ||
// https://github.com/bitnami/charts/blob/common/2.11.1/bitnami/common/templates/_ingress.tpl | ||
*/}} | ||
|
||
{{/* vim: set filetype=mustache: */}} | ||
|
||
{{/* | ||
Generate backend entry that is compatible with all Kubernetes API versions. | ||
Usage: | ||
{{ include "common.ingress.backend" (dict "serviceName" "backendName" "servicePort" "backendPort" "context" $) }} | ||
|
||
Params: | ||
- serviceName - String. Name of an existing service backend | ||
- servicePort - String/Int. Port name (or number) of the service. It will be translated to different yaml depending if it is a string or an integer. | ||
- context - Dict - Required. The context for the template evaluation. | ||
*/}} | ||
{{- define "common.ingress.backend" -}} | ||
{{- $apiVersion := (include "common.capabilities.ingress.apiVersion" .context) -}} | ||
{{- if or (eq $apiVersion "extensions/v1beta1") (eq $apiVersion "networking.k8s.io/v1beta1") -}} | ||
serviceName: {{ .serviceName }} | ||
servicePort: {{ .servicePort }} | ||
{{- else -}} | ||
service: | ||
name: {{ .serviceName }} | ||
port: | ||
{{- if typeIs "string" .servicePort }} | ||
name: {{ .servicePort }} | ||
{{- else if or (typeIs "int" .servicePort) (typeIs "float64" .servicePort) }} | ||
number: {{ .servicePort | int }} | ||
{{- end }} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Print "true" if the API pathType field is supported | ||
Usage: | ||
{{ include "common.ingress.supportsPathType" . }} | ||
*/}} | ||
{{- define "common.ingress.supportsPathType" -}} | ||
{{- if (semverCompare "<1.18-0" (include "common.capabilities.kubeVersion" .)) -}} | ||
{{- print "false" -}} | ||
{{- else -}} | ||
{{- print "true" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Returns true if the ingressClassname field is supported | ||
Usage: | ||
{{ include "common.ingress.supportsIngressClassname" . }} | ||
*/}} | ||
{{- define "common.ingress.supportsIngressClassname" -}} | ||
{{- if semverCompare "<1.18-0" (include "common.capabilities.kubeVersion" .) -}} | ||
{{- print "false" -}} | ||
{{- else -}} | ||
{{- print "true" -}} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Return true if cert-manager required annotations for TLS signed | ||
certificates are set in the Ingress annotations | ||
Ref: https://cert-manager.io/docs/usage/ingress/#supported-annotations | ||
Usage: | ||
{{ include "common.ingress.certManagerRequest" ( dict "annotations" .Values.path.to.the.ingress.annotations ) }} | ||
*/}} | ||
{{- define "common.ingress.certManagerRequest" -}} | ||
{{ if or (hasKey .annotations "cert-manager.io/cluster-issuer") (hasKey .annotations "cert-manager.io/issuer") (hasKey .annotations "kubernetes.io/tls-acme") }} | ||
{{- true -}} | ||
{{- end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{{/* | ||
Copyright VMware, Inc. | ||
SPDX-License-Identifier: APACHE-2.0 | ||
// This file under the http://www.apache.org/licenses/LICENSE-2.0, copied from | ||
// https://github.com/bitnami/charts/blob/common/2.11.1/bitnami/common/templates/_labels.tpl | ||
*/}} | ||
|
||
{{/* vim: set filetype=mustache: */}} | ||
|
||
{{/* | ||
Kubernetes standard labels | ||
{{ include "common.labels.standard" (dict "customLabels" .Values.commonLabels "context" $) -}} | ||
*/}} | ||
{{- define "common.labels.standard" -}} | ||
{{- if and (hasKey . "customLabels") (hasKey . "context") -}} | ||
{{ merge (include "common.tplvalues.render" (dict "value" .customLabels "context" .context) | fromYaml) (dict "app.kubernetes.io/name" (include "common.names.name" .context) "helm.sh/chart" (include "common.names.chart" .context) "app.kubernetes.io/instance" .context.Release.Name "app.kubernetes.io/managed-by" .context.Release.Service "app.kubernetes.io/version" .context.Chart.AppVersion) | toYaml }} | ||
{{- else -}} | ||
app.kubernetes.io/name: {{ include "common.names.name" . }} | ||
helm.sh/chart: {{ include "common.names.chart" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Labels used on immutable fields such as deploy.spec.selector.matchLabels or svc.spec.selector | ||
{{ include "common.labels.matchLabels" (dict "customLabels" .Values.podLabels "context" $) -}} | ||
|
||
We don't want to loop over custom labels appending them to the selector | ||
since it's very likely that it will break deployments, services, etc. | ||
However, it's important to overwrite the standard labels if the user | ||
overwrote them on metadata.labels fields. | ||
*/}} | ||
{{- define "common.labels.matchLabels" -}} | ||
{{- if and (hasKey . "customLabels") (hasKey . "context") -}} | ||
{{ merge (pick (include "common.tplvalues.render" (dict "value" .customLabels "context" .context) | fromYaml) "app.kubernetes.io/name" "app.kubernetes.io/instance") (dict "app.kubernetes.io/name" (include "common.names.name" .context) "app.kubernetes.io/instance" .context.Release.Name ) | toYaml }} | ||
{{- else -}} | ||
app.kubernetes.io/name: {{ include "common.names.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end -}} | ||
{{- end -}} |
Oops, something went wrong.