-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move messaging configuration to file and deprecate deployMessagingService flag #1041
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,4 +46,35 @@ cat > ${APP_ROOT}/certs/v2_key << KEY | |
:key: ${encryption_key} | ||
KEY | ||
|
||
|
||
[[ -f /run/secrets/messaging/MESSAGING_HOSTNAME ]] && messaging_hostname_file=$(cat /run/secrets/messaging/MESSAGING_HOSTNAME) | ||
[[ -f /run/secrets/messaging/MESSAGING_USERNAME ]] && messaging_username_file=$(cat /run/secrets/messaging/MESSAGING_USERNAME) | ||
[[ -f /run/secrets/messaging/MESSAGING_PASSWORD ]] && messaging_password_file=$(cat /run/secrets/messaging/MESSAGING_PASSWORD) | ||
[[ -f /run/secrets/messaging/MESSAGING_PORT ]] && messaging_port_file=$(cat /run/secrets/messaging/MESSAGING_PORT) | ||
[[ -f /run/secrets/messaging/MESSAGING_SASL_MECHANISM ]] && messaging_sasl_mechanism_file=$(cat /run/secrets/messaging/MESSAGING_SASL_MECHANISM) | ||
[[ -f /etc/pki/ca-trust/source/anchors/root.crt ]] && messaging_ca_path=/etc/pki/ca-trust/source/anchors/root.crt | ||
messaging_hostname=${MESSAGING_HOSTNAME:-$messaging_hostname_file} | ||
messaging_hostname=${messaging_hostname:-localhost} | ||
messaging_username=${MESSAGING_USERNAME:-$messaging_username_file} | ||
messaging_password=${MESSAGING_PASSWORD:-$messaging_password_file} | ||
messaging_port=${MESSAGING_PORT:-$messaging_port_file} | ||
messaging_port=${messaging_port:-9093} | ||
messaging_sasl_mechanism=${MESSAGING_SASL_MECHANISM:-$messaging_sasl_mechanism_file} | ||
Comment on lines
+56
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since the env vars won't be used, should they be removed from these conditional assignments? I see that the database env vars are still checked in these conditional assignments https://github.com/ManageIQ/manageiq-pods/blob/master/images/manageiq-base/container-assets/container_env#L12-L20 so I followed suite but didn't understand the reasoning There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We kept them more as a convenience for developers - if you run it locally, it's just a lot easier to pass them as |
||
messaging_ca_path=${messaging_ca_path:-/etc/pki/ca-trust/source/anchors/ca.crt} | ||
|
||
echo "== Writing messaging config ==" | ||
cat > ${APP_ROOT}/config/messaging.yml << KEY | ||
--- | ||
production: | ||
host: ${messaging_hostname} | ||
port: ${messaging_port} | ||
protocol: Kafka | ||
encoding: json | ||
username: ${messaging_username} | ||
password: ${messaging_password} | ||
sasl_mechanism: ${messaging_sasl_mechanism} | ||
ssl: true | ||
ca_file: ${messaging_ca_path} | ||
KEY | ||
|
||
echo "${GUID}" > ${APP_ROOT}/GUID |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 { | ||
|
@@ -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" { | ||
Comment on lines
+534
to
+535
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I followed the same methodology we use for postgresql but in this case the hostname also depends on |
||
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 { | ||
|
@@ -671,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 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right? I thought localhost didn't work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should probably default to the name of the service used to reach kafka