mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-17 20:04:36 -05:00
4283601433
* helm: configure GCP cloud controller manager to search in all zones of a region
See also: d716fdd452/providers/gce/gce.go (L376-L380)
* operators: add nodeGroupName to ScalingGroup CRD
NodeGroupName is the human friendly name of the node group that will be exposed to customers via the Constellation config in the future.
* operators: support simple executor / scheduler to reconcile on non-k8s resources
* operators: add new return type for ListScalingGroups to support arbitrary node groups
* operators: ListScalingGroups should return additionally created node groups on AWS
* operators: ListScalingGroups should return additionally created node groups on Azure
* operators: ListScalingGroups should return additionally created node groups on GCP
* operators: ListScalingGroups should return additionally created node groups on unsupported CSPs
* operators: implement external scaling group reconciler
This controller scans the cloud provider infrastructure and changes k8s resources accordingly.
It creates ScaleSet resources when new node groups are created and deletes them if the node groups are removed.
* operators: no longer create scale sets when the operator starts
In the future, scale sets are created dynamically.
* operators: watch for node join/leave events using a controller
* operators: deploy new controllers
* docs: update auto scaling documentation with support for node groups
77 lines
2.3 KiB
Go
77 lines
2.3 KiB
Go
/*
|
|
Copyright (c) Edgeless Systems GmbH
|
|
|
|
SPDX-License-Identifier: AGPL-3.0-only
|
|
*/
|
|
|
|
package sgreconciler
|
|
|
|
import (
|
|
"context"
|
|
|
|
corev1 "k8s.io/api/core/v1"
|
|
"k8s.io/apimachinery/pkg/runtime"
|
|
"k8s.io/apimachinery/pkg/types"
|
|
ctrl "sigs.k8s.io/controller-runtime"
|
|
"sigs.k8s.io/controller-runtime/pkg/builder"
|
|
"sigs.k8s.io/controller-runtime/pkg/client"
|
|
"sigs.k8s.io/controller-runtime/pkg/event"
|
|
"sigs.k8s.io/controller-runtime/pkg/handler"
|
|
"sigs.k8s.io/controller-runtime/pkg/log"
|
|
"sigs.k8s.io/controller-runtime/pkg/predicate"
|
|
)
|
|
|
|
// NodeJoinWatcher watches node join / leave events.
|
|
type NodeJoinWatcher struct {
|
|
trigger func()
|
|
client.Client
|
|
Scheme *runtime.Scheme
|
|
}
|
|
|
|
// NewNodeJoinWatcher creates a new NodeJoinWatcher.
|
|
func NewNodeJoinWatcher(trigger func(), client client.Client, scheme *runtime.Scheme) *NodeJoinWatcher {
|
|
return &NodeJoinWatcher{
|
|
trigger: trigger,
|
|
Client: client,
|
|
Scheme: scheme,
|
|
}
|
|
}
|
|
|
|
//+kubebuilder:rbac:groups="",resources=nodes,verbs=get;list;watch;create;update;patch;delete
|
|
//+kubebuilder:rbac:groups="",resources=nodes/status,verbs=get
|
|
|
|
// Reconcile reconciles node join / leave events.
|
|
func (w *NodeJoinWatcher) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
|
|
logr := log.FromContext(ctx)
|
|
logr.Info("node has joined or left the cluster", "node", req.Name)
|
|
w.trigger()
|
|
|
|
return ctrl.Result{}, nil
|
|
}
|
|
|
|
// SetupWithManager sets up the controller with the Manager.
|
|
func (w *NodeJoinWatcher) SetupWithManager(mgr ctrl.Manager) error {
|
|
return ctrl.NewControllerManagedBy(mgr).
|
|
Named("node-join-watcher").
|
|
Watches(
|
|
client.Object(&corev1.Node{}),
|
|
handler.EnqueueRequestsFromMapFunc(func(ctx context.Context, obj client.Object) []ctrl.Request {
|
|
return []ctrl.Request{{
|
|
NamespacedName: types.NamespacedName{Name: obj.GetName()},
|
|
}}
|
|
}),
|
|
builder.WithPredicates(nodeJoinLeavePredicate()),
|
|
).
|
|
Complete(w)
|
|
}
|
|
|
|
// nodeJoinLeavePredicate returns a predicate that returns true if a node joins or leaves the cluster.
|
|
func nodeJoinLeavePredicate() predicate.Predicate {
|
|
return predicate.Funcs{
|
|
// CreateFunc is not specified => never filter out create events
|
|
// DeleteFunc is not specified => never filter out delete events
|
|
UpdateFunc: func(e event.UpdateEvent) bool { return false },
|
|
GenericFunc: func(e event.GenericEvent) bool { return false },
|
|
}
|
|
}
|