Skip to content

Commit

Permalink
Bump CAPI to v1.8.5
Browse files Browse the repository at this point in the history
Signed-off-by: Furkat Gofurov <[email protected]>
  • Loading branch information
furkatgofurov7 committed Nov 11, 2024
1 parent 2d23589 commit 29f4bd3
Show file tree
Hide file tree
Showing 23 changed files with 3,798 additions and 1,540 deletions.
12 changes: 8 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ GO_INSTALL := ./scripts/go_install.sh
export PATH := $(abspath $(TOOLS_BIN_DIR)):$(PATH)

# Kubebuilder
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.26.1
export KUBEBUILDER_ENVTEST_KUBERNETES_VERSION ?= 1.30.3
export KUBEBUILDER_CONTROLPLANE_START_TIMEOUT ?= 60s
export KUBEBUILDER_CONTROLPLANE_STOP_TIMEOUT ?= 60s

Expand All @@ -66,7 +66,7 @@ IMAGE_REVIEWERS ?= $(shell ./hack/get-project-maintainers.sh)

# Binaries.
# Need to use abspath so we can invoke these from subdirectories
CONTROLLER_GEN_VER := v0.14.0
CONTROLLER_GEN_VER := v0.15.0
CONTROLLER_GEN_BIN := controller-gen
CONTROLLER_GEN := $(TOOLS_BIN_DIR)/$(CONTROLLER_GEN_BIN)-$(CONTROLLER_GEN_VER)

Expand All @@ -78,15 +78,19 @@ KUSTOMIZE_VER := v5.0.1
KUSTOMIZE_BIN := kustomize
KUSTOMIZE := $(TOOLS_BIN_DIR)/$(KUSTOMIZE_BIN)-$(KUSTOMIZE_VER)

SETUP_ENVTEST_VER := v0.0.0-20240215143116-d0396a3d6f9f
# This is a commit from CR main (22.05.2024).
# Intentionally using a commit from main to use a setup-envtest version
# that uses binaries from controller-tools, not GCS.
# CR PR: https://github.com/kubernetes-sigs/controller-runtime/pull/2811
SETUP_ENVTEST_VER := v0.0.0-20240522175850-2e9781e9fc60
SETUP_ENVTEST_BIN := setup-envtest
SETUP_ENVTEST := $(TOOLS_BIN_DIR)/$(SETUP_ENVTEST_BIN)-$(SETUP_ENVTEST_VER)

GOTESTSUM_VER := v1.11.0
GOTESTSUM_BIN := gotestsum
GOTESTSUM := $(TOOLS_BIN_DIR)/$(GOTESTSUM_BIN)-$(GOTESTSUM_VER)

GINKGO_VER := v2.17.1
GINKGO_VER := v2.20.1
GINKGO_BIN := ginkgo
GINKGO := $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINKGO_VER)

Expand Down
47 changes: 23 additions & 24 deletions api/v1alpha1/provider_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
apimachineryconversion "k8s.io/apimachinery/pkg/conversion"
"k8s.io/utils/ptr"
utilconversion "sigs.k8s.io/cluster-api/util/conversion"
ctrlconfigv1 "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
"sigs.k8s.io/controller-runtime/pkg/conversion"

operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha2"
Expand Down Expand Up @@ -281,33 +280,33 @@ func Convert_v1alpha1_ManagerSpec_To_v1alpha2_ManagerSpec(in *ManagerSpec, out *
return nil
}

out.ControllerManagerConfiguration.SyncPeriod = in.ControllerManagerConfigurationSpec.SyncPeriod
out.ControllerManagerConfiguration.LeaderElection = in.ControllerManagerConfigurationSpec.LeaderElection
out.ControllerManagerConfiguration.CacheNamespace = in.ControllerManagerConfigurationSpec.CacheNamespace
out.ControllerManagerConfiguration.GracefulShutdownTimeout = in.ControllerManagerConfigurationSpec.GracefulShutdownTimeout
out.ControllerManagerConfiguration.SyncPeriod = in.ControllerManager.SyncPeriod
out.ControllerManagerConfiguration.LeaderElection = in.ControllerManager.LeaderElection
out.ControllerManagerConfiguration.CacheNamespace = in.ControllerManager.CacheNamespace
out.ControllerManagerConfiguration.GracefulShutdownTimeout = in.ControllerManager.GracefulShutdownTimeout

if in.ControllerManagerConfigurationSpec.Controller != nil {
if in.ControllerManager.Controller != nil {
out.ControllerManagerConfiguration.Controller = &operatorv1.ControllerConfigurationSpec{
GroupKindConcurrency: in.ControllerManagerConfigurationSpec.Controller.GroupKindConcurrency,
CacheSyncTimeout: in.ControllerManagerConfigurationSpec.Controller.CacheSyncTimeout,
RecoverPanic: in.ControllerManagerConfigurationSpec.Controller.RecoverPanic,
GroupKindConcurrency: in.ControllerManager.Controller.GroupKindConcurrency,
CacheSyncTimeout: in.ControllerManager.Controller.CacheSyncTimeout,
RecoverPanic: in.ControllerManager.Controller.RecoverPanic,
}
}

out.ControllerManagerConfiguration.Metrics = operatorv1.ControllerMetrics{
BindAddress: in.ControllerManagerConfigurationSpec.Metrics.BindAddress,
BindAddress: in.ControllerManager.Metrics.BindAddress,
}

out.ControllerManagerConfiguration.Health = operatorv1.ControllerHealth{
HealthProbeBindAddress: in.ControllerManagerConfigurationSpec.Health.HealthProbeBindAddress,
ReadinessEndpointName: in.ControllerManagerConfigurationSpec.Health.ReadinessEndpointName,
LivenessEndpointName: in.ControllerManagerConfigurationSpec.Health.LivenessEndpointName,
HealthProbeBindAddress: in.ControllerManager.Health.HealthProbeBindAddress,
ReadinessEndpointName: in.ControllerManager.Health.ReadinessEndpointName,
LivenessEndpointName: in.ControllerManager.Health.LivenessEndpointName,
}

out.ControllerManagerConfiguration.Webhook = operatorv1.ControllerWebhook{
Port: in.ControllerManagerConfigurationSpec.Webhook.Port,
Host: in.ControllerManagerConfigurationSpec.Webhook.Host,
CertDir: in.ControllerManagerConfigurationSpec.Webhook.CertDir,
Port: in.ControllerManager.Webhook.Port,
Host: in.ControllerManager.Webhook.Host,
CertDir: in.ControllerManager.Webhook.CertDir,
}

out.ProfilerAddress = in.ProfilerAddress
Expand All @@ -323,30 +322,30 @@ func Convert_v1alpha2_ManagerSpec_To_v1alpha1_ManagerSpec(in *operatorv1.Manager
return nil
}

out.ControllerManagerConfigurationSpec.SyncPeriod = in.ControllerManagerConfiguration.SyncPeriod
out.ControllerManagerConfigurationSpec.LeaderElection = in.ControllerManagerConfiguration.LeaderElection
out.ControllerManagerConfigurationSpec.CacheNamespace = in.ControllerManagerConfiguration.CacheNamespace
out.ControllerManagerConfigurationSpec.GracefulShutdownTimeout = in.ControllerManagerConfiguration.GracefulShutdownTimeout
out.ControllerManager.SyncPeriod = in.ControllerManagerConfiguration.SyncPeriod
out.ControllerManager.LeaderElection = in.ControllerManagerConfiguration.LeaderElection
out.ControllerManager.CacheNamespace = in.ControllerManagerConfiguration.CacheNamespace
out.ControllerManager.GracefulShutdownTimeout = in.ControllerManagerConfiguration.GracefulShutdownTimeout

if in.ControllerManagerConfiguration.Controller != nil {
out.ControllerManagerConfigurationSpec.Controller = &ctrlconfigv1.ControllerConfigurationSpec{
out.ControllerManager.Controller = &ControllerConfigurationSpec{
GroupKindConcurrency: in.ControllerManagerConfiguration.Controller.GroupKindConcurrency,
CacheSyncTimeout: in.ControllerManagerConfiguration.Controller.CacheSyncTimeout,
RecoverPanic: in.ControllerManagerConfiguration.Controller.RecoverPanic,
}
}

out.ControllerManagerConfigurationSpec.Metrics = ctrlconfigv1.ControllerMetrics{
out.ControllerManager.Metrics = ControllerMetrics{
BindAddress: in.ControllerManagerConfiguration.Metrics.BindAddress,
}

out.ControllerManagerConfigurationSpec.Health = ctrlconfigv1.ControllerHealth{
out.ControllerManager.Health = ControllerHealth{
HealthProbeBindAddress: in.ControllerManagerConfiguration.Health.HealthProbeBindAddress,
ReadinessEndpointName: in.ControllerManagerConfiguration.Health.ReadinessEndpointName,
LivenessEndpointName: in.ControllerManagerConfiguration.Health.LivenessEndpointName,
}

out.ControllerManagerConfigurationSpec.Webhook = ctrlconfigv1.ControllerWebhook{
out.ControllerManager.Webhook = ControllerWebhook{
Port: in.ControllerManagerConfiguration.Webhook.Port,
Host: in.ControllerManagerConfiguration.Webhook.Host,
CertDir: in.ControllerManagerConfiguration.Webhook.CertDir,
Expand Down
129 changes: 126 additions & 3 deletions api/v1alpha1/provider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ limitations under the License.
package v1alpha1

import (
"time"

corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
configv1alpha1 "k8s.io/component-base/config/v1alpha1"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
ctrlconfigv1 "sigs.k8s.io/controller-runtime/pkg/config/v1alpha1"
)

const (
Expand Down Expand Up @@ -84,8 +86,8 @@ type ConfigmapReference struct {

// ManagerSpec defines the properties that can be enabled on the controller manager for the provider.
type ManagerSpec struct {
// ControllerManagerConfigurationSpec defines the desired state of GenericControllerManagerConfiguration.
ctrlconfigv1.ControllerManagerConfigurationSpec `json:",inline"`
// ControllerManager returns the configurations for controllers
ControllerManager `json:",inline"`

// ProfilerAddress defines the bind address to expose the pprof profiler (e.g. localhost:6060).
// Default empty, meaning the profiler is disabled.
Expand All @@ -112,6 +114,127 @@ type ManagerSpec struct {
FeatureGates map[string]bool `json:"featureGates,omitempty"`
}

type ControllerManager struct {
// Webhook contains the controllers webhook configuration
// +optional
Webhook ControllerWebhook `json:"webhook,omitempty"`

// SyncPeriod determines the minimum frequency at which watched resources are
// reconciled. A lower period will correct entropy more quickly, but reduce
// responsiveness to change if there are many watched resources. Change this
// value only if you know what you are doing. Defaults to 10 hours if unset.
// there will a 10 percent jitter between the SyncPeriod of all controllers
// so that all controllers will not send list requests simultaneously.
// +optional
SyncPeriod *metav1.Duration `json:"syncPeriod,omitempty"`

// LeaderElection is the LeaderElection config to be used when configuring
// the manager.Manager leader election
// +optional
LeaderElection *configv1alpha1.LeaderElectionConfiguration `json:"leaderElection,omitempty"`

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

// CacheNamespace if specified restricts the manager's cache to watch objects in
// the desired namespace Defaults to all namespaces
//
// Note: If a namespace is specified, controllers can still Watch for a
// cluster-scoped resource (e.g Node). For namespaced resources the cache
// will only hold objects from the desired namespace.
// +optional
CacheNamespace string `json:"cacheNamespace,omitempty"`

// GracefulShutdownTimeout is the duration given to runnable to stop before the manager actually returns on stop.
// To disable graceful shutdown, set to time.Duration(0)
// To use graceful shutdown without timeout, set to a negative duration, e.G. time.Duration(-1)
// The graceful shutdown is skipped for safety reasons in case the leader election lease is lost.
GracefulShutdownTimeout *metav1.Duration `json:"gracefulShutDown,omitempty"`

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

// Controller contains global configuration options for controllers
// registered within this manager.
// +optional
Controller *ControllerConfigurationSpec `json:"controller,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"`

// Host is the hostname that the webhook server binds to.
// It is used to set webhook.Server.Host.
// +optional
Host string `json:"host,omitempty"`

// CertDir is the directory that contains the server key and certificate.
// if not set, webhook server would look up the server key and certificate in
// {TempDir}/k8s-webhook-server/serving-certs. The server key and certificate
// must be named tls.key and tls.crt, respectively.
// +optional
CertDir string `json:"certDir,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"`

// ReadinessEndpointName, defaults to "readyz"
// +optional
ReadinessEndpointName string `json:"readinessEndpointName,omitempty"`

// LivenessEndpointName, defaults to "healthz"
// +optional
LivenessEndpointName string `json:"livenessEndpointName,omitempty"`
}

// ControllerConfigurationSpec defines the global configuration for
// controllers registered with the manager.
type ControllerConfigurationSpec struct {
// GroupKindConcurrency is a map from a Kind to the number of concurrent reconciliation
// allowed for that controller.
//
// When a controller is registered within this manager using the builder utilities,
// users have to specify the type the controller reconciles in the For(...) call.
// If the object's kind passed matches one of the keys in this map, the concurrency
// for that controller is set to the number specified.
//
// The key is expected to be consistent in form with GroupKind.String(),
// e.g. ReplicaSet in apps group (regardless of version) would be `ReplicaSet.apps`.
//
// +optional
GroupKindConcurrency map[string]int `json:"groupKindConcurrency,omitempty"`

// CacheSyncTimeout refers to the time limit set to wait for syncing caches.
// Defaults to 2 minutes if not set.
// +optional
CacheSyncTimeout *time.Duration `json:"cacheSyncTimeout,omitempty"`

// RecoverPanic indicates if panics should be recovered.
// +optional
RecoverPanic *bool `json:"recoverPanic,omitempty"`
}

// DeploymentSpec defines the properties that can be enabled on the Deployment for the provider.
type DeploymentSpec struct {
// Number of desired pods. This is a pointer to distinguish between explicit zero and not specified. Defaults to 1.
Expand Down
Loading

0 comments on commit 29f4bd3

Please sign in to comment.