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 17, 2023
1 parent 21665a2 commit 05ebe45
Show file tree
Hide file tree
Showing 9 changed files with 3,066 additions and 576 deletions.
710 changes: 590 additions & 120 deletions packaging/flavorgen/cloudprovider/csi.go

Large diffs are not rendered by default.

99 changes: 54 additions & 45 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,88 @@ 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)
csiNamespace := cloudprovider.CSIDriverNamespace()
csiNamespaceConfigMap := newConfigMap("csi-namespace", csiNamespace)
appendConfigMapToCrsResource(crs, csiNamespaceConfigMap)

clusterRole := cloudprovider.CSIControllerClusterRole()
clusterRole.TypeMeta = metav1.TypeMeta{
Kind: "ClusterRole",
APIVersion: rbac.SchemeGroupVersion.String(),
}
clusterRoleConfigMap := newConfigMap(clusterRole.Name, clusterRole)
appendConfigMapToCrsResource(crs, clusterRoleConfigMap)
controllerServiceAccount := cloudprovider.CSIControllerServiceAccount()
controllerServiceAccountSecret := newSecret(controllerServiceAccount.Name, controllerServiceAccount)
appendSecretToCrsResource(crs, controllerServiceAccountSecret)

clusterRoleBinding := cloudprovider.CSIControllerClusterRoleBinding()
clusterRoleBinding.TypeMeta = metav1.TypeMeta{
Kind: "ClusterRoleBinding",
APIVersion: rbac.SchemeGroupVersion.String(),
}
clusterRoleBindingConfigMap := newConfigMap(clusterRoleBinding.Name, clusterRoleBinding)
appendConfigMapToCrsResource(crs, clusterRoleBindingConfigMap)
controllerClusterRole := cloudprovider.CSIControllerClusterRole()
controllerClusterRoleConfigMap := newConfigMap(controllerClusterRole.Name, controllerClusterRole)
appendConfigMapToCrsResource(crs, controllerClusterRoleConfigMap)

controllerClusterRoleBinding := cloudprovider.CSIControllerClusterRoleBinding()
controllerClusterRoleBindingConfigMap := newConfigMap(controllerClusterRoleBinding.Name, controllerClusterRoleBinding)
appendConfigMapToCrsResource(crs, controllerClusterRoleBindingConfigMap)

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

nodeRole := cloudprovider.CSINodeRole()
nodeRoleConfigMap := newConfigMap(nodeRole.Name, nodeRole)
appendConfigMapToCrsResource(crs, nodeRoleConfigMap)

nodeRoleBinding := cloudprovider.CSINodeRoleBinding()
nodeRoleBindingConfigMap := newConfigMap(nodeRoleBinding.Name, nodeRoleBinding)
appendConfigMapToCrsResource(crs, nodeRoleBindingConfigMap)

nodeClusterRole := cloudprovider.CSINodeClusterRole()
nodeClusterRoleConfigMap := newConfigMap(nodeClusterRole.Name, nodeClusterRole)
appendConfigMapToCrsResource(crs, nodeClusterRoleConfigMap)

nodeClusterRoleBinding := cloudprovider.CSINodeClusterRoleBinding()
nodeClusterRoleBindingConfigMap := newConfigMap(nodeClusterRoleBinding.Name, nodeClusterRoleBinding)
appendConfigMapToCrsResource(crs, nodeClusterRoleBindingConfigMap)

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)

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

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

csiService := cloudprovider.CSIControllerService()
csiServiceConfigMap := newConfigMap(csiService.Name+"-service", csiService)
appendConfigMapToCrsResource(crs, csiServiceConfigMap)

csiFeatureStates := cloudprovider.CSIFeatureStatesConfigMap()
csiFeatureStatesConfigMap := newConfigMap("internal-feature-states", csiFeatureStates)
appendConfigMapToCrsResource(crs, csiFeatureStatesConfigMap)

return []runtime.Object{
serviceAccountSecret,
clusterRoleConfigMap,
clusterRoleBindingConfigMap,
csiNamespaceConfigMap,
controllerServiceAccountSecret,
controllerClusterRoleConfigMap,
controllerClusterRoleBindingConfigMap,
nodeDaemonSetServiceAccountSecret,
nodeRoleConfigMap,
nodeRoleBindingConfigMap,
nodeClusterRoleConfigMap,
nodeClusterRoleBindingConfigMap,
cloudConfigSecretWrapper,
csiDriverConfigMap,
daemonSetConfigMap,
deploymentConfigMap,
csiFeatureStatesConfigMap,
csiServiceConfigMap,
}
}

Expand All @@ -115,7 +122,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
1 change: 0 additions & 1 deletion packaging/flavorgen/flavors/flavors.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import (
"fmt"

"k8s.io/apimachinery/pkg/runtime"

Check failure on line 22 in packaging/flavorgen/flavors/flavors.go

View workflow job for this annotation

GitHub Actions / lint

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(sigs.k8s.io/cluster-api-provider-vsphere) --custom-order (gci)

"sigs.k8s.io/cluster-api-provider-vsphere/packaging/flavorgen/flavors/crs"
"sigs.k8s.io/cluster-api-provider-vsphere/packaging/flavorgen/flavors/env"
)
Expand Down
Loading

0 comments on commit 05ebe45

Please sign in to comment.