Commit Graph

38 Commits

Author SHA1 Message Date
Alexander Demicev 9c212ea32a
Merge all main logic in one file (#270) 2022-12-01 14:59:11 +01:00
David Cassany Viladomat ff661e086f
Change the helm chart oci reference to be aligned with other elemental images (#268) (#269)
Signed-off-by: David Cassany <dcassany@suse.com>
(cherry picked from commit 242f3cc3ef)
2022-11-30 12:27:09 +01:00
Francesco Giudici 5df274078b
[controller_runtime] operator/registration: switch to Kubebuilder client (#256)
* operator/registration: switch to Kubebuilder client

Fixes #239

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* operator/registration: adapt tests to Kubebuilder client

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* unit-tests: vendor controller-runtime fake client

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* operator: add yaml annotations for correct marshalling

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* operator/RBAC: add "get" verb to ServiceAccount resources

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* operator: generate rbac

make generate-manifests
make build-rbac

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* Add elementalcli package

Create a separate package to deal with elemental-cli installation.
This brings the elemental-cli functions declared in the config package
to a new package that just parses a map[string]interface argument.

This is a step to enable usage of the elemental-cli functions with the
new elementalv1.Config.Elemental.Install type.

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* register: switch to Kubebuilder api

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* register: add mapstructure annotations for correct marshalling

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* register: reduce complexity of the run function

Make linter happy:
"cyclomatic complexity 16 of func `run` is high (> 15) (gocyclo)"

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

* register: drop io/ioutil in favor of os package

io/ioutil is deprecated

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-11-28 17:34:47 +01:00
David Cassany Viladomat 5757f2d82f
Add a rate limiter to managedosversionchannel reconciler (#260)
This commit adds a rate limiter to the ManagedOSVersionChannel controller to prevent
stacking reconcile loops over the same resource in fast rates (doesn't make sense for a
ManagedOSVersionChannel). By default the controller runtime already includes an
equivalent rate limiter, but starts in the range of milliseconds, starting the exponential
rate limiter in the range of seconds is more than enough in this context.

In addition it drops the failures counter in the resource. This counter was supposed to
be used to limit the number attempts to sync in case of failure. This was a bad design,
status should not keep a counter like this as any change in status triggers a new
immediate reconcile loop, hence the counter was reaching the maximum as fast as the
controller runtime was executing reconcile loops without any rate limiter (rate limiter
applies only when there are no changes including status).

For now I think we can just live without the setting any maxium for failures. If we ever
need it I believe it should be coded and tracked within the controller itself, not in each
resource as this prevents the reconcile loop of being idempotent. Alternatively we could
prevent triggering the reconcile loop on status changes, however this prevents
reconciling if any third party (or user from the kubectl client) changes a resource status.

Fixes #257
Part of #240

Signed-off-by: David Cassany <dcassany@suse.com>
2022-11-22 15:40:15 +01:00
David Cassany Viladomat 5b68534515
Improve syncer (#252)
This commit adds few changes on the syncer logic:

* Makes use of ManagedOSVersionChannel status reason to track if there
  is an on going synchronization rather than polling for the existence of a synchronization pod or not.

* Adds a logic to stop trying to synchronize after 4 consecutive attempts.
  If it exceeds the maximum it just programs the next re-sync after the given sync
  interval instead of immediately retrying.

* Adds some logging and comments here and there.

Signed-off-by: David Cassany <dcassany@suse.com>
2022-11-18 14:33:12 +01:00
David Cassany Viladomat ed268ce451
New syncer logic (#245)
* Implement syncer logic as part of the ManagedOSVersionChannel controller

  This commit adds the logic to synchronize managedosversionchannels
  within the already existing controller.

* make generate
* make build-manifests
* Update chart
* update e2e tests

Signed-off-by: David Cassany <dcassany@suse.com>
2022-11-16 18:38:23 +01:00
Alexander Demicev db7d0dd68e
Add remaining controllers (#232)
* Update vendor

* Run generation tasks

* Minor fixes in Makefile

* Remove old code

* Add remaning controllers

* Minor e2e tests improvements

* Switch osversionchannel syncer to controll runtime

* Minor fixes in controllers

* Fix unit tests
2022-11-10 11:26:34 +01:00
Alexander Demicev c81f50ba93 Kubebuilder: Add remaining API types (#225)
* Add remaining API types

* Run generate tasks
2022-10-27 12:29:27 +02:00
Alexander Demicev 0fde15069d Kubebuilder: Add machine registration controller (#206)
* Add new package to Dockerfile

* Update dependencies

* Add unit test helpers

* Add new machine registration controller

* Remove old machine registration controller

* Add rbac tag for secrets

* Fix container argument in chart

* Add labels to all created resources
2022-10-27 12:28:55 +02:00
Alexander Demicev 286e163838 Kubebuilder: Run new code and generate RBAC (#203)
* Add new command for running kubebuilder based code

* Add make task for generating RBAC from code

* Add new directory to makefile
2022-10-27 12:27:35 +02:00
Alexander Demicev 03988e1ef8 Kubebuilder: Add make tasks for different tools (#194)
* Add tools binaries to Makefile

* Run make generate

* Update github workflows

* Impove path to tools
2022-10-27 12:27:27 +02:00
Francesco Giudici 05800af134 operator: enforce ServiceAccount's Secret link
If the ServiceAccount for the newly created MachineRegistration
is already there, ensure it has a link to the newly created  Secret

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-10-20 09:12:45 +02:00
Michal Jura fc1810baf7
Audit and update elemental-operator RBAC ClusterRole (#196)
It seems that elemental-operator RBAC ClusterRole was too wide.
This change is simplifying it and removing unneeded privileges.

Fixes #https://github.com/rancher/elemental-operator/issues/186

Signed-off-by: Michal Jura <mjura@suse.com>

Signed-off-by: Michal Jura <mjura@suse.com>
2022-10-11 14:12:42 +02:00
David Cassany Viladomat 1af1d0709e
Add vendor for obs integration (#198)
These changes are required to facilitate OBS code updates and builds by simply triggering OBS services. This allows updating code and rebuild in OBS based on github events such as on tag, on merge, on push...

Signed-off-by: David Cassany <dcassany@suse.com>
2022-10-07 14:23:11 +00:00
Michal Jura d8810c9407
Add elemental GlobalRole for Rancher UI (#187)
During elemental-operator helm installation, it has to be also added
Elemnetal Administator GlobalRole for Rancher UI users.

Fixes https://github.com/rancher/elemental/issues/332

Signed-off-by: Michal Jura <mjura@suse.com>

Signed-off-by: Michal Jura <mjura@suse.com>
2022-10-03 13:45:33 +02:00
Itxaka 946309b781
Fix secretname for the apiService (#153)
This has to be a known value that we can watch for in the operator, this
doesnt require to be unique per deployment as several processes can
watch the same secret

Signed-off-by: Itxaka <igarcia@suse.com>

Signed-off-by: Itxaka <igarcia@suse.com>
2022-09-01 16:26:56 +02:00
Itxaka 41e9c17915
Enable deploying operator replicas (#150)
Enables deploying multiple operators replicas.

Changes tests to account and test this

Chart changes:
 - Make any fixed names default to the release name. As release name has
   to be unique per namespace, this is a good practice instead of
   hardcoding whatever name we want. This shouldnt affect anything as
   the full chart uses that by default now.

Signed-off-by: Itxaka <igarcia@suse.com>

Signed-off-by: Itxaka <igarcia@suse.com>
2022-08-31 16:36:56 +02:00
Itxaka 01fd853832
Remove default value for flag and expand description (#126)
Make sure we have a decent description for the --operator-image flag as
that is used down the line by the syncer to run the display command and
gather the results from the version syncer.

Also remove the default value for the flag. It makes no sense to have a
default value if we mark a flag as required, as that value will always
be overwritten by the flag.

Signed-off-by: Itxaka <igarcia@suse.com>
2022-08-10 14:31:54 +02:00
Itxaka 7e71181cc4
[chart] only add default-registry if specified (#128) 2022-08-10 10:31:37 +00:00
Itxaka 5b64a774ea
Set the proper namespace (#117) 2022-08-05 14:45:59 +00:00
Michal Jura 9b9844b743
Add README to elemetal-operator helm chart (#56) 2022-07-22 08:48:08 +02:00
Itxaka e87eb80c9c
Use cacert from rancher and use serverl-url from rancher (#36)
* Generate v3.Setting code

Signed-off-by: Itxaka <igarcia@suse.com>

* Use the rancher cacerts for the registration

Also drops the cacert passing via chart, adds proper permissions to the
settings resource, adds the cache index and checks that indeed we are
returning a cacert on the registration url

Signed-off-by: Itxaka <igarcia@suse.com>

* fix lint

Signed-off-by: Itxaka <igarcia@suse.com>

* Drop manual rancherl-url and get the rancher url automatically

Drop any manual setup of rancher-url and use the settings to get the set
rancher-url

Signed-off-by: Itxaka <igarcia@suse.com>

* Small fix for getRancherCACert

Signed-off-by: Itxaka <igarcia@suse.com>

* Fix test setting the wrong url

Signed-off-by: Itxaka <igarcia@suse.com>
2022-07-13 16:11:21 +02:00
Itxaka 7f6baefb2a Restore sync-namespaces
There seems to have some confusion between the namespace of the operator
to run on and the namespaces we want the operator to watch

This restores the sync_namespaces so the operator can watch all
namespaces and sets teh namespace option to be where the operator is
runnig, needed for things like the registration url to be properly
served

Signed-off-by: Itxaka <igarcia@suse.com>
2022-07-11 15:13:22 +02:00
Itxaka caab84f5e2 Allow overriding namespace to watch and debug status for operator
Signed-off-by: Itxaka <igarcia@suse.com>
2022-07-11 15:12:19 +02:00
Itxaka 26464f0e69 Rework tests workflow
Signed-off-by: Itxaka <igarcia@suse.com>
2022-07-11 15:12:19 +02:00
Itxaka 5c5f1150cb Fix all the test, remove leftovers from transition
Remove all the mentions to rancheros-operator in tests, imports and
dependencies.

Restore e2e scripts and test targets on makefile

Fix all lint issues

Signed-off-by: Itxaka <igarcia@suse.com>
2022-07-11 15:12:19 +02:00
Jacob Payne c5a5dbd77f renamed to elemental-operator and switched to system agent 2022-06-30 16:01:13 +00:00
Ettore Di Giacinto f8b3ff8bb7
Set appropriate rules for broadcasting events
Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>
2022-04-07 16:00:24 +02:00
Ettore Di Giacinto 5de58017a1
Use operator image for wait and display hook
Also refactor out syncer code

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>
2022-04-06 15:00:06 +02:00
Ettore Di Giacinto e3488f833b
Implement Custom syncer
At the moment is collecting json output from logs for creating API data
and it's not a real controller. This will be fixed in a follow up.
Besides, relying on logging as we are doing it now, even with the
initContainer workaround is not correct as we
do not have guarantee from kubelet to store logs for us, so this is good
only for small amount of data.

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>
2022-04-06 11:37:45 +02:00
Itxaka 7c44515226 Set the default update to 60m
Signed-off-by: Itxaka <igarcia@suse.com>
2022-04-06 09:44:46 +02:00
Itxaka 55d32338be Add sync-interval flag
Signed-off-by: Itxaka <igarcia@suse.com>
2022-04-06 09:44:46 +02:00
Itxaka bcbe339e38 Use the same binary name across
There was a mix of ros-operator and rancheros-operator.

This patch fixes it so its always rancheros-operator, even
changing the repos to have the full name so everything matches

Signed-off-by: Itxaka <igarcia@suse.com>
2022-03-24 13:41:54 +01:00
Darren Shepherd 3f899e0784 Build custom ipxe and use hostbin for ros-operator 2021-11-08 22:16:28 -07:00
Darren Shepherd 901973e5f6 Add TPM and MachineRegister support 2021-10-29 23:08:26 -07:00
Darren Shepherd b00581c2d7 Various fixes 2021-10-22 23:22:09 -07:00
Darren Shepherd 4085b2977b Rename to rancher/os2 2021-10-20 12:19:44 -07:00
Darren Shepherd 5675644d9f Add operator 2021-10-20 10:58:54 -07:00