Commit Graph

54 Commits

Author SHA1 Message Date
Alexander Demicev 9c212ea32a
Merge all main logic in one file (#270) 2022-12-01 14:59:11 +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 c18f66d8b8
Drop requeuer, not needed anymore (#255)
* Drop requeuer, not needed anymore
* Improve logging

Signed-off-by: David Cassany <dcassany@suse.com>
2022-11-21 12:37:14 +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 d553a0883d Kubebuilder: Add machine inventory selector controller (#224)
* Add machine inventory selector controller

* Remove old machine inventory selector code
2022-10-27 12:30:03 +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
David Cassany Viladomat 7ea38a7df1
Only read yaml files included in the given directories (#215)
Signed-off-by: David Cassany <dcassany@suse.com>

Signed-off-by: David Cassany <dcassany@suse.com>
2022-10-18 10:27:18 +02:00
David Cassany Viladomat cdf406ef81
Allow custom config files for elemental-cli (#210)
* Allow custom config files for elemental-cli
* Update vendor folder

Signed-off-by: David Cassany <dcassany@suse.com>
2022-10-14 10:42:13 +02:00
Itxaka 17d9d21693
support command improvements (#173) 2022-09-22 10:26:59 +02:00
Itxaka 4fab515a30
Rework client to accept a ClientInterface (#166) 2022-09-07 10:39:26 +02:00
Francesco Giudici 5da3ac15ff register/operator: drop MachineInventory labels passed from the client
The right way to set labels for the MachineInventory objs is to set
them in the MachineRegistration:spec:machineInventoryLabels, which
will be processed by the operator.
Drop MachineRegistration spec:config:elemental:registration:labels.

Fixes #161

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-09-06 09:24:14 +02:00
Francesco Giudici 4ce5d77900 register: take control of the registration process
Till now, the attestation and communication with the elemental operator
were all demanded to the github.com/rancher-sandbox/go-tpm package.
Split TPM attestation from the communication with the elemental operator
demanding TPM authentication to the external library while taking full
control of the communication with the operator.

This doesn't introduce functional changes (so it will keep retrocompatibility
with the current elemental operator) and is a preparatory step to address
rancher/elemental-operator#5

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-08-31 16:09:20 +02:00
Francesco Giudici f0bd8f48d2 log: report elemental installation completion
Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-08-22 09:12:26 +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
David Cassany Viladomat 76f61f5ac6
Store all registration data on installation (#116)
Signed-off-by: David Cassany <dcassany@suse.com>
2022-08-04 16:29:03 +02:00
Itxaka 10d362193a
Add a elemental-support binary (#109)
* Add a elemental-support binary

Allows to gather info about the running node, hostname, k8s resources,
systemd logs, etc..

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

* lint

Signed-off-by: Itxaka <igarcia@suse.com>
2022-08-03 12:19:07 +02:00
Itxaka ea7884e8df
Produce 2 binaries instead of one (#99)
* Produce 2 binaries instead of one

This generates a different binary for the register command as to not
bundle it with the full operator.

On the makefile separated builds have been done for operator and
registry.

On the docker image a different container is created for the register
and pushed to a different repo as well.

For releases gorelease generates 2 different binaries.

Signed-off-by: Itxaka <igarcia@suse.com>
2022-08-01 15:08:23 +00:00
Francesco Giudici 53d463dbaf elemental-operator register: add some more logging
mainly more logs about reading config

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-07-22 18:07:18 +02:00
Itxaka f2ab68c3ca
[register] Check for path error before doing anything (#80) 2022-07-22 13:25:41 +00:00
David Cassany Viladomat cf20bc60bb
Make /oem/registration the default configuration dir (#81)
This commit uses /oem/registration as the default directory
to load configuration from in elemental-opertator register command

Signed-off-by: David Cassany <dcassany@suse.com>
2022-07-22 15:11:47 +02:00
David Cassany Viladomat 52c3cbbec2
Store registration yaml in installed system (#71)
Signed-off-by: David Cassany <dcassany@suse.com>
2022-07-21 11:42:13 +02:00
David Cassany Viladomat 79d957e1df
Adds support for cloud-config data in machine registration (#61)
Signed-off-by: David Cassany <dcassany@suse.com>
2022-07-20 10:42:08 +02:00
David Cassany Viladomat 6e2f20f3be
Pass debug flag to elemental client if requested (#58)
Signed-off-by: David Cassany <dcassany@suse.com>
2022-07-18 16:42:43 +02:00
David Cassany Viladomat 2381ebc55a
Do not attempt to install in already installed systems (#55)
Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>

Co-authored-by: David Cassany <d.cassany@suse.com>
2022-07-15 14:57:51 +00:00
Itxaka 618d3c4da3
Log the version, commit and commit date on start (#43) 2022-07-15 09:50:18 +00:00
David Cassany Viladomat bd811be876
Remove obsolete logic from former ros-installer (#45)
* Remove obsolete logic from former ros-installer

Signed-off-by: David Cassany <dcassany@suse.com>
2022-07-15 10:48:41 +02:00
Francesco Giudici a05a2dbae6 elemental-operator register: enable local plans
Enable local plans execution in the rancher-system-agent

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-07-14 17:28:56 +02:00
Francesco Giudici 602178c01d
elemental-operator register: allow cacert passed as file or data (#44)
We now process the cacert as a file path: the yaml file from kubernetes
anyway passes it as the acutal cert data. Manage both cases.

Signed-off-by: Francesco Giudici <francesco.giudici@suse.com>
2022-07-14 14:28:47 +02:00
Itxaka adfff7c91a
Some register fixes (#40)
* Some register fixes

 - Add debug flag for debug loggin
 - Add docs to command
 - Add docs to flags
 - Pass the cacert via a file, NOT via string
 - Rename var config so it doesnt clash with imported package name

Signed-off-by: Itxaka <igarcia@suse.com>
2022-07-13 17:05:19 +00:00
Francesco Giudici 62bac1d84e
elemental-operator register: add elemental cli call (#38)
The elemental-operator register command, after retrieving the config
registration will directly call the elemental cli to start the actual
installation process.

Co-authored-by: David Cassany <dcassany@suse.com>
Co-authored-by: Francesco Giudici <francesco.giudici@suse.com>

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

Co-authored-by: Itxaka <igarcia@suse.com>
2022-07-13 17:30:12 +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
David Cassany Viladomat 14d4d957cf
Share installation configuration structures (#24)
This commit makes sure elemental-operator and elemental-installer are
using the same structures to describe and define the elemental-cli
installation.

Signed-off-by: David Cassany <dcassany@suse.com>
2022-07-12 12:36:53 +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 e6ceda4928 Fix operator display output
For some reson copying the file to stdout produces an empty line which
breaks reading from it, restore it to how it was

Signed-off-by: Itxaka <igarcia@suse.com>
2022-07-11 15:12:19 +02:00
Itxaka 99679d1815 Set logrus to debug if debug is enabled
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
David Cassany Viladomat 1d97f14de7
Merge elemental installer (#20)
* Move main into a cmd/operator package
* Add elemental-installer
* Adding installer unit tests
* Update Makefile
* Update .github/workflows/unit-tests.yaml
* Adapat Dockerfile and golreleaser to keep releasing and building elemental-operator as they used to

Signed-off-by: David Cassany <dcassany@suse.com>
Co-authored-by: Itxaka <igarcia@suse.com>
2022-07-07 14:47:32 +02:00
Jacob Payne c5a5dbd77f renamed to elemental-operator and switched to system agent 2022-06-30 16:01:13 +00:00
Itxaka 26684d1888 Drop everything not needed for ros-operator
- Drops everything not needed for ros-operator
 - New simple Dockerfile
 - New jobs based on ros-operator only
 - Remove uneeded tests
 - Remove dependency on os2 images for integration tests
 - Use gorelease to release ros-operator binaries
 - Use docker to push ci images to ros-operator-ci registry on PR
 - Use docker to push master/tag images to ros-operator registry
 - Build chart indepently
 - Have a null test CI job for future integration tests

Signed-off-by: Itxaka <igarcia@suse.com>
2022-03-24 09:47:18 +01:00
Ettore Di Giacinto b1331abb2a
Add upgradeContainerSpec to ManagedOS and update wrangler (#66)
* Allow to specify a upgradeContainerSpec on ManagedOS

https://github.com/rancher-sandbox/os2/issues/59

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>

* Run go generate and update wrangler

Also pin golang.org/x/tools to latest, to workaround
https://github.com/golang/go/issues/37617

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>

* Update docs

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>

* Adapt to new wrangler signal context

9460166aed

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>

* Fixup license headers

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>
2022-03-23 18:27:39 +01:00
Itxaka 63eb85435a
Add reboot flag (#46) 2022-03-10 13:30:01 +01:00
Itxaka 9fed2edefc
Rework golangci-lint config and github CI (#34) 2022-03-03 09:16:03 +01:00
Ettore Di Giacinto b3dc177666
ros-installer: pick /oem/userdata by default
Fixes: #8

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>
2022-02-14 18:04:20 +01:00
Ettore Di Giacinto d99fca748a
Handle ENV var prefix rename, add tests for read config
Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>
2022-01-31 16:53:16 +01:00
Ettore Di Giacinto 97d58074ee
Refactor import paths
See: https://github.com/rancher-sandbox/cOS-toolkit/issues/1105

Signed-off-by: Ettore Di Giacinto <edigiacinto@suse.com>
2022-01-28 14:00:29 +01:00
Darren Shepherd f35b3697c3 Fix installation and trim packages 2021-11-03 22:06: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