diff --git a/pkg/operator/ceph/csi/spec.go b/pkg/operator/ceph/csi/spec.go index 93b2bdd21..7c6fc1564 100644 --- a/pkg/operator/ceph/csi/spec.go +++ b/pkg/operator/ceph/csi/spec.go @@ -60,6 +60,7 @@ type Param struct { EnableVolumeReplicationSideCar bool EnableCSIAddonsSideCar bool MountCustomCephConf bool + EnableOIDCTokenProjection bool LogLevel uint8 CephFSGRPCMetricsPort uint16 CephFSLivenessMetricsPort uint16 @@ -130,10 +131,11 @@ var ( ) const ( - KubeMinMajor = "1" - kubeMinVerForSnapshot = "17" - kubeMinVerForV1csiDriver = "18" - kubeMaxVerForBeta1csiDriver = "21" + KubeMinMajor = "1" + kubeMinVerForSnapshot = "17" + KubeMinVerForOIDCTokenProjection = "20" + kubeMinVerForV1csiDriver = "18" + kubeMaxVerForBeta1csiDriver = "21" // common tolerations and node affinity provisionerTolerationsEnv = "CSI_PROVISIONER_TOLERATIONS" @@ -294,6 +296,11 @@ func (r *ReconcileCSI) startDrivers(ver *version.Info, ownerInfo *k8sutil.OwnerI tp.EnableOMAPGenerator = true } + // SA token projection is stable only from kubernetes version 1.20. + if ver.Major == KubeMinMajor && ver.Minor >= KubeMinVerForOIDCTokenProjection { + tp.EnableOIDCTokenProjection = true + } + // if k8s >= v1.17 enable RBD and CephFS snapshotter by default if ver.Major == KubeMinMajor && ver.Minor >= kubeMinVerForSnapshot { tp.EnableRBDSnapshotter = true diff --git a/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin-provisioner-dep.yaml b/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin-provisioner-dep.yaml index d4414c9b5..f0432742e 100644 --- a/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin-provisioner-dep.yaml +++ b/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin-provisioner-dep.yaml @@ -225,6 +225,11 @@ spec: mountPath: /etc/ceph/ceph.conf subPath: ceph.conf {{ end }} + {{ if .EnableOIDCTokenProjection }} + - name: oidc-token + mountPath: /run/secrets/tokens + readOnly: true + {{ end }} - name: liveness-prometheus image: {{ .CSIPluginImage }} args: @@ -286,3 +291,12 @@ spec: emptyDir: { medium: "Memory" } + {{ if .EnableOIDCTokenProjection }} + - name: oidc-token + projected: + sources: + - serviceAccountToken: + path: oidc-token + expirationSeconds: 3600 + audience: ceph-csi-kms + {{ end }} diff --git a/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin.yaml b/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin.yaml index ea616537b..eb3ec2f5c 100644 --- a/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin.yaml +++ b/pkg/operator/ceph/csi/template/rbd/csi-rbdplugin.yaml @@ -123,6 +123,11 @@ spec: mountPath: /etc/ceph/ceph.conf subPath: ceph.conf {{ end }} + {{ if .EnableOIDCTokenProjection }} + - name: oidc-token + mountPath: /run/secrets/tokens + readOnly: true + {{ end }} {{ if .EnableCSIAddonsSideCar }} - name: csi-addons securityContext: @@ -251,3 +256,12 @@ spec: - key: ceph.conf path: ceph.conf {{ end }} + {{ if .EnableOIDCTokenProjection }} + - name: oidc-token + projected: + sources: + - serviceAccountToken: + path: oidc-token + expirationSeconds: 3600 + audience: ceph-csi-kms + {{ end }}