csi: mount serviceaccount oidc-token into csi-driver

This oidc-token is used to authenticate with OpenID Connect (OIDC)
Provider. Currently, Ceph-CSI uses it to assume role with amazon STS
to get access to aws kms for encryption.

Signed-off-by: Rakshith R <rar@redhat.com>
This commit is contained in:
Rakshith R committed 2022-03-29 14:04:28 +05:30
1 parent 1569f39186
commit ec6f2e31b1
3 files changed
+39 -4

No files matched your search

+11 -4
View File
@@ -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
@@ -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 }}
@@ -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 }}