Skip to content

Fix/disable 8081 for 2xx and bind to localhost #794

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
4 changes: 4 additions & 0 deletions rust/operator-binary/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,10 @@ pub fn build_nifi_properties(
"nifi.web.https.network.interface.default".to_string(),
"".to_string(),
);
properties.insert(
"nifi.web.https.network.interface.lo".to_string(),
"lo".to_string(),
);
properties.insert(
"nifi.web.jetty.working.directory".to_string(),
"./work/jetty".to_string(),
Expand Down
38 changes: 23 additions & 15 deletions rust/operator-binary/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -810,6 +810,23 @@ fn build_node_rolegroup_service(
resolved_product_image: &ResolvedProductImage,
rolegroup: &RoleGroupRef<v1alpha1::NifiCluster>,
) -> Result<Service> {
let mut enabled_ports = vec![ServicePort {
name: Some(HTTPS_PORT_NAME.to_string()),
port: HTTPS_PORT.into(),
protocol: Some("TCP".to_string()),
..ServicePort::default()
}];

// Nifi 2.x.x offers nifi-api/flow/metrics/prometheus at the HTTPS_PORT, therefore METRICS_PORT is not necessary anymore.
if resolved_product_image.product_version.starts_with("1.") {
enabled_ports.push(ServicePort {
name: Some(METRICS_PORT_NAME.to_string()),
port: METRICS_PORT.into(),
protocol: Some("TCP".to_string()),
..ServicePort::default()
})
}

Ok(Service {
metadata: ObjectMetaBuilder::new()
.name_and_namespace(nifi)
Expand All @@ -829,20 +846,7 @@ fn build_node_rolegroup_service(
// Internal communication does not need to be exposed
type_: Some("ClusterIP".to_string()),
cluster_ip: Some("None".to_string()),
ports: Some(vec![
ServicePort {
name: Some(HTTPS_PORT_NAME.to_string()),
port: HTTPS_PORT.into(),
protocol: Some("TCP".to_string()),
..ServicePort::default()
},
ServicePort {
name: Some(METRICS_PORT_NAME.to_string()),
port: METRICS_PORT.into(),
protocol: Some("TCP".to_string()),
..ServicePort::default()
},
]),
ports: Some(enabled_ports),
selector: Some(
Labels::role_group_selector(nifi, APP_NAME, &rolegroup.role, &rolegroup.role_group)
.context(LabelBuildSnafu)?
Expand Down Expand Up @@ -1117,7 +1121,6 @@ async fn build_node_rolegroup_statefulset(
.add_container_port(HTTPS_PORT_NAME, HTTPS_PORT.into())
.add_container_port(PROTOCOL_PORT_NAME, PROTOCOL_PORT.into())
.add_container_port(BALANCE_PORT_NAME, BALANCE_PORT.into())
.add_container_port(METRICS_PORT_NAME, METRICS_PORT.into())
.liveness_probe(Probe {
initial_delay_seconds: Some(10),
period_seconds: Some(10),
Expand All @@ -1139,6 +1142,11 @@ async fn build_node_rolegroup_statefulset(
})
.resources(merged_config.resources.clone().into());

// Nifi 2.x.x offers nifi-api/flow/metrics/prometheus at the HTTPS_PORT, therefore METRICS_PORT is not necessary anymore.
if resolved_product_image.product_version.starts_with("1.") {
container_nifi.add_container_port(METRICS_PORT_NAME, METRICS_PORT.into());
}

let mut pod_builder = PodBuilder::new();
add_graceful_shutdown_config(merged_config, &mut pod_builder).context(GracefulShutdownSnafu)?;

Expand Down