Skip to content

Commit

Permalink
deploy kafka depending on appname/hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
nasark committed Jan 26, 2024
1 parent 6c880dd commit 21cd053
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
5 changes: 1 addition & 4 deletions images/manageiq-orchestrator/container-assets/entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -116,10 +116,7 @@ EOS

check_svc_status ${MEMCACHED_SERVICE_HOST} ${MEMCACHED_SERVICE_PORT}
check_svc_status ${database_hostname} ${database_port}

if [ -n "$MESSAGING_HOSTNAME" ] && [ -n "$MESSAGING_PORT" ]; then
check_svc_status ${MESSAGING_HOSTNAME} ${MESSAGING_PORT}
fi
check_svc_status ${messaging_hostname} ${messaging_port}

check_deployment_status || exit 1

Expand Down
30 changes: 17 additions & 13 deletions manageiq-operator/internal/controller/manageiq_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,9 @@ func (r *ManageIQReconciler) Reconcile(ctx context.Context, request ctrl.Request
if e := r.generateMemcachedResources(miqInstance); e != nil {
return reconcile.Result{}, e
}
if *miqInstance.Spec.DeployMessagingService {
logger.Info("Reconciling the Kafka resources...")
if e := r.generateKafkaResources(miqInstance); e != nil {
return reconcile.Result{}, e
}
logger.Info("Reconciling the Kafka resources...")
if e := r.generateKafkaResources(miqInstance); e != nil {
return reconcile.Result{}, e
}
logger.Info("Reconciling the Orchestrator resources...")
if e := r.generateOrchestratorResources(miqInstance); e != nil {
Expand Down Expand Up @@ -526,6 +524,19 @@ func (r *ManageIQReconciler) generatePostgresqlResources(cr *miqv1alpha1.ManageI
}

func (r *ManageIQReconciler) generateKafkaResources(cr *miqv1alpha1.ManageIQ) error {
secret, mutateFunc := miqkafka.MessagingEnvSecret(cr, r.Client, r.Scheme)
if result, err := controllerutil.CreateOrUpdate(context.TODO(), r.Client, secret, mutateFunc); err != nil {
return err
} else if result != controllerutil.OperationResultNone {
logger.Info("Secret has been reconciled", "component", "kafka", "result", result)
}

hostName := string(secret.Data["hostname"])
if hostName != "manageiq-kafka-bootstrap" {
logger.Info("External Kafka selected, skipping Kafka service reconciliation", "hostname", hostName)
return nil
}

if miqutilsv1alpha1.FindCatalogSourceByName(r.Client, "openshift-marketplace", "community-operators") != nil {
kafkaOperatorGroup, mutateFunc := miqkafka.KafkaOperatorGroup(cr, r.Scheme)
if result, err := controllerutil.CreateOrUpdate(context.TODO(), r.Client, kafkaOperatorGroup, mutateFunc); err != nil {
Expand Down Expand Up @@ -582,13 +593,6 @@ func (r *ManageIQReconciler) generateKafkaResources(cr *miqv1alpha1.ManageIQ) er
}
}

secret, mutateFunc := miqkafka.MessagingEnvSecret(cr, r.Client, r.Scheme)
if result, err := controllerutil.CreateOrUpdate(context.TODO(), r.Client, secret, mutateFunc); err != nil {
return err
} else if result != controllerutil.OperationResultNone {
logger.Info("Secret has been reconciled", "component", "kafka", "result", result)
}

return nil
}

Expand Down Expand Up @@ -678,7 +682,7 @@ func (r *ManageIQReconciler) generateNetworkPolicies(cr *miqv1alpha1.ManageIQ) e
logger.Info("NetworkPolicy allow postgres has been reconciled", "component", "network_policy", "result", result)
}

if *cr.Spec.DeployMessagingService == true {
if cr.Spec.AppName == "manageiq" {
networkPolicyAllowKafka, mutateFunc := miqtool.NetworkPolicyAllowKafka(cr, r.Scheme, &r.Client)
if result, err := controllerutil.CreateOrUpdate(context.TODO(), r.Client, networkPolicyAllowKafka, mutateFunc); err != nil {
return err
Expand Down

0 comments on commit 21cd053

Please sign in to comment.