Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

[#574] Use k8s jobs to do scaledown #575

Closed
wants to merge 1 commit into from
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -2093,6 +2093,14 @@ spec:
- deployments/finalizers
verbs:
- update
- apiGroups:
- batch
resources:
- jobs
verbs:
- create
- delete
- list
- apiGroups:
- broker.amq.io
resources:
Expand Down
8 changes: 8 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ rules:
- deployments/finalizers
verbs:
- update
- apiGroups:
- batch
resources:
- jobs
verbs:
- create
- delete
- list
- apiGroups:
- broker.amq.io
resources:
Expand Down
9 changes: 9 additions & 0 deletions controllers/activemqartemisscaledown_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ type ActiveMQArtemisScaledownReconciler struct {
//+kubebuilder:rbac:groups=broker.amq.io,namespace=activemq-artemis-operator,resources=activemqartemisscaledowns,verbs=get;list;watch;create;update;patch;delete
//+kubebuilder:rbac:groups=broker.amq.io,namespace=activemq-artemis-operator,resources=activemqartemisscaledowns/status,verbs=get;update;patch
//+kubebuilder:rbac:groups=broker.amq.io,namespace=activemq-artemis-operator,resources=activemqartemisscaledowns/finalizers,verbs=update
//+kubebuilder:rbac:groups=batch,namespace=activemq-artemis-operator,resources=jobs,verbs=create;list;delete

// Reconcile is part of the main kubernetes reconciliation loop which aims to
// move the current state of the cluster closer to the desired state.
Expand Down Expand Up @@ -99,6 +100,14 @@ func (r *ActiveMQArtemisScaledownReconciler) Reconcile(ctx context.Context, requ
return ctrl.Result{}, nil
}

//for testing
func (r *ActiveMQArtemisScaledownReconciler) GetDrainController(namespace string) *draincontroller.Controller {
if inst, ok := controllers[namespace]; ok {
return inst
}
return nil
}

func (r *ActiveMQArtemisScaledownReconciler) getDrainController(localOnly bool, namespace string, kubeClient *kubernetes.Clientset, instance *brokerv1beta1.ActiveMQArtemisScaledown) (kubeinformers.SharedInformerFactory, *draincontroller.Controller, bool) {
var kubeInformerFactory kubeinformers.SharedInformerFactory
var controllerInstance *draincontroller.Controller
Expand Down
Loading