Merge "[AAI] Add model-loader tracing config"
[oom.git] / kubernetes / common / mongodb / common / templates / _ingress.tpl
1 {{/*
2 Copyright VMware, Inc.
3 SPDX-License-Identifier: APACHE-2.0
4 */}}
5
6 {{/* vim: set filetype=mustache: */}}
7
8 {{/*
9 Generate backend entry that is compatible with all Kubernetes API versions.
10
11 Usage:
12 {{ include "common.ingress.backend" (dict "serviceName" "backendName" "servicePort" "backendPort" "context" $) }}
13
14 Params:
15   - serviceName - String. Name of an existing service backend
16   - 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.
17   - context - Dict - Required. The context for the template evaluation.
18 */}}
19 {{- define "common.ingress.backend" -}}
20 {{- $apiVersion := (include "common.capabilities.ingress.apiVersion" .context) -}}
21 {{- if or (eq $apiVersion "extensions/v1beta1") (eq $apiVersion "networking.k8s.io/v1beta1") -}}
22 serviceName: {{ .serviceName }}
23 servicePort: {{ .servicePort }}
24 {{- else -}}
25 service:
26   name: {{ .serviceName }}
27   port:
28     {{- if typeIs "string" .servicePort }}
29     name: {{ .servicePort }}
30     {{- else if or (typeIs "int" .servicePort) (typeIs "float64" .servicePort) }}
31     number: {{ .servicePort | int }}
32     {{- end }}
33 {{- end -}}
34 {{- end -}}
35
36 {{/*
37 Print "true" if the API pathType field is supported
38 Usage:
39 {{ include "common.ingress.supportsPathType" . }}
40 */}}
41 {{- define "common.ingress.supportsPathType" -}}
42 {{- if (semverCompare "<1.18-0" (include "common.capabilities.kubeVersion" .)) -}}
43 {{- print "false" -}}
44 {{- else -}}
45 {{- print "true" -}}
46 {{- end -}}
47 {{- end -}}
48
49 {{/*
50 Returns true if the ingressClassname field is supported
51 Usage:
52 {{ include "common.ingress.supportsIngressClassname" . }}
53 */}}
54 {{- define "common.ingress.supportsIngressClassname" -}}
55 {{- if semverCompare "<1.18-0" (include "common.capabilities.kubeVersion" .) -}}
56 {{- print "false" -}}
57 {{- else -}}
58 {{- print "true" -}}
59 {{- end -}}
60 {{- end -}}
61
62 {{/*
63 Return true if cert-manager required annotations for TLS signed
64 certificates are set in the Ingress annotations
65 Ref: https://cert-manager.io/docs/usage/ingress/#supported-annotations
66 Usage:
67 {{ include "common.ingress.certManagerRequest" ( dict "annotations" .Values.path.to.the.ingress.annotations ) }}
68 */}}
69 {{- define "common.ingress.certManagerRequest" -}}
70 {{ if or (hasKey .annotations "cert-manager.io/cluster-issuer") (hasKey .annotations "cert-manager.io/issuer") (hasKey .annotations "kubernetes.io/tls-acme") }}
71     {{- true -}}
72 {{- end -}}
73 {{- end -}}