Skip to content

Commit b796ab4

Browse files
committed
Support specifying Service type (#350)
# Description For stackabletech/issues#360
1 parent 5185d67 commit b796ab4

4 files changed

Lines changed: 73 additions & 27 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010

1111
### Changed
1212

13+
- [BREAKING]: Support specifying Service type by moving `serviceType` (which was an experimental feature) to `clusterConfig.listenerClass`.
14+
This enables us to later switch non-breaking to using `ListenerClasses` for the exposure of Services.
15+
This change is breaking, because - for security reasons - we default to the `cluster-internal` `ListenerClass`.
16+
If you need your cluster to be accessible from outside of Kubernetes you need to set `clusterConfig.listenerClass`
17+
to `external-unstable` or `external-stable` ([#350]).
1318
- `operator-rs` `0.31.0` -> `0.35.0` ([#322], [#326]).
1419
- Bumped stackable image versions to "23.4.0-rc2" ([#322], [#326]).
1520
- Fragmented `SupersetConfig` ([#323]).
@@ -21,6 +26,7 @@
2126
[#337]: https://github.com/stackabletech/superset-operator/pull/337
2227
[#344]: https://github.com/stackabletech/superset-operator/pull/344
2328
[#348]: https://github.com/stackabletech/superset-operator/pull/348
29+
[#350]: https://github.com/stackabletech/superset-operator/pull/350
2430

2531
## [23.1.0] - 2023-01-23
2632

deploy/helm/superset-operator/crds/crds.yaml

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,27 @@ spec:
4747
description: This role will be given in addition to any AUTH_ROLES_MAPPING. Gets mapped to `AUTH_USER_REGISTRATION_ROLE`
4848
type: string
4949
type: object
50+
clusterConfig:
51+
default:
52+
listenerClass: cluster-internal
53+
description: Superset cluster configuration options.
54+
properties:
55+
listenerClass:
56+
default: cluster-internal
57+
description: |-
58+
In the future this setting will control, which ListenerClass <https://docs.stackable.tech/home/stable/listener-operator/listenerclass.html> will be used to expose the service. Currently only a subset of the ListenerClasses are supported by choosing the type of the created Services by looking at the ListenerClass name specified, In a future release support for custom ListenerClasses will be introduced without a breaking change:
59+
60+
* cluster-internal: Use a ClusterIP service
61+
62+
* external-unstable: Use a NodePort service
63+
64+
* external-stable: Use a LoadBalancer service
65+
enum:
66+
- cluster-internal
67+
- external-unstable
68+
- external-stable
69+
type: string
70+
type: object
5071
clusterOperation:
5172
default:
5273
stopped: false
@@ -1482,13 +1503,6 @@ spec:
14821503
required:
14831504
- roleGroups
14841505
type: object
1485-
serviceType:
1486-
description: Specify the type of the created kubernetes service. This attribute will be removed in a future release when listener-operator is finished. Use with caution.
1487-
enum:
1488-
- NodePort
1489-
- ClusterIP
1490-
nullable: true
1491-
type: string
14921506
stopped:
14931507
description: Emergency stop button, if `true` then all pods are stopped without affecting configuration (as setting `replicas` to `0` would)
14941508
nullable: true

rust/crd/src/lib.rs

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ pub struct SupersetClusterSpec {
146146
pub stopped: Option<bool>,
147147
/// The Superset image to use
148148
pub image: ProductImage,
149+
/// Superset cluster configuration options.
150+
#[serde(default)]
151+
pub cluster_config: SupersetClusterConfig,
149152
/// Name of the Vector aggregator discovery ConfigMap.
150153
/// It must contain the key `ADDRESS` with the address of the Vector aggregator.
151154
#[serde(skip_serializing_if = "Option::is_none")]
@@ -160,27 +163,49 @@ pub struct SupersetClusterSpec {
160163
pub nodes: Option<Role<SupersetConfigFragment>>,
161164
#[serde(default, skip_serializing_if = "Option::is_none")]
162165
pub database_initialization: Option<supersetdb::SupersetDbConfigFragment>,
163-
/// Specify the type of the created kubernetes service.
164-
/// This attribute will be removed in a future release when listener-operator is finished.
165-
/// Use with caution.
166-
#[serde(default, skip_serializing_if = "Option::is_none")]
167-
pub service_type: Option<ServiceType>,
168166
/// Cluster operations like pause reconciliation or cluster stop.
169167
#[serde(default)]
170168
pub cluster_operation: ClusterOperation,
171169
}
172170

171+
#[derive(Clone, Debug, Default, Eq, Deserialize, JsonSchema, PartialEq, Serialize)]
172+
#[serde(rename_all = "camelCase")]
173+
pub struct SupersetClusterConfig {
174+
/// In the future this setting will control, which ListenerClass <https://docs.stackable.tech/home/stable/listener-operator/listenerclass.html>
175+
/// will be used to expose the service.
176+
/// Currently only a subset of the ListenerClasses are supported by choosing the type of the created Services
177+
/// by looking at the ListenerClass name specified,
178+
/// In a future release support for custom ListenerClasses will be introduced without a breaking change:
179+
///
180+
/// * cluster-internal: Use a ClusterIP service
181+
///
182+
/// * external-unstable: Use a NodePort service
183+
///
184+
/// * external-stable: Use a LoadBalancer service
185+
#[serde(default)]
186+
pub listener_class: CurrentlySupportedListenerClasses,
187+
}
188+
173189
// TODO: Temporary solution until listener-operator is finished
174-
#[derive(Clone, Debug, Display, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
190+
#[derive(Clone, Debug, Default, Display, Deserialize, Eq, JsonSchema, PartialEq, Serialize)]
175191
#[serde(rename_all = "PascalCase")]
176-
pub enum ServiceType {
177-
NodePort,
178-
ClusterIP,
192+
pub enum CurrentlySupportedListenerClasses {
193+
#[default]
194+
#[serde(rename = "cluster-internal")]
195+
ClusterInternal,
196+
#[serde(rename = "external-unstable")]
197+
ExternalUnstable,
198+
#[serde(rename = "external-stable")]
199+
ExternalStable,
179200
}
180201

181-
impl Default for ServiceType {
182-
fn default() -> Self {
183-
Self::NodePort
202+
impl CurrentlySupportedListenerClasses {
203+
pub fn k8s_service_type(&self) -> String {
204+
match self {
205+
CurrentlySupportedListenerClasses::ClusterInternal => "ClusterIP".to_string(),
206+
CurrentlySupportedListenerClasses::ExternalUnstable => "NodePort".to_string(),
207+
CurrentlySupportedListenerClasses::ExternalStable => "LoadBalancer".to_string(),
208+
}
184209
}
185210
}
186211

rust/operator-binary/src/superset_controller.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -379,21 +379,20 @@ fn build_node_role_service(
379379
))
380380
.build(),
381381
spec: Some(ServiceSpec {
382+
type_: Some(
383+
superset
384+
.spec
385+
.cluster_config
386+
.listener_class
387+
.k8s_service_type(),
388+
),
382389
ports: Some(vec![ServicePort {
383390
name: Some("superset".to_string()),
384391
port: APP_PORT.into(),
385392
protocol: Some("TCP".to_string()),
386393
..ServicePort::default()
387394
}]),
388395
selector: Some(role_selector_labels(superset, APP_NAME, &role_name)),
389-
type_: Some(
390-
superset
391-
.spec
392-
.service_type
393-
.clone()
394-
.unwrap_or_default()
395-
.to_string(),
396-
),
397396
..ServiceSpec::default()
398397
}),
399398
status: None,
@@ -499,6 +498,8 @@ fn build_node_rolegroup_service(
499498
.with_label("prometheus.io/scrape", "true")
500499
.build(),
501500
spec: Some(ServiceSpec {
501+
// Internal communication does not need to be exposed
502+
type_: Some("ClusterIP".to_string()),
502503
cluster_ip: Some("None".to_string()),
503504
ports: Some(vec![
504505
ServicePort {

0 commit comments

Comments
 (0)