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

🌱 Add option to skip rancher pre-requisites #705

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
2 changes: 2 additions & 0 deletions charts/rancher-turtles/templates/pre-install-job.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{{- if index .Values "rancherTurtles" "features" "embedded-capi" "disabled" }}
{{- if index .Values "rancherTurtles" "rancherInstalled"}}
---
apiVersion: management.cattle.io/v3
kind: Feature
Expand All @@ -10,6 +11,7 @@ metadata:
spec:
value: false
{{- end }}
{{- end }}
{{- if index .Values "rancherTurtles" "features" "rancher-webhook" "cleanup" }}
---
apiVersion: v1
Expand Down
1 change: 1 addition & 0 deletions charts/rancher-turtles/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ rancherTurtles:
namespace: rancher-turtles-system
managerArguments: []
imagePullSecrets: []
rancherInstalled: true
features:
cluster-api-operator:
cleanup: true
Expand Down
4 changes: 3 additions & 1 deletion internal/controllers/capiprovider_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
"sigs.k8s.io/controller-runtime/pkg/log"

operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha2"
Expand Down Expand Up @@ -96,8 +97,9 @@ func (r *CAPIProviderReconciler) patchStatus(ctx context.Context, capiProvider *
}

// SetupWithManager sets up the controller with the Manager.
func (r *CAPIProviderReconciler) SetupWithManager(_ context.Context, mgr ctrl.Manager) (err error) {
func (r *CAPIProviderReconciler) SetupWithManager(_ context.Context, mgr ctrl.Manager, options controller.Options) (err error) {
b := ctrl.NewControllerManagedBy(mgr).
WithOptions(options).
For(&turtlesv1.CAPIProvider{})

resources := []client.Object{
Expand Down
3 changes: 2 additions & 1 deletion internal/controllers/capiprovider_controller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
operatorv1 "sigs.k8s.io/cluster-api-operator/api/v1alpha2"
"sigs.k8s.io/cluster-api/util/conditions"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/controller"
. "sigs.k8s.io/controller-runtime/pkg/envtest/komega"
)

Expand All @@ -53,7 +54,7 @@ var _ = Describe("Reconcile CAPIProvider", func() {
Scheme: testEnv.GetScheme(),
}

Expect(r.SetupWithManager(ctx, testEnv.Manager)).ToNot(HaveOccurred())
Expect(r.SetupWithManager(ctx, testEnv.Manager, controller.Options{})).ToNot(HaveOccurred())
})

It("Should create infrastructure docker provider and secret", func() {
Expand Down
11 changes: 9 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) {
RancherClient: rancherClient,
}).SetupWithManager(ctx, mgr, controller.Options{
MaxConcurrentReconciles: concurrencyNumber,
CacheSyncTimeout: maxDuration,
}); err != nil {
setupLog.Error(err, "unable to create rancher management v3 cleanup controller")
os.Exit(1)
Expand All @@ -272,7 +273,10 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) {
if err := (&controllers.RancherKubeconfigSecretReconciler{
Client: mgr.GetClient(),
WatchFilterValue: watchFilterValue,
}).SetupWithManager(ctx, mgr, controller.Options{MaxConcurrentReconciles: concurrencyNumber}); err != nil {
}).SetupWithManager(ctx, mgr, controller.Options{
MaxConcurrentReconciles: concurrencyNumber,
CacheSyncTimeout: maxDuration,
}); err != nil {
setupLog.Error(err, "unable to create Rancher kubeconfig secret controller")
os.Exit(1)
}
Expand All @@ -283,7 +287,10 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) {
if err := (&controllers.CAPIProviderReconciler{
Client: mgr.GetClient(),
Scheme: scheme,
}).SetupWithManager(ctx, mgr); err != nil {
}).SetupWithManager(ctx, mgr, controller.Options{
MaxConcurrentReconciles: concurrencyNumber,
CacheSyncTimeout: maxDuration,
}); err != nil {
setupLog.Error(err, "unable to create CAPI Provider controller")
os.Exit(1)
}
Expand Down