Skip to content

Commit bf3d04c

Browse files
authored
Merge branch 'main' into add-automatic-cert-generation
2 parents 3bf8736 + 7cfa3f1 commit bf3d04c

File tree

14 files changed

+123
-39
lines changed

14 files changed

+123
-39
lines changed

analytics-datastore-clickhouse/docker-compose.cluster.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ services:
55
image: ${CLICKHOUSE_IMAGE}
66
ulimits:
77
noFile: 262144
8+
environment:
9+
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD}
810
volumes:
911
- clickhouse-data-01:/var/lib/clickhouse/
1012
hostname: analytics-datastore-clickhouse-01
@@ -33,6 +35,7 @@ services:
3335
source: clickhouse_trace_log.xml
3436
networks:
3537
public:
38+
reverse-proxy:
3639
default:
3740

3841
analytics-datastore-clickhouse-02:
@@ -44,6 +47,8 @@ services:
4447
- "node.labels.name==${ANALYTICS_DATASTORE_CLICKHOUSE_02_PLACEMENT}"
4548
ulimits:
4649
noFile: 262144
50+
environment:
51+
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD}
4752
volumes:
4853
- clickhouse-data-02:/var/lib/clickhouse/
4954
configs:
@@ -78,6 +83,8 @@ services:
7883
- "node.labels.name==${ANALYTICS_DATASTORE_CLICKHOUSE_03_PLACEMENT}"
7984
ulimits:
8085
noFile: 262144
86+
environment:
87+
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD}
8188
volumes:
8289
- clickhouse-data-03:/var/lib/clickhouse/
8390
configs:
@@ -108,6 +115,8 @@ services:
108115
hostname: analytics-datastore-clickhouse-04
109116
ulimits:
110117
noFile: 262144
118+
environment:
119+
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD}
111120
volumes:
112121
- clickhouse-data-04:/var/lib/clickhouse/
113122
configs:
@@ -213,4 +222,7 @@ networks:
213222
public:
214223
name: clickhouse_public
215224
external: true
225+
reverse-proxy:
226+
name: reverse-proxy_public
227+
external: true
216228
default:

analytics-datastore-clickhouse/docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ services:
55
image: ${CLICKHOUSE_IMAGE}
66
ulimits:
77
noFile: 262144
8+
environment:
9+
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD}
810
volumes:
911
- clickhouse-data:/var/lib/clickhouse/
1012
configs:
@@ -18,6 +20,7 @@ services:
1820
source: clickhouse_trace_log.xml
1921
networks:
2022
public:
23+
reverse-proxy:
2124
default:
2225

2326
volumes:
@@ -49,4 +52,7 @@ networks:
4952
public:
5053
name: clickhouse_public
5154
external: true
55+
reverse-proxy:
56+
name: reverse-proxy_public
57+
external: true
5258
default:

analytics-datastore-clickhouse/importer/config/clickhouseConfig.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,16 @@ const CLICKHOUSE_HOST =
77
process.env.CLICKHOUSE_HOST || 'analytics-datastore-clickhouse';
88
const CLICKHOUSE_PORT = parseInt(process.env.CLICKHOUSE_PORT || '8123');
99
const CLICKHOUSE_DEBUG = Boolean(process.env.CLICKHOUSE_DEBUG || false);
10+
const CLICKHOUSE_PASSWORD = process.env.CLICKHOUSE_PASSWORD || '';
1011

1112
const clickhouse = new ClickHouse({
1213
url: CLICKHOUSE_HOST,
1314
port: CLICKHOUSE_PORT,
1415
debug: CLICKHOUSE_DEBUG,
16+
basicAuth: {
17+
username: 'default',
18+
password: CLICKHOUSE_PASSWORD,
19+
},
1520
raw: true,
1621
});
1722

analytics-datastore-clickhouse/importer/docker-compose.config.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ services:
99
environment:
1010
CLICKHOUSE_HOST: ${CLICKHOUSE_HOST}
1111
CLICKHOUSE_PORT: ${CLICKHOUSE_PORT}
12+
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD}
1213
CLUSTERED_MODE: ${CLUSTERED_MODE}
1314
configs:
1415
- source: config-importer-clickhouseConfig.js

analytics-datastore-clickhouse/package-metadata.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"environmentVariables": {
99
"CLICKHOUSE_HOST": "analytics-datastore-clickhouse",
1010
"CLICKHOUSE_PORT": "8123",
11+
"CLICKHOUSE_PASSWORD": "dev_password_only",
1112
"CLICKHOUSE_IMAGE": "clickhouse/clickhouse-server:23.8.14.6",
1213
"ANALYTICS_DATASTORE_CLICKHOUSE_01_PLACEMENT": "node-1",
1314
"ANALYTICS_DATASTORE_CLICKHOUSE_02_PLACEMENT": "node-2",

analytics-datastore-elastic-search/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ services:
3737
start_period: 1m
3838
volumes:
3939
- es-data:/usr/share/elasticsearch/data
40-
- /backups:/backups/elasticsearch
40+
- ${ES_BACKUPS_PATH:-/backups}:/backups/elasticsearch
4141
networks:
4242
public:
4343

-593 Bytes
Binary file not shown.

dashboard-visualiser-superset/importer/config/supersetConfig.js

Lines changed: 73 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ const SUPERSET_LOGIN_PATH =
1414
process.env.SUPERSET_LOGIN_PATH || '/api/v1/security/login';
1515
const SUPERSET_IMPORT_PATH =
1616
process.env.SUPERSET_IMPORT_PATH || '/api/v1/assets/import/';
17+
const SUPERSET_DATABASE_PUT_PATH =
18+
process.env.SUPERSET_DATABASE_PUT_PATH || '/api/v1/database';
1719
const CONFIG_FILE = process.env.CONFIG_FILE;
1820
const SUPERSET_SSL = process.env.SUPERSET_SSL || 'false';
1921

@@ -27,7 +29,7 @@ const getAccessToken = async () => {
2729
refresh: true,
2830
});
2931

30-
var config = {
32+
const config = {
3133
method: 'POST',
3234
url: `${protocol}://${SUPERSET_SERVICE_NAME}:${SUPERSET_API_PORT}${SUPERSET_LOGIN_PATH}`,
3335
headers: {
@@ -47,39 +49,81 @@ const getAccessToken = async () => {
4749
}
4850
};
4951

52+
const importZipConfig = async (accessToken) => {
53+
const data = new FormData();
54+
55+
if (CONFIG_FILE) {
56+
data.append(
57+
'bundle',
58+
fs.createReadStream(path.resolve(__dirname, CONFIG_FILE))
59+
);
60+
61+
const config = {
62+
method: 'POST',
63+
url: `${protocol}://${SUPERSET_SERVICE_NAME}:${SUPERSET_API_PORT}${SUPERSET_IMPORT_PATH}`,
64+
headers: {
65+
'Content-Type': 'application/zip',
66+
Authorization: `Bearer ${accessToken}`,
67+
...data.getHeaders(),
68+
},
69+
data: data,
70+
};
71+
72+
const res = await axios(config);
73+
74+
console.log('\n', res.data);
75+
console.log('\nConfig imported successfully. exit.');
76+
} else {
77+
throw new Error(
78+
'\nNo path was provided. Please provide the path of the config.'
79+
);
80+
}
81+
}
82+
83+
const replaceClickhouseConnectionString = async (accessToken) => {
84+
const CLICKHOUSE_HOST = process.env.CLICKHOUSE_HOST || 'analytics-datastore-clickhouse';
85+
const CLICKHOUSE_PORT = process.env.CLICKHOUSE_PORT || '8123';
86+
const CLICKHOUSE_PASSWORD = process.env.CLICKHOUSE_PASSWORD || 'dev_password_only';
87+
88+
const databaseConfig = {
89+
allow_ctas: false,
90+
allow_cvas: false,
91+
allow_dml: false,
92+
allow_file_upload: false,
93+
allow_run_async: false,
94+
cache_timeout: 0,
95+
configuration_method: "sqlalchemy_form",
96+
database_name: "Clickhouse connection",
97+
driver: "connect",
98+
engine: "clickhousedb",
99+
expose_in_sqllab: true,
100+
sqlalchemy_uri: `clickhousedb+connect://default:${CLICKHOUSE_PASSWORD}@${CLICKHOUSE_HOST}:${CLICKHOUSE_PORT}/default`,
101+
uuid: "868ecd6d-f099-46ab-a100-dd91173bc63f"
102+
};
103+
104+
const config = {
105+
method: 'POST',
106+
url: `${protocol}://${SUPERSET_SERVICE_NAME}:${SUPERSET_API_PORT}${SUPERSET_DATABASE_PUT_PATH}`,
107+
headers: {
108+
'Content-Type': 'application/json',
109+
Authorization: `Bearer ${accessToken}`
110+
},
111+
data: databaseConfig,
112+
};
113+
114+
const res = await axios(config);
115+
116+
console.log('\n', res.data);
117+
console.log('\Database connection updated successfully. exit.');
118+
}
119+
50120
(async () => {
51121
try {
52122
const accessToken = await getAccessToken();
53123

54124
if (accessToken) {
55-
var data = new FormData();
56-
57-
if (CONFIG_FILE) {
58-
data.append(
59-
'bundle',
60-
fs.createReadStream(path.resolve(__dirname, CONFIG_FILE))
61-
);
62-
63-
var config = {
64-
method: 'POST',
65-
url: `${protocol}://${SUPERSET_SERVICE_NAME}:${SUPERSET_API_PORT}${SUPERSET_IMPORT_PATH}`,
66-
headers: {
67-
'Content-Type': 'application/zip',
68-
Authorization: `Bearer ${accessToken}`,
69-
...data.getHeaders(),
70-
},
71-
data: data,
72-
};
73-
74-
const res = await axios(config);
75-
76-
console.log('\n', res.data);
77-
console.log('\nConfig imported successfully. exit.');
78-
} else {
79-
throw new Error(
80-
'\nNo path was provided. Please provide the path of the config.'
81-
);
82-
}
125+
await importZipConfig(accessToken);
126+
await replaceClickhouseConnectionString(accessToken);
83127
} else {
84128
throw new Error('\nNo access token was generated.');
85129
}

dashboard-visualiser-superset/importer/docker-compose.config.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,17 @@ services:
1313
SUPERSET_API_USERNAME: ${SUPERSET_USERNAME}
1414
CONFIG_FILE: ${SUPERSET_CONFIG_FILE}
1515
SUPERSET_SSL: ${SUPERSET_SSL}
16+
CLICKHOUSE_HOST: ${CLICKHOUSE_HOST}
17+
CLICKHOUSE_PORT: ${CLICKHOUSE_PORT}
18+
CLICKHOUSE_PASSWORD: ${CLICKHOUSE_PASSWORD}
1619
configs:
1720
- source: config-importer-supersetConfig.js
1821
target: /supersetConfig.js
1922
- source: config-importer-superset-export.zip
2023
target: /superset-export.zip
2124
command: sh -c "cd / && npm i axios form-data && node /supersetConfig.js"
25+
networks:
26+
clickhouse:
2227

2328
configs:
2429
config-importer-supersetConfig.js:
@@ -31,3 +36,8 @@ configs:
3136
name: config-importer-superset-export.zip-${config_importer_superset_export_zip_DIGEST:?err}
3237
labels:
3338
name: superset
39+
40+
networks:
41+
clickhouse:
42+
name: clickhouse_public
43+
external: true

dashboard-visualiser-superset/package-metadata.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@
3333
"SUPERSET_POSTGRESQL_PASSWORD": "instant101",
3434
"SUPERSET_POSTGRESQL_DATABASE": "superset",
3535
"SUPERSET_POSTGRESQL_URL": "postgres-1:5432",
36+
"CLICKHOUSE_HOST": "analytics-datastore-clickhouse",
37+
"CLICKHOUSE_PORT": 8123,
38+
"CLICKHOUSE_PASSWORD": "dev_password_only",
3639
"SUPERSET_TRAEFIK_SUBDOMAIN": "superset"
3740
}
3841
}

0 commit comments

Comments
 (0)