Browse Source

Merge pull request #2 from tekliner/reconcile_secrets

reconcile secrets after edit
pull/3/head
Vladimir Smagin 1 year ago
committed by GitHub
parent
commit
bae7fb99f6
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 65 deletions
  1. +5
    -0
      deploy/crds/rabbitmq_v1_rabbitmq_cr.yaml
  2. +2
    -12
      pkg/controller/rabbitmq/rabbitmq_controller.go
  3. +1
    -53
      pkg/controller/rabbitmq/rabbitmq_services.go

+ 5
- 0
deploy/crds/rabbitmq_v1_rabbitmq_cr.yaml View File

@@ -20,6 +20,11 @@ spec:
k8s_service_discovery: "svc.cluster.imp"
k8s_addrtype: hostname
cluster_node_cleanup_interval: 10
auth:
enabled: true
mechanisms:
- PLAIN
- AMQPLAIN
volume_size: 1Gi
# policies:
# - name: ha-three


+ 2
- 12
pkg/controller/rabbitmq/rabbitmq_controller.go View File

@@ -42,9 +42,9 @@ func newReconciler(mgr manager.Manager) reconcile.Reconciler {
}

// add adds a new Controller to mgr with r as the reconcile.Reconciler
func add(mgr manager.Manager, r reconcile.Reconciler) error {
func add(mgr manager.Manager, reconciler reconcile.Reconciler) error {
// Create a new controller
c, err := controller.New("rabbitmq-controller", mgr, controller.Options{Reconciler: r})
c, err := controller.New("rabbitmq-controller", mgr, controller.Options{Reconciler: reconciler})
if err != nil {
return err
}
@@ -184,21 +184,11 @@ func (r *ReconcileRabbitmq) Reconcile(request reconcile.Request) (reconcile.Resu
// creating services
reqLogger.Info("Reconciling services")

_, err = r.reconcileEpmdService(reqLogger, instance)
if err != nil {
return reconcile.Result{}, err
}

_, err = r.reconcileHTTPService(reqLogger, instance)
if err != nil {
return reconcile.Result{}, err
}

_, err = r.reconcileAmqpService(reqLogger, instance)
if err != nil {
return reconcile.Result{}, err
}

// all-in-one service
_, err = r.reconcileHAService(reqLogger, instance)
if err != nil {


+ 1
- 53
pkg/controller/rabbitmq/rabbitmq_services.go View File

@@ -92,62 +92,10 @@ func (r *ReconcileRabbitmq) reconcileDiscoveryService(reqLogger logr.Logger, cr
return reconcileResult, err
}

func (r *ReconcileRabbitmq) reconcileEpmdService(reqLogger logr.Logger, cr *rabbitmqv1.Rabbitmq) (reconcile.Result, error) {

service := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: cr.Name + "-empd",
Namespace: cr.Namespace,
Labels: returnLabels(cr),
},
Spec: corev1.ServiceSpec{
Type: corev1.ServiceTypeClusterIP,
Selector: returnLabels(cr),
Ports: []corev1.ServicePort{
{
TargetPort: intstr.IntOrString{IntVal: 4369},
Port: 4369,
Protocol: corev1.ProtocolTCP,
Name: "empd",
},
},
},
}
reconcileResult, err := r.reconcileService(reqLogger, cr, service)

return reconcileResult, err
}

func (r *ReconcileRabbitmq) reconcileAmqpService(reqLogger logr.Logger, cr *rabbitmqv1.Rabbitmq) (reconcile.Result, error) {
service := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: cr.Name + "-amqp",
Namespace: cr.Namespace,
Labels: returnLabels(cr),
},
Spec: corev1.ServiceSpec{
Type: corev1.ServiceTypeClusterIP,
Selector: returnLabels(cr),
Ports: []corev1.ServicePort{
{
TargetPort: intstr.IntOrString{IntVal: 5672},
Port: 5672,
Protocol: corev1.ProtocolTCP,
Name: "amqp",
},
},
},
}

reconcileResult, err := r.reconcileService(reqLogger, cr, service)

return reconcileResult, err
}

func (r *ReconcileRabbitmq) reconcileHAService(reqLogger logr.Logger, cr *rabbitmqv1.Rabbitmq) (reconcile.Result, error) {
service := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{
Name: cr.Name + "-ha",
Name: cr.Name,
Namespace: cr.Namespace,
Labels: returnLabels(cr),
},


Loading…
Cancel
Save