Skip to content

Commit

Permalink
add defaults for CSI / CPI images
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Sy Kim <kiman@vmware.com>
  • Loading branch information
andrewsykim committed Oct 18, 2019
1 parent d3895c6 commit d50072d
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 7 deletions.
2 changes: 1 addition & 1 deletion api/v1alpha2/cloudprovider/encoding_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ folder = kubernetes
Folder: "kubernetes",
},
ProviderConfig: cloudprovider.ProviderConfig{
Cloud: cloudprovider.CloudConfig{
Cloud: &cloudprovider.CloudConfig{
ControllerImage: "test",
},
},
Expand Down
4 changes: 2 additions & 2 deletions api/v1alpha2/cloudprovider/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ type Config struct {
// ProviderConfig defines any extra information used to configure
// the vSphere external cloud provider
type ProviderConfig struct {
Cloud CloudConfig `json:"cloud,omitempty"`
Storage StorageConfig `json:"storage,omitempty"`
Cloud *CloudConfig `json:"cloud,omitempty"`
Storage *StorageConfig `json:"storage,omitempty"`
}

type CloudConfig struct {
Expand Down
57 changes: 55 additions & 2 deletions controllers/vspherecluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,22 @@ func (r *VSphereClusterReconciler) reconcileAPIEndpoints(ctx *context.ClusterCon

func (r *VSphereClusterReconciler) reconcileCloudProvider(ctx *context.ClusterContext) error {
// if the cloud provider image is not specified, then we do nothing
controllerImage := ctx.VSphereCluster.Spec.CloudProviderConfiguration.ProviderConfig.Cloud.ControllerImage
if controllerImage == "" {
cloudproviderConfig := ctx.VSphereCluster.Spec.CloudProviderConfiguration.ProviderConfig.Cloud
if cloudproviderConfig == nil {
ctx.Logger.V(2).Info(
"cloud provider config was not specified in VSphereCluster, skipping reconciliation of the cloud provider integration",
)

return nil
}

if cloudproviderConfig.ControllerImage == "" {
cloudproviderConfig.ControllerImage = cloudprovider.DefaultCPIControllerImage
}

ctx.VSphereCluster.Spec.CloudProviderConfiguration.ProviderConfig.Cloud = cloudproviderConfig
controllerImage := cloudproviderConfig.ControllerImage

targetClusterClient, err := infrautilv1.NewKubeClient(ctx, ctx.Client, ctx.Cluster)
if err != nil {
return errors.Wrapf(err,
Expand Down Expand Up @@ -321,6 +332,48 @@ func (r *VSphereClusterReconciler) reconcileCloudProvider(ctx *context.ClusterCo
}

func (r *VSphereClusterReconciler) reconcileStorageProvider(ctx *context.ClusterContext) error {
// if storage config is not defined, assume we don't want CSI installed
storageConfig := ctx.VSphereCluster.Spec.CloudProviderConfiguration.ProviderConfig.Storage
if storageConfig == nil {
ctx.Logger.V(2).Info(
"storage config was not specified in VSphereCluster, skipping reconciliation of the CSI driver",
)

return nil
}

// if at least 1 field in the storage config is defined, assume CNS should be installed
// and use default images when not defined
if storageConfig.ControllerImage == "" {
storageConfig.ControllerImage = cloudprovider.DefaultCSIControllerImage
}

if storageConfig.NodeDriverImage == "" {
storageConfig.NodeDriverImage = cloudprovider.DefaultCSINodeDriverImage
}

if storageConfig.AttacherImage == "" {
storageConfig.AttacherImage = cloudprovider.DefaultCSIAttacherImage
}

if storageConfig.ProvisionerImage == "" {
storageConfig.ProvisionerImage = cloudprovider.DefaultCSIProvisionerImage
}

if storageConfig.MetadataSyncerImage == "" {
storageConfig.MetadataSyncerImage = cloudprovider.DefaultCSIMetadataSyncerImage
}

if storageConfig.LivenessProbeImage == "" {
storageConfig.LivenessProbeImage = cloudprovider.DefaultCSILivenessProbeImage
}

if storageConfig.RegistrarImage == "" {
storageConfig.RegistrarImage = cloudprovider.DefaultCSIRegistrarImage
}

ctx.VSphereCluster.Spec.CloudProviderConfiguration.ProviderConfig.Storage = storageConfig

targetClusterClient, err := infrautilv1.NewKubeClient(ctx, ctx.Client, ctx.Cluster)
if err != nil {
return errors.Wrapf(err,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ import (

// NOTE: the contents of this file are derived from https://github.com/kubernetes/cloud-provider-vsphere/tree/master/manifests/controller-manager

const (
DefaultCPIControllerImage = "gcr.io/cloud-provider-vsphere/cpi/release/manager:v1.0.0"
)

// CloudControllerManagerServiceAccount returns the ServiceAccount used for the cloud-controller-manager
func CloudControllerManagerServiceAccount() *corev1.ServiceAccount {
return &corev1.ServiceAccount{
Expand Down
14 changes: 12 additions & 2 deletions pkg/cloud/vsphere/services/cloudprovider/csi.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,16 @@ import (

// NOTE: the contents of this file are derived from https://github.com/kubernetes-sigs/vsphere-csi-driver/tree/master/manifests/1.14

const (
DefaultCSIControllerImage = "vmware/vsphere-block-csi-driver:v1.0.0"
DefaultCSINodeDriverImage = "vmware/vsphere-block-csi-driver:v1.0.0"
DefaultCSIAttacherImage = "quay.io/k8scsi/csi-attacher:v1.1.1"
DefaultCSIProvisionerImage = "quay.io/k8scsi/csi-provisioner:v1.2.1"
DefaultCSIMetadataSyncerImage = "vmware/volume-metadata-syncer:v1.0.0"
DefaultCSILivenessProbeImage = "quay.io/k8scsi/livenessprobe:v1.1.0"
DefaultCSIRegistrarImage = "quay.io/k8scsi/csi-node-driver-registrar:v1.1.0"
)

func CSIControllerServiceAccount() *corev1.ServiceAccount {
return &corev1.ServiceAccount{
ObjectMeta: metav1.ObjectMeta{
Expand Down Expand Up @@ -138,7 +148,7 @@ func CSIDriver() *storagev1beta1.CSIDriver {
}
}

func VSphereCSINodeDaemonSet(storageConfig cloudprovider.StorageConfig) *appsv1.DaemonSet {
func VSphereCSINodeDaemonSet(storageConfig *cloudprovider.StorageConfig) *appsv1.DaemonSet {
return &appsv1.DaemonSet{
ObjectMeta: metav1.ObjectMeta{
Name: "vsphere-csi-node",
Expand Down Expand Up @@ -343,7 +353,7 @@ func LivenessProbeForNodeContainer(image string) corev1.Container {
}
}

func CSIControllerStatefulSet(storageConfig cloudprovider.StorageConfig) *appsv1.StatefulSet {
func CSIControllerStatefulSet(storageConfig *cloudprovider.StorageConfig) *appsv1.StatefulSet {
return &appsv1.StatefulSet{
ObjectMeta: metav1.ObjectMeta{
Name: "vsphere-csi-controller",
Expand Down

0 comments on commit d50072d

Please sign in to comment.