Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ crd:
hack/update-generated-crd.sh
hack/update-profile-manifests.sh

# Download Istio Helm charts from sail-operator repository.
.PHONY: update-istio-charts
update-istio-charts:
hack/update-istio-charts.sh

.PHONY: manifests
manifests:
go generate ./pkg/manifests
Expand Down
1 change: 1 addition & 0 deletions cmd/ingress-operator/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ var log = logf.Logger.WithName("main")
func main() {
var rootCmd = &cobra.Command{Use: "ingress-operator"}
rootCmd.AddCommand(NewStartCommand())
rootCmd.AddCommand(NewStartGatewayClassCommand())
rootCmd.AddCommand(NewRenderCommand())
rootCmd.AddCommand(httphealthcheck.NewServeHealthCheckCommand())
rootCmd.AddCommand(&cobra.Command{
Expand Down
118 changes: 118 additions & 0 deletions cmd/ingress-operator/start-gatewayclass.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
package main

import (
"fmt"
"github.com/spf13/cobra"
"os"

operatorclient "github.com/openshift/cluster-ingress-operator/pkg/operator/client"
operatorcontroller "github.com/openshift/cluster-ingress-operator/pkg/operator/controller"
gatewayclasscontroller "github.com/openshift/cluster-ingress-operator/pkg/operator/controller/gatewayclass"

"sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client/config"
"sigs.k8s.io/controller-runtime/pkg/manager"
"sigs.k8s.io/controller-runtime/pkg/manager/signals"
)

type StartGatewayClassOptions struct {
// OperatorNamespace is the namespace the operator is deployed to.
OperatorNamespace string
// IstioVersion is the version of Istio to install.
IstioVersion string
}

// NewStartGatewayClassCommand creates a command to run only the gatewayclass controller.
// This is useful for POC testing of the Helm-based Istio installation.
func NewStartGatewayClassCommand() *cobra.Command {
var options StartGatewayClassOptions

cmd := &cobra.Command{
Use: "start-gatewayclass",
Short: "Start only the gatewayclass controller (POC testing)",
Long: `start-gatewayclass launches only the gatewayclass controller in the foreground.
This is a minimal command for testing the Helm-based Istio installation POC.
It does not start any other controllers or require OpenShift-specific APIs.`,
Run: func(cmd *cobra.Command, args []string) {
if err := startGatewayClass(&options); err != nil {
log.Error(err, "error starting gatewayclass controller")
os.Exit(1)
}
},
}

cmd.Flags().StringVarP(&options.OperatorNamespace, "namespace", "n", operatorcontroller.DefaultOperatorNamespace, "operator namespace")
cmd.Flags().StringVarP(&options.IstioVersion, "istio-version", "", defaultIstioVersion, "version of Istio to install")

return cmd
}

func startGatewayClass(opts *StartGatewayClassOptions) error {
kubeConfig, err := config.GetConfig()
if err != nil {
return fmt.Errorf("failed to get kube config: %w", err)
}

log.Info("starting gatewayclass controller (POC mode)", "namespace", opts.OperatorNamespace, "istio-version", opts.IstioVersion)

// Set up signal handler
ctx := signals.SetupSignalHandler()

// Create a minimal manager
scheme := operatorclient.GetScheme()
mgr, err := manager.New(kubeConfig, manager.Options{
Scheme: scheme,
Cache: cache.Options{
// Only watch resources in the operator and operand namespaces
// plus cluster-scoped resources like GatewayClass
DefaultNamespaces: map[string]cache.Config{
opts.OperatorNamespace: {},
operatorcontroller.DefaultOperandNamespace: {},
},
},
})
if err != nil {
return fmt.Errorf("failed to create manager: %w", err)
}

// Create the gatewayclass controller
gatewayClassController, err := gatewayclasscontroller.NewUnmanaged(mgr, gatewayclasscontroller.Config{
OperatorNamespace: opts.OperatorNamespace,
OperandNamespace: operatorcontroller.DefaultOperandNamespace,
IstioVersion: opts.IstioVersion,
})
if err != nil {
return fmt.Errorf("failed to create gatewayclass controller: %w", err)
}

// Start the gatewayclass controller manually (since it's unmanaged)
// We need to start the manager's cache first
go func() {
if err := mgr.Start(ctx); err != nil {
log.Error(err, "manager exited with error")
os.Exit(1)
}
}()

// Wait for cache to sync before starting the controller
if !mgr.GetCache().WaitForCacheSync(ctx) {
return fmt.Errorf("failed to sync cache")
}

log.Info("cache synced, starting gatewayclass controller")

// Start the gatewayclass controller
go func() {
if err := gatewayClassController.Start(ctx); err != nil {
log.Error(err, "gatewayclass controller exited with error")
os.Exit(1)
}
}()

log.Info("gatewayclass controller started successfully")

// Wait for shutdown signal
<-ctx.Done()
log.Info("shutting down")
return nil
}
29 changes: 7 additions & 22 deletions cmd/ingress-operator/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,8 @@ import (
const (
// defaultTrustedCABundle is the fully qualified path of the trusted CA bundle
// that is mounted from configmap openshift-ingress-operator/trusted-ca.
defaultTrustedCABundle = "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"
defaultGatewayAPIOperatorCatalog = "redhat-operators"
defaultGatewayAPIOperatorChannel = "stable"
defaultGatewayAPIOperatorVersion = "servicemeshoperator3.v3.2.0"
defaultIstioVersion = "v1.27.3"
defaultTrustedCABundle = "/etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem"
defaultIstioVersion = "v1.27.3"
)

type StartOptions struct {
Expand All @@ -55,12 +52,6 @@ type StartOptions struct {
CanaryImage string
// ReleaseVersion is the cluster version which the operator will converge to.
ReleaseVersion string
// GatewayAPIOperatorCatalog is the catalog source to use to install the Gateway API implementation.
GatewayAPIOperatorCatalog string
// GatewayAPIOperatorChannel is the release channel of the Gateway API implementation to install.
GatewayAPIOperatorChannel string
// GatewayAPIOperatorVersion is the name and release of the Gateway API implementation to install.
GatewayAPIOperatorVersion string
// IstioVersion is the version Istio to install.
IstioVersion string
}
Expand All @@ -86,9 +77,6 @@ func NewStartCommand() *cobra.Command {
cmd.Flags().StringVarP(&options.ReleaseVersion, "release-version", "", statuscontroller.UnknownVersionValue, "the release version the operator should converge to (required)")
cmd.Flags().StringVarP(&options.MetricsListenAddr, "metrics-listen-addr", "", "127.0.0.1:60000", "metrics endpoint listen address (required)")
cmd.Flags().StringVarP(&options.ShutdownFile, "shutdown-file", "s", defaultTrustedCABundle, "if provided, shut down the operator when this file changes")
cmd.Flags().StringVarP(&options.GatewayAPIOperatorCatalog, "gateway-api-operator-catalog", "", defaultGatewayAPIOperatorCatalog, "catalog source for the Gateway API implementation to install")
cmd.Flags().StringVarP(&options.GatewayAPIOperatorChannel, "gateway-api-operator-channel", "", defaultGatewayAPIOperatorChannel, "release channel of the Gateway API implementation to install")
cmd.Flags().StringVarP(&options.GatewayAPIOperatorVersion, "gateway-api-operator-version", "", defaultGatewayAPIOperatorVersion, "name and release of the Gateway API implementation to install")
cmd.Flags().StringVarP(&options.IstioVersion, "istio-version", "", defaultIstioVersion, "version Istio to install")

if err := cmd.MarkFlagRequired("namespace"); err != nil {
Expand Down Expand Up @@ -134,14 +122,11 @@ func start(opts *StartOptions) error {
defer cancel()

operatorConfig := operatorconfig.Config{
OperatorReleaseVersion: opts.ReleaseVersion,
Namespace: opts.OperatorNamespace,
IngressControllerImage: opts.IngressControllerImage,
CanaryImage: opts.CanaryImage,
GatewayAPIOperatorCatalog: opts.GatewayAPIOperatorCatalog,
GatewayAPIOperatorChannel: opts.GatewayAPIOperatorChannel,
GatewayAPIOperatorVersion: opts.GatewayAPIOperatorVersion,
IstioVersion: opts.IstioVersion,
OperatorReleaseVersion: opts.ReleaseVersion,
Namespace: opts.OperatorNamespace,
IngressControllerImage: opts.IngressControllerImage,
CanaryImage: opts.CanaryImage,
IstioVersion: opts.IstioVersion,
}

// Start operator metrics.
Expand Down
Loading