Skip to content

Commit

Permalink
Update CSI driver to v3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
laozc committed Sep 19, 2023
1 parent 21665a2 commit e3b2dc3
Show file tree
Hide file tree
Showing 8 changed files with 2,892 additions and 909 deletions.
710 changes: 590 additions & 120 deletions packaging/flavorgen/cloudprovider/csi.go

Large diffs are not rendered by default.

99 changes: 45 additions & 54 deletions packaging/flavorgen/flavors/crs/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,6 @@ import (
"fmt"

"github.com/pkg/errors"
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
rbac "k8s.io/api/rbac/v1"
storagev1 "k8s.io/api/storage/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
addonsv1 "sigs.k8s.io/cluster-api/exp/addons/api/v1beta1"

Expand All @@ -36,76 +31,70 @@ import (
// CreateCrsResourceObjectsCSI creates the api objects necessary for CSI to function.
// Also appends the resources to the CRS.
func CreateCrsResourceObjectsCSI(crs *addonsv1.ClusterResourceSet) []runtime.Object {
serviceAccount := cloudprovider.CSIControllerServiceAccount()
serviceAccount.TypeMeta = metav1.TypeMeta{
Kind: "ServiceAccount",
APIVersion: corev1.SchemeGroupVersion.String(),
}
serviceAccountSecret := newSecret(serviceAccount.Name, serviceAccount)
appendSecretToCrsResource(crs, serviceAccountSecret)
var objs []runtime.Object

clusterRole := cloudprovider.CSIControllerClusterRole()
clusterRole.TypeMeta = metav1.TypeMeta{
Kind: "ClusterRole",
APIVersion: rbac.SchemeGroupVersion.String(),
}
clusterRoleConfigMap := newConfigMap(clusterRole.Name, clusterRole)
appendConfigMapToCrsResource(crs, clusterRoleConfigMap)
csiNamespace := cloudprovider.CSIDriverNamespace()
objs = append(objs, csiNamespace)

clusterRoleBinding := cloudprovider.CSIControllerClusterRoleBinding()
clusterRoleBinding.TypeMeta = metav1.TypeMeta{
Kind: "ClusterRoleBinding",
APIVersion: rbac.SchemeGroupVersion.String(),
}
clusterRoleBindingConfigMap := newConfigMap(clusterRoleBinding.Name, clusterRoleBinding)
appendConfigMapToCrsResource(crs, clusterRoleBindingConfigMap)
controllerServiceAccount := cloudprovider.CSIControllerServiceAccount()
controllerServiceAccountSecret := newSecret(controllerServiceAccount.Name, controllerServiceAccount)
appendSecretToCrsResource(crs, controllerServiceAccountSecret)

controllerClusterRole := cloudprovider.CSIControllerClusterRole()
objs = append(objs, controllerClusterRole)

controllerClusterRoleBinding := cloudprovider.CSIControllerClusterRoleBinding()
objs = append(objs, controllerClusterRoleBinding)

nodeDaemonSetServiceAccount := cloudprovider.CSINodeDaemonSetServiceAccount()
nodeDaemonSetServiceAccountSecret := newSecret(nodeDaemonSetServiceAccount.Name, nodeDaemonSetServiceAccount)
appendSecretToCrsResource(crs, nodeDaemonSetServiceAccountSecret)

nodeRole := cloudprovider.CSINodeRole()
objs = append(objs, nodeRole)

nodeRoleBinding := cloudprovider.CSINodeRoleBinding()
objs = append(objs, nodeRoleBinding)

nodeClusterRole := cloudprovider.CSINodeClusterRole()
objs = append(objs, nodeClusterRole)

nodeClusterRoleBinding := cloudprovider.CSINodeClusterRoleBinding()
objs = append(objs, nodeClusterRoleBinding)

cloudConfig, err := ConfigForCSI().MarshalINI()
if err != nil {
panic(errors.Errorf("invalid cloudConfig"))
}
// cloud config secret is wrapped in another secret so it could be injected via CRS
cloudConfigSecret := cloudprovider.CSICloudConfigSecret(string(cloudConfig))
cloudConfigSecret.TypeMeta = metav1.TypeMeta{
Kind: "Secret",
APIVersion: corev1.SchemeGroupVersion.String(),
}
cloudConfigSecretWrapper := newSecret(cloudConfigSecret.Name, cloudConfigSecret)
appendSecretToCrsResource(crs, cloudConfigSecretWrapper)

csiDriver := cloudprovider.CSIDriver()
csiDriver.TypeMeta = metav1.TypeMeta{
Kind: "CSIDriver",
APIVersion: storagev1.SchemeGroupVersion.String(),
}
csiDriverConfigMap := newConfigMap(csiDriver.Name, csiDriver)
appendConfigMapToCrsResource(crs, csiDriverConfigMap)
objs = append(objs, csiDriver)

storageConfig := createStorageConfig()
daemonSet := cloudprovider.VSphereCSINodeDaemonSet(storageConfig)
daemonSet.TypeMeta = metav1.TypeMeta{
Kind: "DaemonSet",
APIVersion: appsv1.SchemeGroupVersion.String(),
}
daemonSetConfigMap := newConfigMap(daemonSet.Name, daemonSet)
appendConfigMapToCrsResource(crs, daemonSetConfigMap)
objs = append(objs, daemonSet)

deployment := cloudprovider.CSIControllerDeployment(storageConfig)
deployment.TypeMeta = metav1.TypeMeta{
Kind: "Deployment",
APIVersion: appsv1.SchemeGroupVersion.String(),
}
deploymentConfigMap := newConfigMap(deployment.Name, deployment)
appendConfigMapToCrsResource(crs, deploymentConfigMap)
objs = append(objs, deployment)

csiService := cloudprovider.CSIControllerService()
objs = append(objs, csiService)

csiFeatureStates := cloudprovider.CSIFeatureStatesConfigMap()
objs = append(objs, csiFeatureStates)

manifestConfigMap := newConfigMapManifests("csi-manifests", objs)
appendConfigMapToCrsResource(crs, manifestConfigMap)

return []runtime.Object{
serviceAccountSecret,
clusterRoleConfigMap,
clusterRoleBindingConfigMap,
controllerServiceAccountSecret,
nodeDaemonSetServiceAccountSecret,
cloudConfigSecretWrapper,
csiDriverConfigMap,
daemonSetConfigMap,
deploymentConfigMap,
manifestConfigMap,
}
}

Expand All @@ -115,7 +104,9 @@ func createStorageConfig() *types.CPIStorageConfig {
ControllerImage: cloudprovider.DefaultCSIControllerImage,
NodeDriverImage: cloudprovider.DefaultCSINodeDriverImage,
AttacherImage: cloudprovider.DefaultCSIAttacherImage,
ResizerImage: cloudprovider.DefaultCSIResizerImage,
ProvisionerImage: cloudprovider.DefaultCSIProvisionerImage,
SnapshotterImage: cloudprovider.DefaultCSISnapshotterContainerImage,
MetadataSyncerImage: cloudprovider.DefaultCSIMetadataSyncerImage,
LivenessProbeImage: cloudprovider.DefaultCSILivenessProbeImage,
RegistrarImage: cloudprovider.DefaultCSIRegistrarImage,
Expand Down
2 changes: 2 additions & 0 deletions packaging/flavorgen/flavors/crs/types/cloudprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,9 @@ type CPIStorageConfig struct {
ControllerImage string `json:"controllerImage,omitempty"`
NodeDriverImage string `json:"nodeDriverImage,omitempty"`
AttacherImage string `json:"attacherImage,omitempty"`
ResizerImage string `json:"resizerImage,omitempty"`
ProvisionerImage string `json:"provisionerImage,omitempty"`
SnapshotterImage string `json:"snapshotterImage,omitempty"`
MetadataSyncerImage string `json:"metadataSyncerImage,omitempty"`
LivenessProbeImage string `json:"livenessProbeImage,omitempty"`
RegistrarImage string `json:"registrarImage,omitempty"`
Expand Down
Loading

0 comments on commit e3b2dc3

Please sign in to comment.