diff --git a/Documentation/helm-ceph-cluster.md b/Documentation/helm-ceph-cluster.md index 07fc35a4a88e..ff37077489be 100644 --- a/Documentation/helm-ceph-cluster.md +++ b/Documentation/helm-ceph-cluster.md @@ -57,6 +57,7 @@ The following tables lists the configurable parameters of the rook-operator char | Parameter | Description | Default | | ---------------------- | -------------------------------------------------------------------- | ----------- | | `operatorNamespace` | Namespace of the Rook Operator | `rook-ceph` | +| `kubeVersion` | Optional override of the target kubernetes version | `` | | `configOverride` | Cluster ceph.conf override | | | `toolbox.enabled` | Enable Ceph debugging pod deployment. See [toolbox](ceph-toolbox.md) | `false` | | `toolbox.tolerations` | Toolbox tolerations | `[]` | diff --git a/cluster/charts/rook-ceph-cluster/templates/_helpers.tpl b/cluster/charts/rook-ceph-cluster/templates/_helpers.tpl index 8a7cf525d6a0..f7f5e2760a0b 100644 --- a/cluster/charts/rook-ceph-cluster/templates/_helpers.tpl +++ b/cluster/charts/rook-ceph-cluster/templates/_helpers.tpl @@ -31,3 +31,23 @@ Define the clusterName as defaulting to the release namespace {{- define "clusterName" -}} {{ .Values.clusterName | default .Release.Namespace }} {{- end -}} + +{{/* +Return the target Kubernetes version. +*/}} +{{- define "capabilities.kubeVersion" -}} +{{- default .Capabilities.KubeVersion.Version .Values.kubeVersion -}} +{{- end -}} + +{{/* +Return the appropriate apiVersion for ingress. +*/}} +{{- define "capabilities.ingress.apiVersion" -}} +{{- if semverCompare "<1.14-0" (include "capabilities.kubeVersion" .) -}} +{{- print "extensions/v1beta1" -}} +{{- else if semverCompare "<1.19-0" (include "capabilities.kubeVersion" .) -}} +{{- print "networking.k8s.io/v1beta1" -}} +{{- else -}} +{{- print "networking.k8s.io/v1" -}} +{{- end -}} +{{- end -}} diff --git a/cluster/charts/rook-ceph-cluster/templates/ingress.yaml b/cluster/charts/rook-ceph-cluster/templates/ingress.yaml index d665de5f28fd..078693288b93 100644 --- a/cluster/charts/rook-ceph-cluster/templates/ingress.yaml +++ b/cluster/charts/rook-ceph-cluster/templates/ingress.yaml @@ -1,12 +1,6 @@ {{- if .Values.ingress.dashboard.host }} --- -{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" }} -apiVersion: networking.k8s.io/v1 -{{ else if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1" }} -apiVersion: networking.k8s.io/v1beta1 -{{ else }} -apiVersion: extensions/v1beta1 -{{ end -}} +apiVersion: {{ include "capabilities.ingress.apiVersion" . }} kind: Ingress metadata: name: {{ template "clusterName" . }}-dashboard @@ -20,7 +14,14 @@ spec: paths: - path: {{ .Values.ingress.dashboard.host.path | default "/" }} backend: -{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" }} +{{- if (semverCompare "<1.18-0" (include "capabilities.kubeVersion" .)) }} + serviceName: rook-ceph-mgr-dashboard + {{- if .Values.cephClusterSpec.dashboard.ssl }} + servicePort: https-dashboard + {{- else }} + servicePort: http-dashboard + {{- end }} +{{- else }} service: name: rook-ceph-mgr-dashboard port: @@ -30,13 +31,6 @@ spec: name: http-dashboard {{- end }} pathType: Prefix -{{- else }} - serviceName: rook-ceph-mgr-dashboard - {{- if .Values.cephClusterSpec.dashboard.ssl }} - servicePort: https-dashboard - {{- else }} - servicePort: http-dashboard - {{- end }} {{- end }} {{- if .Values.ingress.dashboard.tls }} tls: {{- toYaml .Values.ingress.dashboard.tls | nindent 4 }} diff --git a/cluster/charts/rook-ceph-cluster/values.yaml b/cluster/charts/rook-ceph-cluster/values.yaml index 5a878fb941b3..48c221b4608e 100644 --- a/cluster/charts/rook-ceph-cluster/values.yaml +++ b/cluster/charts/rook-ceph-cluster/values.yaml @@ -8,6 +8,9 @@ operatorNamespace: rook-ceph # The metadata.name of the CephCluster CR. The default name is the same as the namespace. # clusterName: rook-ceph +# Ability to override the kubernetes version used in rendering the helm chart +# kubeVersion: 1.21 + # Ability to override ceph.conf # configOverride: | # [global]