Skip to content
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

Operator Feature for Dedicated Networking #926

Merged
merged 20 commits into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from 17 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
2 changes: 1 addition & 1 deletion charts/tembo-operator/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: tembo-operator
description: "Helm chart to deploy the tembo-operator"
type: application
icon: https://cloud.tembo.io/images/TemboElephant.png
version: 0.7.1
version: 0.7.2
home: https://tembo.io
sources:
- https://github.com/tembo-io/tembo
Expand Down
36 changes: 36 additions & 0 deletions charts/tembo-operator/templates/crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2135,6 +2135,42 @@ spec:
type: object
type: object
type: object
dedicatedNetworking:
description: |-
Configuration for dedicated networking.

**Default**: disabled
nullable: true
properties:
enabled:
default: false
description: |-
Enable dedicated networking for the CoreDB instance.

**Default**: false.
type: boolean
includeStandby:
default: false
description: |-
Include a separate load balancer for the standby (replica) server.

**Default**: false.
type: boolean
public:
default: false
description: |-
Configure the load balancer to be public or private.

**Default**: false.
type: boolean
serviceType:
default: LoadBalancer
description: |-
The type of Kubernetes Service to create (LoadBalancer or ClusterIP).

**Default**: LoadBalancer.
type: string
type: object
extensions:
default: []
description: |-
Expand Down
40 changes: 40 additions & 0 deletions tembo-operator/src/apis/coredb_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,40 @@ pub struct PgBouncer {
pub resources: Option<PoolerTemplateSpecContainersResources>,
}

#[derive(Deserialize, Serialize, Clone, Debug, JsonSchema, Default)]
#[allow(non_snake_case)]
pub struct DedicatedNetworking {
/// Enable dedicated networking for the CoreDB instance.
///
/// **Default**: false.
#[serde(default)]
pub enabled: bool,

/// Include a separate load balancer for the standby (replica) server.
///
/// **Default**: false.
#[serde(default)]
pub includeStandby: bool,

/// Configure the load balancer to be public or private.
///
/// **Default**: false.
#[serde(default)]
pub public: bool,

/// The type of Kubernetes Service to create (LoadBalancer or ClusterIP).
///
/// **Default**: LoadBalancer.
#[serde(default = "defaults::default_service_type")]
pub serviceType: String,
}

impl DedicatedNetworking {
pub fn is_enabled(&self) -> bool {
self.enabled
}
}

/// Generate the Kubernetes wrapper struct `CoreDB` from our Spec and Status struct
///
/// This provides a hook for generating the CRD yaml (in crdgen.rs)
Expand Down Expand Up @@ -440,6 +474,12 @@ pub struct CoreDBSpec {
#[serde(default = "defaults::default_postgres_exporter_image")]
pub postgresExporterImage: String,

/// Configuration for dedicated networking.
///
/// **Default**: disabled
#[serde(default)]
pub dedicatedNetworking: Option<DedicatedNetworking>,

/// The port to expose the Postgres service on.
///
/// **Default**: 5432.
Expand Down
8 changes: 8 additions & 0 deletions tembo-operator/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ use crate::{
VOLUME_SNAPSHOT_CLASS_NAME,
},
config::Config,
dedicated_networking::reconcile_dedicated_networking,
exec::{ExecCommand, ExecOutput},
extensions::database_queries::is_not_restarting,
heartbeat::reconcile_heartbeat,
Expand Down Expand Up @@ -277,6 +278,13 @@ impl CoreDB {
Action::requeue(Duration::from_secs(300))
})?;

reconcile_dedicated_networking(self, ctx.clone(), basedomain.as_str())
.await
.map_err(|e| {
error!("Error reconciling dedicated networking: {:?}", e);
Action::requeue(Duration::from_secs(300))
})?;

let name_pooler = format!("{}-pooler", self.name_any().as_str());
let prefix_pooler = format!("{}-pooler-", self.name_any().as_str());
reconcile_postgres_ing_route_tcp(
Expand Down
Loading
Loading