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

MCO-679: MCO-830: Managed boot images MVP #4083

Merged
merged 5 commits into from
Jan 8, 2024
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
15 changes: 15 additions & 0 deletions cmd/machine-config-controller/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
containerruntimeconfig "github.com/openshift/machine-config-operator/pkg/controller/container-runtime-config"
"github.com/openshift/machine-config-operator/pkg/controller/drain"
kubeletconfig "github.com/openshift/machine-config-operator/pkg/controller/kubelet-config"
machinesetbootimage "github.com/openshift/machine-config-operator/pkg/controller/machine-set-boot-image"
"github.com/openshift/machine-config-operator/pkg/controller/node"
"github.com/openshift/machine-config-operator/pkg/controller/render"
"github.com/openshift/machine-config-operator/pkg/controller/template"
Expand Down Expand Up @@ -87,6 +88,9 @@ func runStartCmd(_ *cobra.Command, _ []string) {
ctrlctx.OpenShiftConfigKubeNamespacedInformerFactory.Start(ctrlctx.Stop)
ctrlctx.OperatorInformerFactory.Start(ctrlctx.Stop)
ctrlctx.ConfigInformerFactory.Start(ctrlctx.Stop)
ctrlctx.KubeNamespacedInformerFactory.Start(ctrlctx.Stop)
ctrlctx.MachineInformerFactory.Start(ctrlctx.Stop)
ctrlctx.KubeMAOSharedInformer.Start(ctrlctx.Stop)

close(ctrlctx.InformersStarted)

Expand Down Expand Up @@ -196,6 +200,17 @@ func createControllers(ctx *ctrlcommon.ControllerContext) []ctrlcommon.Controlle
ctx.ClientBuilder.MachineConfigClientOrDie("node-update-controller"),
ctx.FeatureGateAccess,
),
machinesetbootimage.New(
ctx.ClientBuilder.KubeClientOrDie("machine-set-boot-image-controller"),
ctx.ClientBuilder.MachineClientOrDie("machine-set-boot-image-controller"),
ctx.KubeNamespacedInformerFactory.Core().V1().ConfigMaps(),
ctx.MachineInformerFactory.Machine().V1beta1().Machines(),
ctx.MachineInformerFactory.Machine().V1beta1().MachineSets(),
ctx.KubeMAOSharedInformer.Core().V1().Secrets(),
ctx.ConfigInformerFactory.Config().V1().Infrastructures(),
ctx.KubeInformerFactory.Core().V1().Nodes(),
ctx.FeatureGateAccess,
),
)

return controllers
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ require (
github.com/coreos/ignition v0.35.0
github.com/coreos/ignition/v2 v2.15.0
github.com/coreos/rpmostree-client-go v0.0.0-20230914135003-fae0786302f7
github.com/coreos/stream-metadata-go v0.4.3
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
github.com/fsnotify/fsnotify v1.6.0
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ github.com/coreos/ignition/v2 v2.15.0 h1:v2fQ6QvkcAF+La5PHHpnpBS1eGZo+LYL1wTOPvD
github.com/coreos/ignition/v2 v2.15.0/go.mod h1:+7BiKurzCFg3P427Ml0wqnKzIuhLimnil6LhFV2DkJM=
github.com/coreos/rpmostree-client-go v0.0.0-20230914135003-fae0786302f7 h1:gpIn0B0F00GJPlI1iPjJbHMS01QoxDs7Bf8UgH9D3wg=
github.com/coreos/rpmostree-client-go v0.0.0-20230914135003-fae0786302f7/go.mod h1:WiAXRoGnl4Lwr7OM5izCLWMLH6Y43sYWJREoeeHEg4E=
github.com/coreos/stream-metadata-go v0.4.3 h1:5GykJ8dtZSx1rdlzEAiDVzA73cwmUF3ceTuIP293L6E=
github.com/coreos/stream-metadata-go v0.4.3/go.mod h1:fMObQqQm8Ku91G04btKzEH3AsdP1mrAb986z9aaK0tE=
github.com/coreos/vcontext v0.0.0-20190529201340-22b159166068/go.mod h1:E+6hug9bFSe0KZ2ZAzr8M9F5JlArJjv5D1JS7KSkPKE=
github.com/coreos/vcontext v0.0.0-20191017033345-260217907eb5/go.mod h1:E+6hug9bFSe0KZ2ZAzr8M9F5JlArJjv5D1JS7KSkPKE=
github.com/coreos/vcontext v0.0.0-20230201181013-d72178a18687 h1:uSmlDgJGbUB0bwQBcZomBTottKwEDF5fF8UjSwKSzWM=
Expand Down
6 changes: 6 additions & 0 deletions internal/clients/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
buildclientset "github.com/openshift/client-go/build/clientset/versioned"
configclientset "github.com/openshift/client-go/config/clientset/versioned"
imageclientset "github.com/openshift/client-go/image/clientset/versioned"
mapiclientset "github.com/openshift/client-go/machine/clientset/versioned"
mcfgclientset "github.com/openshift/client-go/machineconfiguration/clientset/versioned"
operatorclientset "github.com/openshift/client-go/operator/clientset/versioned"
apiext "k8s.io/apiextensions-apiserver/pkg/client/clientset/clientset"
Expand Down Expand Up @@ -66,6 +67,11 @@ func (cb *Builder) ImageClientOrDie(name string) imageclientset.Interface {
return imageclientset.NewForConfigOrDie(rest.AddUserAgent(cb.config, name))
}

// MachineClientOrDie returns the machine api client interface for machine api objects.
func (cb *Builder) MachineClientOrDie(name string) mapiclientset.Interface {
return mapiclientset.NewForConfigOrDie(rest.AddUserAgent(cb.config, name))
}

// GetBuilderConfig returns a copy of the builders *rest.Config
func (cb *Builder) GetBuilderConfig() *rest.Config {
return rest.CopyConfig(cb.config)
Expand Down
6 changes: 6 additions & 0 deletions manifests/machineconfigcontroller/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ rules:
- apiGroups: ["apps"]
resources: ["daemonsets"]
verbs: ["get"]
- apiGroups: ["machine.openshift.io"]
resources: ["machinesets"]
verbs: ["get", "list", "watch", "patch"]
- apiGroups: ["machine.openshift.io"]
resources: ["machines"]
verbs: ["list","watch"]
- apiGroups:
- authentication.k8s.io
resources:
Expand Down
9 changes: 9 additions & 0 deletions pkg/controller/common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,13 @@ const (

// MachineConfigRoleLabel is the role on MachineConfigs, used to select for pools
MachineConfigRoleLabel = "machineconfiguration.openshift.io/role"

// BootImagesConfigMapName is a Configmap of golden bootimages, updated by CVO on an upgrade
BootImagesConfigMapName = "coreos-bootimages"

// MCOVersionHashKey is the key for indexing the MCO git version hash stored in the bootimages configmap
MCOVersionHashKey = "MCOVersionHash"

// MCOReleaseImageVersionKey is the key for indexing the MCO release version stored in the bootimages configmap
MCOReleaseImageVersionKey = "MCOReleaseImageVersion"
)
6 changes: 6 additions & 0 deletions pkg/controller/common/controller_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

configinformers "github.com/openshift/client-go/config/informers/externalversions"
machineinformersv1beta1 "github.com/openshift/client-go/machine/informers/externalversions"
mcfginformers "github.com/openshift/client-go/machineconfiguration/informers/externalversions"

operatorinformers "github.com/openshift/client-go/operator/informers/externalversions"
Expand Down Expand Up @@ -56,6 +57,7 @@ type ControllerContext struct {
ConfigInformerFactory configinformers.SharedInformerFactory
OperatorInformerFactory operatorinformers.SharedInformerFactory
KubeMAOSharedInformer informers.SharedInformerFactory
MachineInformerFactory machineinformersv1beta1.SharedInformerFactory

FeatureGateAccess featuregates.FeatureGateAccess

Expand All @@ -75,6 +77,7 @@ func CreateControllerContext(ctx context.Context, cb *clients.Builder) *Controll
apiExtClient := cb.APIExtClientOrDie("apiext-shared-informer")
configClient := cb.ConfigClientOrDie("config-shared-informer")
operatorClient := cb.OperatorClientOrDie("operator-shared-informer")
machineClient := cb.MachineClientOrDie("machine-shared-informer")
sharedInformers := mcfginformers.NewSharedInformerFactory(client, resyncPeriod()())
sharedNamespacedInformers := mcfginformers.NewFilteredSharedInformerFactory(client, resyncPeriod()(), MCONamespace, nil)
kubeSharedInformer := informers.NewSharedInformerFactory(kubeClient, resyncPeriod()())
Expand Down Expand Up @@ -103,6 +106,8 @@ func CreateControllerContext(ctx context.Context, cb *clients.Builder) *Controll
apiextinformers.WithNamespace(MCONamespace), apiextinformers.WithTweakListOptions(assignFilterLabels))
configSharedInformer := configinformers.NewSharedInformerFactory(configClient, resyncPeriod()())
operatorSharedInformer := operatorinformers.NewSharedInformerFactory(operatorClient, resyncPeriod()())
machineSharedInformer := machineinformersv1beta1.NewSharedInformerFactoryWithOptions(machineClient, resyncPeriod()(), machineinformersv1beta1.WithNamespace("openshift-machine-api"))

desiredVersion := version.ReleaseVersion
missingVersion := "0.0.1-snapshot"

Expand Down Expand Up @@ -133,6 +138,7 @@ func CreateControllerContext(ctx context.Context, cb *clients.Builder) *Controll
APIExtInformerFactory: apiExtSharedInformer,
ConfigInformerFactory: configSharedInformer,
OperatorInformerFactory: operatorSharedInformer,
MachineInformerFactory: machineSharedInformer,
Stop: ctx.Done(),
InformersStarted: make(chan struct{}),
ResyncPeriod: resyncPeriod(),
Expand Down
Loading