Skip to content

Commit 63af879

Browse files
committed
wip: tls almost working
1 parent 60141dd commit 63af879

6 files changed

Lines changed: 150 additions & 2 deletions

File tree

stacks/trino-iceberg/airflow.yaml

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ spec:
3535
roleGroups:
3636
default:
3737
replicas: 1
38+
# kubernetesExecutors:
39+
# config: {}
3840
schedulers:
3941
roleGroups:
4042
default:
@@ -56,6 +58,36 @@ data:
5658
dbt_trino.py: |
5759
from airflow import DAG
5860
from airflow.providers.cncf.kubernetes.operators.pod import KubernetesPodOperator
61+
from kubernetes.client import models as k8s
62+
63+
volume = k8s.V1Volume(
64+
name="server-tls-mount",
65+
ephemeral=k8s.V1EphemeralVolumeSource(
66+
volume_claim_template=k8s.V1PersistentVolumeClaimTemplate(
67+
metadata=k8s.V1ObjectMeta(
68+
annotations={
69+
"secrets.stackable.tech/class": "trino-tls",
70+
"secrets.stackable.tech/scope": "pod,node"
71+
}
72+
),
73+
spec=k8s.V1PersistentVolumeClaimSpec(
74+
access_modes=["ReadWriteOnce"],
75+
resources=k8s.V1ResourceRequirements(
76+
requests={"storage": "1"}
77+
),
78+
storage_class_name="secrets.stackable.tech"
79+
)
80+
)
81+
)
82+
)
83+
84+
volume_mount = k8s.V1VolumeMount(
85+
name="server-tls-mount", mount_path="/dbt/trusted"
86+
)
87+
88+
pod_security_context = k8s.V1PodSecurityContext(
89+
fs_group=1000
90+
)
5991
6092
with DAG(
6193
dag_id="run_dbt_check_via_pod_operator",
@@ -67,10 +99,13 @@ data:
6799
image="my-dbt-trino:0.0.1",
68100
image_pull_policy="IfNotPresent",
69101
cmds=["/bin/bash", "-x", "-euo", "pipefail", "-c"],
70-
arguments=["dbt debug"],
102+
arguments=["sleep infinity #curl -v -u admin:adminadmin --cacert /dbt/trusted/ca.crt https://trino-coordinator-default-headless.default.svc.cluster.local:8443/v1/info"],
71103
name="run-dbt-debug",
72104
task_id="dbt-task",
73105
get_logs=True,
106+
volumes=[volume],
107+
volume_mounts=[volume_mount],
108+
security_context=pod_security_context,
74109
startup_timeout_seconds=600
75110
)
76111
run_dbt_check
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
FROM python:3.11-slim AS builder
2+
3+
# Install build dependencies
4+
RUN apt-get update && apt-get install -y \
5+
git \
6+
gcc \
7+
&& rm -rf /var/lib/apt/lists/*
8+
9+
# Create virtual environment
10+
RUN python -m venv /opt/venv
11+
ENV PATH="/opt/venv/bin:$PATH"
12+
13+
# Install Python packages
14+
COPY requirements.txt .
15+
RUN pip install --no-cache-dir --upgrade pip && \
16+
pip install --no-cache-dir -r requirements.txt
17+
18+
# Final stage
19+
FROM python:3.11-slim
20+
21+
RUN apt-get update && apt-get install -y \
22+
git \
23+
curl \
24+
vim \
25+
&& rm -rf /var/lib/apt/lists/*
26+
27+
# Copy virtual environment from builder
28+
COPY --from=builder /opt/venv /opt/venv
29+
ENV PATH="/opt/venv/bin:$PATH"
30+
31+
WORKDIR /dbt
32+
33+
# Copy dbt project
34+
COPY dbt_project.yml profiles.yml ./
35+
36+
# Security: non-root user
37+
RUN useradd -m -u 1000 dbt && chown -R dbt:dbt /dbt
38+
USER dbt
39+
40+
ENV DBT_PROFILES_DIR=/dbt
41+
42+
CMD ["dbt", "run"]
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: 'my_dbt_project'
2+
version: '1.0.0'
3+
config-version: 2
4+
5+
# This links to the profile name in profiles.yml
6+
profile: 'my_project'
7+
8+
model-paths: ["models"]
9+
seed-paths: ["seeds"]
10+
macro-paths: ["macros"]
11+
12+
clean-targets:
13+
- "target"
14+
15+
models:
16+
my_dbt_project:
17+
+materialized: view
18+
+file_format: parquet
19+
20+
flags:
21+
require_certificate_validation: True
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
my_project:
2+
target: prod
3+
outputs:
4+
prod:
5+
type: trino
6+
#method: none
7+
user: admin
8+
password: adminadmin
9+
host: trino-coordinator-default-headless.default.svc.cluster.local
10+
port: 8443
11+
database: lakehouse
12+
schema: my_schema
13+
threads: 4
14+
http_scheme: https
15+
cert: /dbt/trusted/ca.crt
16+
session_properties:
17+
query_max_run_time: "4h"
18+
query_priority: 1
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
dbt-core
2+
dbt-trino
3+
trino==0.329

stacks/trino-iceberg/trino.yaml

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ spec:
1616
opa:
1717
configMapName: opa
1818
package: trino
19+
tls:
20+
serverSecretClass: trino-tls
21+
internalSecretClass: trino-internal-tls
1922
coordinators:
2023
roleGroups:
2124
default:
@@ -27,6 +30,32 @@ spec:
2730
default:
2831
replicas: 1
2932
---
33+
apiVersion: secrets.stackable.tech/v1alpha1
34+
kind: SecretClass
35+
metadata:
36+
name: trino-tls
37+
spec:
38+
backend:
39+
autoTls:
40+
ca:
41+
secret:
42+
name: secret-provisioner-trino-tls-ca
43+
namespace: default
44+
autoGenerate: true
45+
---
46+
apiVersion: secrets.stackable.tech/v1alpha1
47+
kind: SecretClass
48+
metadata:
49+
name: trino-internal-tls
50+
spec:
51+
backend:
52+
autoTls:
53+
ca:
54+
secret:
55+
name: secret-provisioner-trino-internal-tls-ca
56+
namespace: default
57+
autoGenerate: true
58+
---
3059
apiVersion: authentication.stackable.tech/v1alpha1
3160
kind: AuthenticationClass
3261
metadata:
@@ -43,7 +72,7 @@ metadata:
4372
name: trino-users
4473
type: kubernetes.io/opaque
4574
stringData:
46-
admin: "{{ trinoAdminPassword }}"
75+
admin: adminadmin
4776
---
4877
apiVersion: trino.stackable.tech/v1alpha1
4978
kind: TrinoCatalog

0 commit comments

Comments
 (0)