Skip to content

Commit

Permalink
operator/manager: allows disable Reconcile for CRDs
Browse files Browse the repository at this point in the history
With new flag `-controller.disableReconcileFor=vmauth,vmagent` it's possible to disable reconcile controllers for particular CRDs.

It's useful, if only specific subset of components should be managed by operator.

 Related issue:
#528

Signed-off-by: f41gh7 <[email protected]>
  • Loading branch information
f41gh7 committed Sep 29, 2024
1 parent ef366ce commit aba59ef
Show file tree
Hide file tree
Showing 19 changed files with 177 additions and 138 deletions.
1 change: 1 addition & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ aliases:

- [vmcluster](https://docs.victoriametrics.com/operator/resources/vmcluster): properly apply global container registry from configuration. It was ignored for `VMCluster` since `v0.48.0` release. See [this issue](https://github.com/VictoriaMetrics/operator/issues/1118) for details.
- [operator](https://docs.victoriametrics.com/operator/): updates default vlogs app version to v0.32.0
- [operator](https://docs.victoriametrics.com/operator/): adds new flag `--disableControllerForCRD`. It allows to disable reconcile controller for the given comma-separated list of CRD names. See [this issue](https://github.com/VictoriaMetrics/operator/issues/528) for details.

## [v0.48.2](https://github.com/VictoriaMetrics/operator/releases/tag/v0.48.2) - 27 Sep 2024

Expand Down
6 changes: 3 additions & 3 deletions docs/vars.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ aliases:
- /operator/vars/index.html
---
<!-- this doc autogenerated - don't edit it manually -->
updated at Fri Sep 27 13:40:34 UTC 2024
updated at Sun Sep 29 19:33:17 UTC 2024


| variable name | variable default value | variable required | variable description |
Expand All @@ -20,7 +20,7 @@ aliases:
| VM_CUSTOMCONFIGRELOADERIMAGE | victoriametrics/operator:config-reloader-v0.48.2 | false | - |
| VM_PSPAUTOCREATEENABLED | false | false | - |
| VM_VLOGSDEFAULT_IMAGE | victoriametrics/victoria-logs | false | - |
| VM_VLOGSDEFAULT_VERSION | v0.31.0-victorialogs | false | - |
| VM_VLOGSDEFAULT_VERSION | v0.32.0-victorialogs | false | - |
| VM_VLOGSDEFAULT_CONFIGRELOADIMAGE | - | false | ignored |
| VM_VLOGSDEFAULT_PORT | 9428 | false | - |
| VM_VLOGSDEFAULT_USEDEFAULTRESOURCES | true | false | - |
Expand Down Expand Up @@ -136,4 +136,4 @@ aliases:
| VM_PODWAITREADYINTERVALCHECK | 5s | false | Defines poll interval for pods ready check at statefulset rollout update |
| VM_FORCERESYNCINTERVAL | 60s | false | configures force resync interval for VMAgent, VMAlert, VMAlertmanager and VMAuth. |
| VM_ENABLESTRICTSECURITY | false | false | EnableStrictSecurity will add default `securityContext` to pods and containers created by operator Default PodSecurityContext include: 1. RunAsNonRoot: true 2. RunAsUser/RunAsGroup/FSGroup: 65534 '65534' refers to 'nobody' in all the used default images like alpine, busybox. If you're using customize image, please make sure '65534' is a valid uid in there or specify SecurityContext. 3. FSGroupChangePolicy: &onRootMismatch If KubeVersion>=1.20, use `FSGroupChangePolicy="onRootMismatch"` to skip the recursive permission change when the root of the volume already has the correct permissions 4. SeccompProfile: type: RuntimeDefault Use `RuntimeDefault` seccomp profile by default, which is defined by the container runtime, instead of using the Unconfined (seccomp disabled) mode. Default container SecurityContext include: 1. AllowPrivilegeEscalation: false 2. ReadOnlyRootFilesystem: true 3. Capabilities: drop: - all turn off `EnableStrictSecurity` by default, see https://github.com/VictoriaMetrics/operator/issues/749 for details |
[envconfig-sum]: 97c30e81298d2e6bde28647c913b9b88
[envconfig-sum]: bcf2b739473583d36da69a3c4c3835cf
8 changes: 8 additions & 0 deletions internal/controller/operator/vlogs_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ type VLogsReconciler struct {
BaseConf *config.BaseOperatorConf
}

// Init implements crdController interface
func (r *VLogsReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VLogs")
r.OriginScheme = sc
r.BaseConf = cf
}

// Scheme implements interface.
func (r *VLogsReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/operator/vmagent_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ type VMAgentReconciler struct {
BaseConf *config.BaseOperatorConf
}

// Init implements crdController interface
func (r *VMAgentReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMAgent")
r.OriginScheme = sc
r.BaseConf = cf
}

// Reconcile general reconcile method
// +kubebuilder:rbac:groups=operator.victoriametrics.com,resources=vmagents,verbs=get;list;watch;create;update;patch;delete
// +kubebuilder:rbac:groups=operator.victoriametrics.com,resources=vmagents/status,verbs=get;update;patch
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/operator/vmalert_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ type VMAlertReconciler struct {
BaseConf *config.BaseOperatorConf
}

// Init implements crdController interface
func (r *VMAlertReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMAlert")
r.OriginScheme = sc
r.BaseConf = cf
}

// Scheme implements interface.
func (r *VMAlertReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/operator/vmalertmanager_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ type VMAlertmanagerReconciler struct {
BaseConf *config.BaseOperatorConf
}

// Init implements crdController interface
func (r *VMAlertmanagerReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMAlertmanager")
r.OriginScheme = sc
r.BaseConf = cf
}

// Scheme implements interface.
func (r *VMAlertmanagerReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ type VMAlertmanagerConfigReconciler struct {
BaseConf *config.BaseOperatorConf
}

// Init implements crdController interface
func (r *VMAlertmanagerConfigReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMAlertmanagerConfig")
r.OriginScheme = sc
r.BaseConf = cf
}

// Scheme implements interface.
func (r *VMAlertmanagerConfigReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/operator/vmauth_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ type VMAuthReconciler struct {
OriginScheme *runtime.Scheme
}

// Init implements crdController interface
func (r *VMAuthReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMAuth")
r.OriginScheme = sc
r.BaseConf = cf
}

// Scheme implements interface.
func (r *VMAuthReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/operator/vmcluster_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@ type VMClusterReconciler struct {
BaseConf *config.BaseOperatorConf
}

// Init implements crdController interface
func (r *VMClusterReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMCluster")
r.OriginScheme = sc
r.BaseConf = cf
}

// Scheme implements interface.
func (r *VMClusterReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
7 changes: 7 additions & 0 deletions internal/controller/operator/vmnodescrape_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ type VMNodeScrapeReconciler struct {
OriginScheme *runtime.Scheme
}

// Init implements crdController interface
func (r *VMNodeScrapeReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMNodeScrape")
r.OriginScheme = sc
}

// Scheme implements interface.
func (r *VMNodeScrapeReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
7 changes: 7 additions & 0 deletions internal/controller/operator/vmpodscrape_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ type VMPodScrapeReconciler struct {
OriginScheme *runtime.Scheme
}

// Init implements crdController interface
func (r *VMPodScrapeReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMPodScrape")
r.OriginScheme = sc
}

// Scheme implements interface.
func (r *VMPodScrapeReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
7 changes: 7 additions & 0 deletions internal/controller/operator/vmprobe_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ type VMProbeReconciler struct {
OriginScheme *runtime.Scheme
}

// Init implements crdController interface
func (r *VMProbeReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMProbe")
r.OriginScheme = sc
}

// Scheme implements interface.
func (r *VMProbeReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
7 changes: 7 additions & 0 deletions internal/controller/operator/vmrule_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ type VMRuleReconciler struct {
OriginScheme *runtime.Scheme
}

// Init implements crdController interface
func (r *VMRuleReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMRule")
r.OriginScheme = sc
}

// Scheme implements interface.
func (r *VMRuleReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
7 changes: 7 additions & 0 deletions internal/controller/operator/vmscrapeconfig_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ type VMScrapeConfigReconciler struct {
OriginScheme *runtime.Scheme
}

// Init implements crdController interface
func (r *VMScrapeConfigReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMScrapeConfig")
r.OriginScheme = sc
}

// Scheme implements interface.
func (r *VMScrapeConfigReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
7 changes: 7 additions & 0 deletions internal/controller/operator/vmservicescrape_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ type VMServiceScrapeReconciler struct {
OriginScheme *runtime.Scheme
}

// Init implements crdController interface
func (r *VMServiceScrapeReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMServiceScrape")
r.OriginScheme = sc
}

// Scheme implements interface.
func (r *VMServiceScrapeReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
8 changes: 8 additions & 0 deletions internal/controller/operator/vmsingle_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ type VMSingleReconciler struct {
BaseConf *config.BaseOperatorConf
}

// Init implements crdController interface
func (r *VMSingleReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMSingle")
r.OriginScheme = sc
r.BaseConf = cf
}

// Scheme implements interface.
func (r *VMSingleReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
7 changes: 7 additions & 0 deletions internal/controller/operator/vmstaticscrape_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,13 @@ type VMStaticScrapeReconciler struct {
OriginScheme *runtime.Scheme
}

// Init implements crdController interface
func (r *VMStaticScrapeReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMStaticScrape")
r.OriginScheme = sc
}

// Scheme implements interface.
func (r *VMStaticScrapeReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
7 changes: 7 additions & 0 deletions internal/controller/operator/vmuser_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,13 @@ type VMUserReconciler struct {
OriginScheme *runtime.Scheme
}

// Init implements crdController interface
func (r *VMUserReconciler) Init(rclient client.Client, l logr.Logger, sc *runtime.Scheme, cf *config.BaseOperatorConf) {
r.Client = rclient
r.Log = l.WithName("controller").WithName("VMUser")
r.OriginScheme = sc
}

// Scheme implements interface.
func (r *VMUserReconciler) Scheme() *runtime.Scheme {
return r.OriginScheme
Expand Down
Loading

0 comments on commit aba59ef

Please sign in to comment.