Skip to content

Commit

Permalink
Added library-go controller
Browse files Browse the repository at this point in the history
  • Loading branch information
anirudhAgniRedhat committed Oct 23, 2024
1 parent 9ea6c34 commit fe7b17e
Show file tree
Hide file tree
Showing 4 changed files with 500 additions and 383 deletions.
29 changes: 0 additions & 29 deletions cmd/aws-ebs-csi-driver-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,15 @@ package main

import (
"context"
"fmt"
"os"

"github.com/openshift/csi-operator/pkg/driver/aws-ebs"
"github.com/openshift/library-go/pkg/controller/controllercmd"
"github.com/spf13/cobra"
"k8s.io/component-base/cli"
"k8s.io/klog/v2"

configclient "github.com/openshift/client-go/config/clientset/versioned"
"github.com/openshift/csi-operator/pkg/operator"
"github.com/openshift/csi-operator/pkg/version"
corev1 "k8s.io/client-go/kubernetes/typed/core/v1"
)

func main() {
Expand Down Expand Up @@ -53,31 +49,6 @@ func NewOperatorCommand() *cobra.Command {
}

func runCSIDriverOperator(ctx context.Context, controllerConfig *controllercmd.ControllerContext) error {
klog.Info("Starting AWS EBS CSI Driver Operator")

opConfig := aws_ebs.GetAWSEBSOperatorConfig()

configClient, err := configclient.NewForConfig(controllerConfig.KubeConfig)
if err != nil {
klog.Errorf("Failed to create config client: %v", err)
return fmt.Errorf("failed to create config client: %v", err)
}

coreClient, err := corev1.NewForConfig(controllerConfig.KubeConfig)
if err != nil {
klog.Errorf("Failed to create core client: %v", err)
return fmt.Errorf("failed to create core client: %v", err)
}

ebsTagsController, err := aws_ebs.NewEBSVolumeTagController(configClient, coreClient)
if err != nil {
klog.Errorf("Failed to create EBS volume tag controller: %v", err)
return fmt.Errorf("failed to create EBS volume tag controller: %v", err)
}

go ebsTagsController.Run(ctx)

klog.Info("EBS Volume Tag Controller is running")

return operator.RunOperator(ctx, controllerConfig, *guestKubeconfig, opConfig)
}
3 changes: 3 additions & 0 deletions pkg/driver/aws-ebs/aws_ebs.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ func GetAWSEBSOperatorControllerConfig(ctx context.Context, flavour generator.Cl
cfg.ExtraControlPlaneControllers = append(cfg.ExtraControlPlaneControllers, ctrl)
}

volumeTagController := NewEBSVolumeTagsController(ctx, cfg.GetControllerName("EBSVolumeTagsController"), c, c.EventRecorder)
cfg.ExtraControlPlaneControllers = append(cfg.ExtraControlPlaneControllers, volumeTagController)

return cfg, nil
}

Expand Down
Loading

0 comments on commit fe7b17e

Please sign in to comment.