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

✨Bump CAPI to v1.6.0-rc.1 #308

Merged
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ GOTESTSUM_VER := v1.6.4
GOTESTSUM_BIN := gotestsum
GOTESTSUM := $(TOOLS_BIN_DIR)/$(GOTESTSUM_BIN)-$(GOTESTSUM_VER)

GINKGO_VER := v2.12.0
GINKGO_VER := v2.13.1
GINKGO_BIN := ginkgo
GINKGO := $(TOOLS_BIN_DIR)/$(GINKGO_BIN)-$(GINKGO_VER)

Expand Down Expand Up @@ -331,6 +331,7 @@ generate-go: $(CONTROLLER_GEN) ## Runs Go related generate targets for the opera
.PHONY: generate-manifests
generate-manifests: $(CONTROLLER_GEN) ## Generate manifests for the operator e.g. CRD, RBAC etc.
$(CONTROLLER_GEN) \
paths=./cmd \
paths=./api/... \
paths=./internal/controller/... \
paths=./internal/webhook/... \
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha2/addonprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ type AddonProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []AddonProvider `json:"items"`
}

func init() {
objectTypes = append(objectTypes, &AddonProvider{}, &AddonProviderList{})
}
4 changes: 4 additions & 0 deletions api/v1alpha2/bootstrapprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ type BootstrapProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []BootstrapProvider `json:"items"`
}

func init() {
objectTypes = append(objectTypes, &BootstrapProvider{}, &BootstrapProviderList{})
}
4 changes: 4 additions & 0 deletions api/v1alpha2/controlplaneprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ type ControlPlaneProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []ControlPlaneProvider `json:"items"`
}

func init() {
objectTypes = append(objectTypes, &ControlPlaneProvider{}, &ControlPlaneProviderList{})
}
4 changes: 4 additions & 0 deletions api/v1alpha2/coreprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ type CoreProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []CoreProvider `json:"items"`
}

func init() {
objectTypes = append(objectTypes, &CoreProvider{}, &CoreProviderList{})
}
11 changes: 3 additions & 8 deletions api/v1alpha2/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,13 @@ var (

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme

objectTypes = []runtime.Object{}
)

// Adds the list of known types to api.Scheme.
func addKnownTypes(scheme *runtime.Scheme) error {
scheme.AddKnownTypes(GroupVersion,
&CoreProvider{}, &CoreProviderList{},
&BootstrapProvider{}, &BootstrapProviderList{},
&ControlPlaneProvider{}, &ControlPlaneProviderList{},
&InfrastructureProvider{}, &InfrastructureProviderList{},
&AddonProvider{}, &AddonProviderList{},
)

scheme.AddKnownTypes(GroupVersion, objectTypes...)
metav1.AddToGroupVersion(scheme, GroupVersion)

return nil
Expand Down
4 changes: 4 additions & 0 deletions api/v1alpha2/infrastructureprovider_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ type InfrastructureProviderList struct {
metav1.ListMeta `json:"metadata,omitempty"`
Items []InfrastructureProvider `json:"items"`
}

func init() {
objectTypes = append(objectTypes, &InfrastructureProvider{}, &InfrastructureProviderList{})
}
85 changes: 55 additions & 30 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ package main
import (
"flag"
"fmt"
"net/http"
"os"
goruntime "runtime"
"time"

"github.com/spf13/pflag"
Expand All @@ -34,11 +34,14 @@ import (
"sigs.k8s.io/cluster-api-operator/internal/webhook"
clusterv1 "sigs.k8s.io/cluster-api/api/v1beta1"
clusterctlv1 "sigs.k8s.io/cluster-api/cmd/clusterctl/api/v1alpha3"
"sigs.k8s.io/cluster-api/util/flags"
"sigs.k8s.io/cluster-api/version"
ctrl "sigs.k8s.io/controller-runtime"
cache "sigs.k8s.io/controller-runtime/pkg/cache"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/healthz"
ctrlwebhook "sigs.k8s.io/controller-runtime/pkg/webhook"

operatorv1alpha1 "sigs.k8s.io/cluster-api-operator/api/v1alpha1"
operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha2"
Expand All @@ -51,18 +54,20 @@ var (
setupLog = ctrl.Log.WithName("setup")

// flags.
metricsBindAddr string
enableLeaderElection bool
leaderElectionLeaseDuration time.Duration
leaderElectionRenewDeadline time.Duration
leaderElectionRetryPeriod time.Duration
watchFilterValue string
watchNamespace string
profilerAddress string
enableContentionProfiling bool
concurrencyNumber int
syncPeriod time.Duration
webhookPort int
webhookCertDir string
healthAddr string
diagnosticsOptions = flags.DiagnosticsOptions{}
)

func init() {
Expand All @@ -78,9 +83,6 @@ func init() {

// InitFlags initializes the flags.
func InitFlags(fs *pflag.FlagSet) {
fs.StringVar(&metricsBindAddr, "metrics-bind-addr", "localhost:8080",
"The address the metric endpoint binds to.")

fs.BoolVar(&enableLeaderElection, "leader-elect", false,
"Enable leader election for controller manager. Enabling this will ensure there is only one active controller manager.")

Expand All @@ -96,9 +98,15 @@ func InitFlags(fs *pflag.FlagSet) {
fs.StringVar(&watchFilterValue, "watch-filter", "",
fmt.Sprintf("Label value that the controller watches to reconcile cluster-api objects. Label key is always %s. If unspecified, the controller watches for all cluster-api objects.", clusterv1.WatchLabel))

fs.StringVar(&watchNamespace, "namespace", "",
"Namespace that the controller watches to reconcile cluster-api objects. If unspecified, the controller watches for cluster-api objects across all namespaces.")

fs.StringVar(&profilerAddress, "profiler-address", "",
"Bind address to expose the pprof profiler (e.g. localhost:6060)")

fs.BoolVar(&enableContentionProfiling, "contention-profiling", false,
"Enable block profiling")

fs.IntVar(&concurrencyNumber, "concurrency", 1,
"Number of core resources to process simultaneously")

Expand All @@ -112,6 +120,8 @@ func InitFlags(fs *pflag.FlagSet) {

fs.StringVar(&healthAddr, "health-addr", ":9440",
"The address the health endpoint binds to.")

flags.AddDiagnosticsOptions(fs, &diagnosticsOptions)
}

func main() {
Expand All @@ -120,37 +130,52 @@ func main() {
pflag.Parse()

ctrl.SetLogger(klogr.New())
restConfig := ctrl.GetConfigOrDie()

if profilerAddress != "" {
klog.Infof("Profiler listening for requests at %s", profilerAddress)
diagnosticsOpts := flags.GetDiagnosticsOptions(diagnosticsOptions)

go func() {
server := &http.Server{
Addr: profilerAddress,
ReadHeaderTimeout: 3 * time.Second,
}
var watchNamespaces map[string]cache.Config
if watchNamespace != "" {
watchNamespaces = map[string]cache.Config{
watchNamespace: {},
}
}

klog.Info(server.ListenAndServe())
}()
if enableContentionProfiling {
goruntime.SetBlockProfileRate(1)
}

mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
Scheme: scheme,
MetricsBindAddress: metricsBindAddr,
LeaderElection: enableLeaderElection,
LeaderElectionID: "controller-leader-election-capi-operator",
LeaseDuration: &leaderElectionLeaseDuration,
RenewDeadline: &leaderElectionRenewDeadline,
RetryPeriod: &leaderElectionRetryPeriod,
SyncPeriod: &syncPeriod,
ClientDisableCacheFor: []client.Object{
&corev1.ConfigMap{},
&corev1.Secret{},
},
Port: webhookPort,
CertDir: webhookCertDir,
ctrlOptions := ctrl.Options{
Scheme: scheme,
LeaderElection: enableLeaderElection,
LeaderElectionID: "controller-leader-election-capi-operator",
LeaseDuration: &leaderElectionLeaseDuration,
RenewDeadline: &leaderElectionRenewDeadline,
RetryPeriod: &leaderElectionRetryPeriod,
HealthProbeBindAddress: healthAddr,
})
PprofBindAddress: profilerAddress,
Metrics: diagnosticsOpts,
Cache: cache.Options{
DefaultNamespaces: watchNamespaces,
SyncPeriod: &syncPeriod,
},
Client: client.Options{
Cache: &client.CacheOptions{
DisableFor: []client.Object{
&corev1.ConfigMap{},
&corev1.Secret{},
},
},
},
WebhookServer: ctrlwebhook.NewServer(
ctrlwebhook.Options{
Port: webhookPort,
CertDir: webhookCertDir,
},
),
}

mgr, err := ctrl.NewManager(restConfig, ctrlOptions)
if err != nil {
setupLog.Error(err, "unable to start manager")
os.Exit(1)
Expand Down
6 changes: 6 additions & 0 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@ spec:
containers:
- command:
- /manager
args:
- "--leader-elect"
image: controller:latest
name: manager
ports:
- containerPort: 8443
name: metrics
protocol: TCP
resources:
limits:
cpu: 100m
Expand Down
1 change: 0 additions & 1 deletion config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: manager-role
rules:
- apiGroups:
Expand Down
2 changes: 2 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@ spec:
- --metrics-bind-addr=:8080
- --leader-elect
- --leader-elect-retry-period=5s
- "--diagnostics-address=${CAPI_OPERATOR_DIAGNOSTICS_ADDRESS:=:8443}"
- "--insecure-diagnostics=${CAPI_OPERATOR_INSECURE_DIAGNOSTICS:=false}"
- --v=5
env:...
```
Expand Down
Loading
Loading