Skip to content

Commit

Permalink
deploy kafka networkpolicies only when needed
Browse files Browse the repository at this point in the history
  • Loading branch information
nasark committed Sep 14, 2023
1 parent 8c1edd0 commit 08fb96e
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions manageiq-operator/internal/controller/manageiq_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -677,18 +677,20 @@ func (r *ManageIQReconciler) generateNetworkPolicies(cr *miqv1alpha1.ManageIQ) e
logger.Info("NetworkPolicy allow postgres has been reconciled", "component", "network_policy", "result", result)
}

networkPolicyAllowKafka, mutateFunc := miqtool.NetworkPolicyAllowKafka(cr, r.Scheme, &r.Client)
if result, err := controllerutil.CreateOrUpdate(context.TODO(), r.Client, networkPolicyAllowKafka, mutateFunc); err != nil {
return err
} else if result != controllerutil.OperationResultNone {
logger.Info("NetworkPolicy allow kafka has been reconciled", "component", "network_policy", "result", result)
}
if *cr.Spec.DeployMessagingService == true {
networkPolicyAllowKafka, mutateFunc := miqtool.NetworkPolicyAllowKafka(cr, r.Scheme, &r.Client)
if result, err := controllerutil.CreateOrUpdate(context.TODO(), r.Client, networkPolicyAllowKafka, mutateFunc); err != nil {
return err
} else if result != controllerutil.OperationResultNone {
logger.Info("NetworkPolicy allow kafka has been reconciled", "component", "network_policy", "result", result)
}

networkPolicyAllowZookeeper, mutateFunc := miqtool.NetworkPolicyAllowZookeeper(cr, r.Scheme, &r.Client)
if result, err := controllerutil.CreateOrUpdate(context.TODO(), r.Client, networkPolicyAllowZookeeper, mutateFunc); err != nil {
return err
} else if result != controllerutil.OperationResultNone {
logger.Info("NetworkPolicy allow zookeeper has been reconciled", "component", "network_policy", "result", result)
networkPolicyAllowZookeeper, mutateFunc := miqtool.NetworkPolicyAllowZookeeper(cr, r.Scheme, &r.Client)
if result, err := controllerutil.CreateOrUpdate(context.TODO(), r.Client, networkPolicyAllowZookeeper, mutateFunc); err != nil {
return err
} else if result != controllerutil.OperationResultNone {
logger.Info("NetworkPolicy allow zookeeper has been reconciled", "component", "network_policy", "result", result)
}
}

return nil
Expand Down

0 comments on commit 08fb96e

Please sign in to comment.