Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support external control plane topology #187

Merged
merged 2 commits into from Jul 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions pkg/operator/csidriveroperator/csioperatorclient/types.go
Expand Up @@ -41,6 +41,8 @@ type CSIOperatorConfig struct {
OLMOptions *OLMOptions
// Run the CSI driver operator only when given FeatureGate is enabled
RequireFeatureGate string
// Schedule CSI driver operator on workers when control plane is externalized
ScheduleOnWorkers bool
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@csrwng on vSphere clusters we also schedule the vsphere-problem-detector pod on master nodes, is that something we need to change as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, thank you, we should. Will update this PR

}

// OLMOptions contains information that is necessary to remove old CSI driver
Expand Down
3 changes: 3 additions & 0 deletions pkg/operator/csidriveroperator/deploymentcontroller.go
Expand Up @@ -114,6 +114,9 @@ func (c *CSIDriverOperatorDeploymentController) Sync(ctx context.Context, syncCt
if err != nil {
return fmt.Errorf("failed to inject proxy data into deployment: %w", err)
}
if c.csiOperatorConfig.ScheduleOnWorkers {
requiredCopy.Spec.Template.Spec.NodeSelector = map[string]string{}
}

_, err = csoutils.CreateDeployment(ctx, csoutils.DeploymentOptions{
Required: requiredCopy,
Expand Down
5 changes: 5 additions & 0 deletions pkg/operator/csidriveroperator/driverstarter.go
Expand Up @@ -150,6 +150,7 @@ func (c *CSIDriverStarterController) sync(ctx context.Context, syncCtx factory.S
if !shouldRun {
continue
}
ctrl.operatorConfig.ScheduleOnWorkers = shouldScheduleOnWorkers(infrastructure)
relatedObjects = append(relatedObjects, configv1.ObjectReference{
Group: operatorapi.GroupName,
Resource: "clustercsidrivers",
Expand Down Expand Up @@ -295,3 +296,7 @@ func isUnsupportedCSIDriverRunning(cfg csioperatorclient.CSIOperatorConfig, csiD

return true
}

func shouldScheduleOnWorkers(infra *configv1.Infrastructure) bool {
return infra.Status.ControlPlaneTopology == configv1.ExternalTopologyMode
}
Expand Up @@ -7,7 +7,9 @@ import (
"strings"
"time"

configv1 "github.com/openshift/api/config/v1"
operatorapi "github.com/openshift/api/operator/v1"
openshiftv1 "github.com/openshift/client-go/config/listers/config/v1"
"github.com/openshift/cluster-storage-operator/pkg/csoclients"
"github.com/openshift/cluster-storage-operator/pkg/operator/configobservation/util"
csoutils "github.com/openshift/cluster-storage-operator/pkg/utils"
Expand All @@ -28,6 +30,7 @@ const (
type VSphereProblemDetectorDeploymentController struct {
operatorClient v1helpers.OperatorClient
kubeClient kubernetes.Interface
infraLister openshiftv1.InfrastructureLister
versionGetter status.VersionGetter
targetVersion string
eventRecorder events.Recorder
Expand All @@ -42,6 +45,7 @@ func NewVSphereProblemDetectorDeploymentController(
c := &VSphereProblemDetectorDeploymentController{
operatorClient: clients.OperatorClient,
kubeClient: clients.KubeClient,
infraLister: clients.ConfigInformers.Config().V1().Infrastructures().Lister(),
versionGetter: versionGetter,
eventRecorder: eventRecorder,
targetVersion: targetVersion,
Expand All @@ -50,7 +54,8 @@ func NewVSphereProblemDetectorDeploymentController(
WithSync(c.sync).
WithInformers(
c.operatorClient.Informer(),
clients.KubeInformers.InformersFor(csoclients.OperatorNamespace).Apps().V1().Deployments().Informer()).
clients.KubeInformers.InformersFor(csoclients.OperatorNamespace).Apps().V1().Deployments().Informer(),
clients.ConfigInformers.Config().V1().Infrastructures().Informer()).
ResyncEvery(resyncInterval).
WithSyncDegradedOnError(clients.OperatorClient).
ToController(deploymentControllerName, eventRecorder.WithComponentSuffix("vsphere-problem-detector-deployment"))
Expand All @@ -75,6 +80,11 @@ func (c *VSphereProblemDetectorDeploymentController) sync(ctx context.Context, s
"${OPERATOR_IMAGE}", os.Getenv(vSphereProblemDetectorOperatorImage),
}

infrastructure, err := c.infraLister.Get(infraConfigName)
if err != nil {
return err
}

replacer := strings.NewReplacer(pairs...)
required, err := csoutils.GetRequiredDeployment("vsphere_problem_detector/06_deployment.yaml", opSpec, replacer)
if err != nil {
Expand All @@ -86,6 +96,10 @@ func (c *VSphereProblemDetectorDeploymentController) sync(ctx context.Context, s
return fmt.Errorf("failed to inject proxy data into deployment: %w", err)
}

if shouldScheduleOnWorkers(infrastructure) {
requiredCopy.Spec.Template.Spec.NodeSelector = map[string]string{}
}

_, err = csoutils.CreateDeployment(ctx, csoutils.DeploymentOptions{
Required: requiredCopy,
ControllerName: deploymentControllerName,
Expand All @@ -99,3 +113,7 @@ func (c *VSphereProblemDetectorDeploymentController) sync(ctx context.Context, s
})
return err
}

func shouldScheduleOnWorkers(infra *configv1.Infrastructure) bool {
return infra.Status.ControlPlaneTopology == configv1.ExternalTopologyMode
}