Skip to content

Commit 051746f

Browse files
committed
Add support and test for HDFS
1 parent 76d4b4d commit 051746f

File tree

18 files changed

+192
-37
lines changed

18 files changed

+192
-37
lines changed

deploy/crd/trinocatalog.crd.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ spec:
3333
properties:
3434
hive:
3535
properties:
36+
hdfs:
37+
nullable: true
38+
properties:
39+
configMap:
40+
description: Name of the discovery-configmap providing information about the HDFS
41+
type: string
42+
required:
43+
- configMap
44+
type: object
3645
metastore:
3746
description: "Mandatory connection to a Hive Metastore, which will be used as a storage for metadata"
3847
properties:

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,15 @@ spec:
463463
properties:
464464
hive:
465465
properties:
466+
hdfs:
467+
nullable: true
468+
properties:
469+
configMap:
470+
description: Name of the discovery-configmap providing information about the HDFS
471+
type: string
472+
required:
473+
- configMap
474+
type: object
466475
metastore:
467476
description: "Mandatory connection to a Hive Metastore, which will be used as a storage for metadata"
468477
properties:

deploy/manifests/crds.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,15 @@ spec:
464464
properties:
465465
hive:
466466
properties:
467+
hdfs:
468+
nullable: true
469+
properties:
470+
configMap:
471+
description: Name of the discovery-configmap providing information about the HDFS
472+
type: string
473+
required:
474+
- configMap
475+
type: object
467476
metastore:
468477
description: "Mandatory connection to a Hive Metastore, which will be used as a storage for metadata"
469478
properties:

rust/crd/src/catalog.rs

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub struct HiveConnector {
4949
/// Connection to an S3 store
5050
pub s3: Option<S3ConnectionDef>,
5151
// /// Connection to an HDFS
52-
// pub hdfs: Option<HdfsConnection>,
52+
pub hdfs: Option<HdfsConnection>,
5353
}
5454

5555
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Serialize)]
@@ -59,12 +59,9 @@ pub struct MetastoreConnection {
5959
pub config_map: String,
6060
}
6161

62-
// #[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Serialize)]
63-
// #[serde(rename_all = "camelCase")]
64-
// pub struct HdfsConnection {
65-
// /// Name of the discovery-configmap providing information about the HDFS
66-
// pub config_map: String,
67-
// /// Wether Trino should impersonate the users when accessing HDFS
68-
// #[serde(default)]
69-
// impersonation: bool,
70-
// }
62+
#[derive(Clone, Debug, Deserialize, JsonSchema, PartialEq, Serialize)]
63+
#[serde(rename_all = "camelCase")]
64+
pub struct HdfsConnection {
65+
/// Name of the discovery-configmap providing information about the HDFS
66+
pub config_map: String,
67+
}

rust/operator-binary/src/catalog.rs

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use std::collections::{BTreeMap};
1+
use std::collections::BTreeMap;
22

33
use snafu::{ResultExt, Snafu};
44
use stackable_operator::{
@@ -8,7 +8,10 @@ use stackable_operator::{
88
k8s_openapi::api::core::v1::{ConfigMapKeySelector, EnvVar, EnvVarSource, Volume, VolumeMount},
99
kube::ResourceExt,
1010
};
11-
use stackable_trino_crd::{catalog::TrinoCatalog, S3_SECRET_DIR_NAME};
11+
use stackable_trino_crd::{
12+
CONFIG_DIR_NAME, RW_CONFIG_DIR_NAME,
13+
{catalog::TrinoCatalog, S3_SECRET_DIR_NAME},
14+
};
1215

1316
use self::from_trino_catalog_error::ResolveS3ConnectionDefSnafu;
1417

@@ -87,8 +90,9 @@ impl CatalogConfig {
8790
catalog: TrinoCatalog,
8891
client: &Client,
8992
) -> Result<CatalogConfig, FromTrinoCatalogError> {
93+
let catalog_name = catalog.name();
9094
let mut config = CatalogConfig {
91-
name: catalog.name(),
95+
name: catalog_name.to_string(),
9296
properties: BTreeMap::new(),
9397
env_bindings: Vec::new(),
9498
load_env_from_files: BTreeMap::new(),
@@ -144,6 +148,23 @@ impl CatalogConfig {
144148

145149
// TODO: Handle TLS settings (related to https://github.com/stackabletech/trino-operator/pull/244)
146150
}
151+
152+
if let Some(hdfs) = &hive.hdfs {
153+
config.add_property(
154+
"hive.config.resources",
155+
format!("{RW_CONFIG_DIR_NAME}/catalog/{catalog_name}/hdfs-config/hdfs-site.xml"),
156+
);
157+
158+
let volume_name = format!("{catalog_name}-hdfs");
159+
config.volumes.push(
160+
VolumeBuilder::new(&volume_name)
161+
.with_config_map(&hdfs.config_map)
162+
.build(),
163+
);
164+
config
165+
.volume_mounts
166+
.push(VolumeMountBuilder::new(&volume_name, format!("{CONFIG_DIR_NAME}/catalog/{catalog_name}/hdfs-config")).build());
167+
}
147168
}
148169
}
149170

tests/templates/kuttl/smoke/04-assert.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
apiVersion: kuttl.dev/v1beta1
33
kind: TestAssert
44
metadata:
5-
name: install-postgres
5+
name: install-zookeeper
66
timeout: 600
77
---
88
apiVersion: apps/v1
99
kind: StatefulSet
1010
metadata:
11-
name: hive-postgresql
11+
name: zookeeper-server-default
1212
status:
1313
readyReplicas: 1
1414
replicas: 1
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
apiVersion: zookeeper.stackable.tech/v1alpha1
3+
kind: ZookeeperCluster
4+
metadata:
5+
name: zookeeper
6+
spec:
7+
servers:
8+
roleGroups:
9+
default:
10+
replicas: 1
11+
version: {{ test_scenario['values']['zookeeper'] }}

tests/templates/kuttl/smoke/05-assert.yaml

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,29 @@
22
apiVersion: kuttl.dev/v1beta1
33
kind: TestAssert
44
metadata:
5-
name: install-hive
6-
timeout: 720
5+
name: install-hdfs
6+
timeout: 600
77
---
88
apiVersion: apps/v1
99
kind: StatefulSet
1010
metadata:
11-
name: hive-metastore-default
11+
name: hdfs-namenode-default
12+
status:
13+
readyReplicas: 2
14+
replicas: 2
15+
---
16+
apiVersion: apps/v1
17+
kind: StatefulSet
18+
metadata:
19+
name: hdfs-journalnode-default
20+
status:
21+
readyReplicas: 1
22+
replicas: 1
23+
---
24+
apiVersion: apps/v1
25+
kind: StatefulSet
26+
metadata:
27+
name: hdfs-datanode-default
1228
status:
1329
readyReplicas: 1
1430
replicas: 1
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
apiVersion: hdfs.stackable.tech/v1alpha1
3+
kind: HdfsCluster
4+
metadata:
5+
name: hdfs
6+
spec:
7+
version: {{ test_scenario['values']['hdfs'] }}
8+
zookeeperConfigMapName: zookeeper-hdfs-znode
9+
dfsReplication: 1
10+
nameNodes:
11+
roleGroups:
12+
default:
13+
replicas: 2
14+
dataNodes:
15+
roleGroups:
16+
default:
17+
replicas: 1
18+
journalNodes:
19+
roleGroups:
20+
default:
21+
replicas: 1
22+
---
23+
apiVersion: zookeeper.stackable.tech/v1alpha1
24+
kind: ZookeeperZnode
25+
metadata:
26+
name: zookeeper-hdfs-znode
27+
spec:
28+
clusterRef:
29+
name: zookeeper

tests/templates/kuttl/smoke/06-assert.yaml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22
apiVersion: kuttl.dev/v1beta1
33
kind: TestAssert
44
metadata:
5-
name: install-opa
6-
timeout: 300
7-
commands:
8-
- script: kubectl -n $NAMESPACE rollout status daemonset opa-server-default --timeout 300s
5+
name: install-postgres
6+
timeout: 600
7+
---
8+
apiVersion: apps/v1
9+
kind: StatefulSet
10+
metadata:
11+
name: hive-postgresql
12+
status:
13+
readyReplicas: 1
14+
replicas: 1

0 commit comments

Comments
 (0)