Skip to content

Commit

Permalink
operator: Replace deprecated ctrl-runtime cfg with custom package (#1…
Browse files Browse the repository at this point in the history
…1678)

Co-authored-by: Robert Jacob <rojacob@redhat.com>
Co-authored-by: Robert Jacob <xperimental@solidproject.de>
  • Loading branch information
3 people committed Jan 18, 2024
1 parent 423f3e9 commit 28a4135
Show file tree
Hide file tree
Showing 8 changed files with 300 additions and 182 deletions.
65 changes: 63 additions & 2 deletions operator/apis/config/v1/projectconfig_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package v1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
cfg "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1" //nolint:staticcheck
configv1alpha1 "k8s.io/component-base/config/v1alpha1"
)

// BuiltInCertManagement is the configuration for the built-in facility to generate and rotate
Expand Down Expand Up @@ -142,14 +142,75 @@ const (
TLSProfileModernType TLSProfileType = "Modern"
)

// ControllerManagerConfigurationSpec defines the desired state of GenericControllerManagerConfiguration.
type ControllerManagerConfigurationSpec struct {
// LeaderElection is the LeaderElection config to be used when configuring
// the manager.Manager leader election
// +optional
LeaderElection *configv1alpha1.LeaderElectionConfiguration `json:"leaderElection,omitempty"`

// Metrics contains the controller metrics configuration
// +optional
Metrics ControllerMetrics `json:"metrics,omitempty"`

// Health contains the controller health configuration
// +optional
Health ControllerHealth `json:"health,omitempty"`

// Webhook contains the controllers webhook configuration
// +optional
Webhook ControllerWebhook `json:"webhook,omitempty"`
}

// ControllerMetrics defines the metrics configs.
type ControllerMetrics struct {
// BindAddress is the TCP address that the controller should bind to
// for serving prometheus metrics.
// It can be set to "0" to disable the metrics serving.
// +optional
BindAddress string `json:"bindAddress,omitempty"`
}

// ControllerHealth defines the health configs.
type ControllerHealth struct {
// HealthProbeBindAddress is the TCP address that the controller should bind to
// for serving health probes
// It can be set to "0" or "" to disable serving the health probe.
// +optional
HealthProbeBindAddress string `json:"healthProbeBindAddress,omitempty"`
}

// ControllerWebhook defines the webhook server for the controller.
type ControllerWebhook struct {
// Port is the port that the webhook server serves at.
// It is used to set webhook.Server.Port.
// +optional
Port *int `json:"port,omitempty"`
}

//+kubebuilder:object:root=true

// ControllerManagerConfiguration is the Schema for the GenericControllerManagerConfigurations API.
type ControllerManagerConfiguration struct {
metav1.TypeMeta `json:",inline"`

// ControllerManagerConfiguration returns the contfigurations for controllers
ControllerManagerConfigurationSpec `json:",inline"`
}

// Complete returns the configuration for controller-runtime.
func (c *ControllerManagerConfigurationSpec) Complete() (ControllerManagerConfigurationSpec, error) {
return *c, nil
}

//+kubebuilder:object:root=true

// ProjectConfig is the Schema for the projectconfigs API
type ProjectConfig struct {
metav1.TypeMeta `json:",inline"`

// ControllerManagerConfigurationSpec returns the contfigurations for controllers
cfg.ControllerManagerConfigurationSpec `json:",inline"`
ControllerManagerConfigurationSpec `json:",inline"`

Gates FeatureGates `json:"featureGates,omitempty"`
}
Expand Down
99 changes: 99 additions & 0 deletions operator/apis/config/v1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 8 additions & 18 deletions operator/config/docs/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
],
"hideTypePatterns": [
"ParseError$",
"List$"
"List$",
"ControllerHealth$",
"ControllerManagerConfiguration$",
"ControllerManagerConfigurationSpec$",
"ControllerMetrics$",
"ControllerWebhook$",
"ProjectConfig$"
],
"externalPackages": [
{
Expand Down Expand Up @@ -38,22 +44,6 @@
{
"typeMatchPrefix": "^k8s\\.io/component-base/config/v1alpha1\\.LeaderElectionConfiguration$",
"docsURLTemplate": "https://pkg.go.dev/k8s.io/component-base/config#LeaderElectionConfiguration"
},
{
"typeMatchPrefix": "^sigs\\.k8s\\.io/controller-runtime/pkg/config/v1alpha1\\.ControllerConfigurationSpec$",
"docsURLTemplate": "https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/config/v1alpha1#ControllerConfigurationSpec"
},
{
"typeMatchPrefix": "^sigs\\.k8s\\.io/controller-runtime/pkg/config/v1alpha1\\.ControllerMetrics$",
"docsURLTemplate": "https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/config/v1alpha1#ControllerMetrics"
},
{
"typeMatchPrefix": "^sigs\\.k8s\\.io/controller-runtime/pkg/config/v1alpha1\\.ControllerHealth$",
"docsURLTemplate": "https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/config/v1alpha1#ControllerHealth"
},
{
"typeMatchPrefix": "^sigs\\.k8s\\.io/controller-runtime/pkg/config/v1alpha1\\.ControllerWebhook$",
"docsURLTemplate": "https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/config/v1alpha1#ControllerWebhook"
}
],
"typeDisplayNamePrefixOverrides": {
Expand All @@ -66,4 +56,4 @@
"github.com/grafana/loki/operator/apis/loki/config/v1": "Feature Gates"
},
"markdownDisabled": false
}
}

0 comments on commit 28a4135

Please sign in to comment.