| {{/* |
| Return the appropriate apiVersion for deployment or statefulset. |
| */}} |
| {{- define "apiVersion" -}} |
| {{- if and ($.Capabilities.APIVersions.Has "apps/v1") (semverCompare ">= 1.14-0" .Capabilities.KubeVersion.Version) }} |
| {{- print "apps/v1" }} |
| {{- else }} |
| {{- print "extensions/v1beta1" }} |
| {{- end }} |
| {{- end }} |
| |
| {{/* |
| Return the appropriate apiVersion for rbac. |
| */}} |
| {{- define "rbac.apiVersion" -}} |
| {{- if $.Capabilities.APIVersions.Has "rbac.authorization.k8s.io/v1" }} |
| {{- print "rbac.authorization.k8s.io/v1" }} |
| {{- else }} |
| {{- print "rbac.authorization.k8s.io/v1beta1" }} |
| {{- end }} |
| {{- end }} |
| |
| {{/* |
| Return the appropriate apiVersion for networkpolicy. |
| */}} |
| {{- define "networkpolicy.apiVersion" -}} |
| {{- if $.Capabilities.APIVersions.Has "networking.k8s.io/v1/NetworkPolicy" }} |
| {{- print "networking.k8s.io/v1" }} |
| {{- else }} |
| {{- print "extensions/v1beta1" }} |
| {{- end }} |
| {{- end }} |
| |
| {{/* |
| Return the appropriate apiVersion for podDisruptionBudget. |
| */}} |
| {{- define "poddisruptionbudget.apiVersion" -}} |
| {{- if $.Capabilities.APIVersions.Has "policy/v1/PodDisruptionBudget" }} |
| {{- print "policy/v1" }} |
| {{- else }} |
| {{- print "policy/v1beta1" }} |
| {{- end }} |
| {{- end }} |
| |
| {{/* |
| Return the appropriate apiVersion for ingress. |
| */}} |
| {{- define "network.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 }} |