Skip to content

Commit

Permalink
Upgrade ClickHouse server image to v23.4 (#306)
Browse files Browse the repository at this point in the history
* Upgrade ClickHouse server image to v23.4

- Upgrade ClickHouse server to v23.4
- Upgrade ClickHouse operator and metrics exporter to v0.21.0

Notable changes:
- The inner table name of Materialized View has
been changed to `.inner_id.<uuid>`. We are no longer able to
find the table by self-defined Materialized View name. Thus,
in `create_table.sh`, we save the data of Materialized Views
to pre-defined underlying tables.
- ClickHouse upgrade test used to always apply the latest
clickhouse-operator-install-bundle.yaml. In this upgrade,
latest operator yaml does not work with version N-1 ClickHouse
data schema. Therefore, we change the test to use the correct
version of operator yaml corresponding to the tested ClickHouse
data schema.
- We removed the theia- prefix in clickhouse operator images in
- We increase theia-manager ping timeout when connecting to
ClickHouse Service to fix test flakiness.

Signed-off-by: heanlan <hanlan@vmware.com>

* Add time wait before starting iPerf traffic in e2e test

Signed-off-by: heanlan <hanlan@vmware.com>

---------

Signed-off-by: heanlan <hanlan@vmware.com>
  • Loading branch information
heanlan authored Jun 8, 2023
1 parent 96a2009 commit 61818ba
Show file tree
Hide file tree
Showing 18 changed files with 1,750 additions and 984 deletions.
1,677 changes: 796 additions & 881 deletions build/charts/theia/crds/clickhouse-operator-install-bundle.yaml

Large diffs are not rendered by default.

120 changes: 96 additions & 24 deletions build/charts/theia/provisioning/datasources/create_table.sh
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,31 @@ clickhouse client -n -h 127.0.0.1 <<-EOSQL
ALTER TABLE flows_local MODIFY TTL timeInserted + INTERVAL {{ .Values.clickhouse.ttl }};
ALTER TABLE flows_local MODIFY SETTING merge_with_ttl_timeout={{ $ttlTimeout }};
--Create a Materialized View to aggregate data for pods
CREATE MATERIALIZED VIEW IF NOT EXISTS flows_pod_view_local
ENGINE = ReplicatedSummingMergeTree('/clickhouse/tables/{shard}/{database}/{table}', '{replica}')
--Create a Materialized View to aggregate data for Pods and save the data
--to default.pod_view_table_local
CREATE TABLE IF NOT EXISTS pod_view_table_local (
timeInserted DateTime DEFAULT now(),
flowEndSeconds DateTime,
flowEndSecondsFromSourceNode DateTime,
flowEndSecondsFromDestinationNode DateTime,
sourcePodName String,
destinationPodName String,
destinationIP String,
destinationServicePort UInt16,
destinationServicePortName String,
flowType UInt8,
sourcePodNamespace String,
destinationPodNamespace String,
sourceTransportPort UInt16,
destinationTransportPort UInt16,
octetDeltaCount UInt64,
reverseOctetDeltaCount UInt64,
throughput UInt64,
reverseThroughput UInt64,
throughputFromSourceNode UInt64,
throughputFromDestinationNode UInt64,
clusterUUID String
) ENGINE = ReplicatedSummingMergeTree('/clickhouse/tables/{shard}/{database}/{table}', '{replica}')
ORDER BY (
timeInserted,
flowEndSeconds,
Expand All @@ -103,8 +125,12 @@ clickhouse client -n -h 127.0.0.1 <<-EOSQL
destinationPodNamespace,
sourceTransportPort,
destinationTransportPort,
clusterUUID)
POPULATE
clusterUUID);
ALTER TABLE "pod_view_table_local" MODIFY TTL timeInserted + INTERVAL {{ .Values.clickhouse.ttl }};
ALTER TABLE "pod_view_table_local" MODIFY SETTING merge_with_ttl_timeout={{ $ttlTimeout }};
CREATE MATERIALIZED VIEW IF NOT EXISTS flows_pod_view_local TO pod_view_table_local
AS SELECT
timeInserted,
flowEndSeconds,
Expand Down Expand Up @@ -145,12 +171,27 @@ clickhouse client -n -h 127.0.0.1 <<-EOSQL
destinationTransportPort,
clusterUUID;
ALTER TABLE ".inner.flows_pod_view_local" MODIFY TTL timeInserted + INTERVAL {{ .Values.clickhouse.ttl }};
ALTER TABLE ".inner.flows_pod_view_local" MODIFY SETTING merge_with_ttl_timeout={{ $ttlTimeout }};
--Create a Materialized View to aggregate data for nodes
CREATE MATERIALIZED VIEW IF NOT EXISTS flows_node_view_local
ENGINE = ReplicatedSummingMergeTree('/clickhouse/tables/{shard}/{database}/{table}', '{replica}')
--Create a Materialized View to aggregate data for Nodes and save the data
--to default.node_view_table_local
CREATE TABLE IF NOT EXISTS node_view_table_local (
timeInserted DateTime DEFAULT now(),
flowEndSeconds DateTime,
flowEndSecondsFromSourceNode DateTime,
flowEndSecondsFromDestinationNode DateTime,
sourceNodeName String,
destinationNodeName String,
sourcePodNamespace String,
destinationPodNamespace String,
octetDeltaCount UInt64,
reverseOctetDeltaCount UInt64,
throughput UInt64,
reverseThroughput UInt64,
throughputFromSourceNode UInt64,
reverseThroughputFromSourceNode UInt64,
throughputFromDestinationNode UInt64,
reverseThroughputFromDestinationNode UInt64,
clusterUUID String
) ENGINE = ReplicatedSummingMergeTree('/clickhouse/tables/{shard}/{database}/{table}', '{replica}')
ORDER BY (
timeInserted,
flowEndSeconds,
Expand All @@ -160,8 +201,12 @@ clickhouse client -n -h 127.0.0.1 <<-EOSQL
destinationNodeName,
sourcePodNamespace,
destinationPodNamespace,
clusterUUID)
POPULATE
clusterUUID);
ALTER TABLE "node_view_table_local" MODIFY TTL timeInserted + INTERVAL {{ .Values.clickhouse.ttl }};
ALTER TABLE "node_view_table_local" MODIFY SETTING merge_with_ttl_timeout={{ $ttlTimeout }};
CREATE MATERIALIZED VIEW IF NOT EXISTS flows_node_view_local TO node_view_table_local
AS SELECT
timeInserted,
flowEndSeconds,
Expand Down Expand Up @@ -192,12 +237,38 @@ clickhouse client -n -h 127.0.0.1 <<-EOSQL
destinationPodNamespace,
clusterUUID;
ALTER TABLE ".inner.flows_node_view_local" MODIFY TTL timeInserted + INTERVAL {{ .Values.clickhouse.ttl }};
ALTER TABLE ".inner.flows_node_view_local" MODIFY SETTING merge_with_ttl_timeout={{ $ttlTimeout }};
--Create a Materialized View to aggregate data for network policies
CREATE MATERIALIZED VIEW IF NOT EXISTS flows_policy_view_local
ENGINE = ReplicatedSummingMergeTree('/clickhouse/tables/{shard}/{database}/{table}', '{replica}')
--Create a Materialized View to aggregate data for network policies and
--save the data to default.policy_view_table_local
CREATE TABLE IF NOT EXISTS policy_view_table_local (
timeInserted DateTime DEFAULT now(),
flowEndSeconds DateTime,
flowEndSecondsFromSourceNode DateTime,
flowEndSecondsFromDestinationNode DateTime,
egressNetworkPolicyName String,
egressNetworkPolicyNamespace String,
egressNetworkPolicyRuleAction UInt8,
ingressNetworkPolicyName String,
ingressNetworkPolicyNamespace String,
ingressNetworkPolicyRuleAction UInt8,
sourcePodName String,
sourceTransportPort UInt16,
sourcePodNamespace String,
destinationPodName String,
destinationTransportPort UInt16,
destinationPodNamespace String,
destinationServicePort UInt16,
destinationServicePortName String,
destinationIP String,
octetDeltaCount UInt64,
reverseOctetDeltaCount UInt64,
throughput UInt64,
reverseThroughput UInt64,
throughputFromSourceNode UInt64,
reverseThroughputFromSourceNode UInt64,
throughputFromDestinationNode UInt64,
reverseThroughputFromDestinationNode UInt64,
clusterUUID String
) ENGINE = ReplicatedSummingMergeTree('/clickhouse/tables/{shard}/{database}/{table}', '{replica}')
ORDER BY (
timeInserted,
flowEndSeconds,
Expand All @@ -218,8 +289,12 @@ clickhouse client -n -h 127.0.0.1 <<-EOSQL
destinationServicePort,
destinationServicePortName,
destinationIP,
clusterUUID)
POPULATE
clusterUUID);
ALTER TABLE "policy_view_table_local" MODIFY TTL timeInserted + INTERVAL {{ .Values.clickhouse.ttl }};
ALTER TABLE "policy_view_table_local" MODIFY SETTING merge_with_ttl_timeout={{ $ttlTimeout }};
CREATE MATERIALIZED VIEW IF NOT EXISTS flows_policy_view_local to policy_view_table_local
AS SELECT
timeInserted,
flowEndSeconds,
Expand Down Expand Up @@ -272,9 +347,6 @@ clickhouse client -n -h 127.0.0.1 <<-EOSQL
destinationIP,
clusterUUID;
ALTER TABLE ".inner.flows_policy_view_local" MODIFY TTL timeInserted + INTERVAL {{ .Values.clickhouse.ttl }};
ALTER TABLE ".inner.flows_policy_view_local" MODIFY SETTING merge_with_ttl_timeout={{ $ttlTimeout }};
--Create a table to store the network policy recommendation results
CREATE TABLE IF NOT EXISTS recommendations_local (
id String,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
DROP VIEW flows_pod_view_local;
DROP VIEW flows_node_view_local;
DROP VIEW flows_policy_view_local;

--Create a Materialized View to aggregate data for pods
CREATE MATERIALIZED VIEW IF NOT EXISTS flows_pod_view_local
ENGINE = ReplicatedSummingMergeTree('/clickhouse/tables/{shard}/{database}/{table}', '{replica}')
ORDER BY (
timeInserted,
flowEndSeconds,
flowEndSecondsFromSourceNode,
flowEndSecondsFromDestinationNode,
sourcePodName,
destinationPodName,
destinationIP,
destinationServicePort,
destinationServicePortName,
flowType,
sourcePodNamespace,
destinationPodNamespace,
sourceTransportPort,
destinationTransportPort,
clusterUUID)
POPULATE
AS SELECT
timeInserted,
flowEndSeconds,
flowEndSecondsFromSourceNode,
flowEndSecondsFromDestinationNode,
sourcePodName,
destinationPodName,
destinationIP,
destinationServicePort,
destinationServicePortName,
flowType,
sourcePodNamespace,
destinationPodNamespace,
sourceTransportPort,
destinationTransportPort,
sum(octetDeltaCount) AS octetDeltaCount,
sum(reverseOctetDeltaCount) AS reverseOctetDeltaCount,
sum(throughput) AS throughput,
sum(reverseThroughput) AS reverseThroughput,
sum(throughputFromSourceNode) AS throughputFromSourceNode,
sum(throughputFromDestinationNode) AS throughputFromDestinationNode,
clusterUUID
FROM flows_local
GROUP BY
timeInserted,
flowEndSeconds,
flowEndSecondsFromSourceNode,
flowEndSecondsFromDestinationNode,
sourcePodName,
destinationPodName,
destinationIP,
destinationServicePort,
destinationServicePortName,
flowType,
sourcePodNamespace,
destinationPodNamespace,
sourceTransportPort,
destinationTransportPort,
clusterUUID;

--Create a Materialized View to aggregate data for nodes
CREATE MATERIALIZED VIEW IF NOT EXISTS flows_node_view_local
ENGINE = ReplicatedSummingMergeTree('/clickhouse/tables/{shard}/{database}/{table}', '{replica}')
ORDER BY (
timeInserted,
flowEndSeconds,
flowEndSecondsFromSourceNode,
flowEndSecondsFromDestinationNode,
sourceNodeName,
destinationNodeName,
sourcePodNamespace,
destinationPodNamespace,
clusterUUID)
POPULATE
AS SELECT
timeInserted,
flowEndSeconds,
flowEndSecondsFromSourceNode,
flowEndSecondsFromDestinationNode,
sourceNodeName,
destinationNodeName,
sourcePodNamespace,
destinationPodNamespace,
sum(octetDeltaCount) AS octetDeltaCount,
sum(reverseOctetDeltaCount) AS reverseOctetDeltaCount,
sum(throughput) AS throughput,
sum(reverseThroughput) AS reverseThroughput,
sum(throughputFromSourceNode) AS throughputFromSourceNode,
sum(reverseThroughputFromSourceNode) AS reverseThroughputFromSourceNode,
sum(throughputFromDestinationNode) AS throughputFromDestinationNode,
sum(reverseThroughputFromDestinationNode) AS reverseThroughputFromDestinationNode,
clusterUUID
FROM flows_local
GROUP BY
timeInserted,
flowEndSeconds,
flowEndSecondsFromSourceNode,
flowEndSecondsFromDestinationNode,
sourceNodeName,
destinationNodeName,
sourcePodNamespace,
destinationPodNamespace,
clusterUUID;

--Create a Materialized View to aggregate data for network policies
CREATE MATERIALIZED VIEW IF NOT EXISTS flows_policy_view_local
ENGINE = ReplicatedSummingMergeTree('/clickhouse/tables/{shard}/{database}/{table}', '{replica}')
ORDER BY (
timeInserted,
flowEndSeconds,
flowEndSecondsFromSourceNode,
flowEndSecondsFromDestinationNode,
egressNetworkPolicyName,
egressNetworkPolicyNamespace,
egressNetworkPolicyRuleAction,
ingressNetworkPolicyName,
ingressNetworkPolicyNamespace,
ingressNetworkPolicyRuleAction,
sourcePodName,
sourceTransportPort,
sourcePodNamespace,
destinationPodName,
destinationTransportPort,
destinationPodNamespace,
destinationServicePort,
destinationServicePortName,
destinationIP,
clusterUUID)
POPULATE
AS SELECT
timeInserted,
flowEndSeconds,
flowEndSecondsFromSourceNode,
flowEndSecondsFromDestinationNode,
egressNetworkPolicyName,
egressNetworkPolicyNamespace,
egressNetworkPolicyRuleAction,
ingressNetworkPolicyName,
ingressNetworkPolicyNamespace,
ingressNetworkPolicyRuleAction,
sourcePodName,
sourceTransportPort,
sourcePodNamespace,
destinationPodName,
destinationTransportPort,
destinationPodNamespace,
destinationServicePort,
destinationServicePortName,
destinationIP,
sum(octetDeltaCount) AS octetDeltaCount,
sum(reverseOctetDeltaCount) AS reverseOctetDeltaCount,
sum(throughput) AS throughput,
sum(reverseThroughput) AS reverseThroughput,
sum(throughputFromSourceNode) AS throughputFromSourceNode,
sum(reverseThroughputFromSourceNode) AS reverseThroughputFromSourceNode,
sum(throughputFromDestinationNode) AS throughputFromDestinationNode,
sum(reverseThroughputFromDestinationNode) AS reverseThroughputFromDestinationNode,
clusterUUID
FROM flows_local
GROUP BY
timeInserted,
flowEndSeconds,
flowEndSecondsFromSourceNode,
flowEndSecondsFromDestinationNode,
egressNetworkPolicyName,
egressNetworkPolicyNamespace,
egressNetworkPolicyRuleAction,
ingressNetworkPolicyName,
ingressNetworkPolicyNamespace,
ingressNetworkPolicyRuleAction,
sourcePodName,
sourceTransportPort,
sourcePodNamespace,
destinationPodName,
destinationTransportPort,
destinationPodNamespace,
destinationServicePort,
destinationServicePortName,
destinationIP,
clusterUUID;

INSERT INTO ".inner.flows_pod_view_local" SELECT * FROM pod_view_table_local;
INSERT INTO ".inner.flows_node_view_local" SELECT * FROM node_view_table_local;
INSERT INTO ".inner.flows_policy_view_local" SELECT * FROM policy_view_table_local;

DROP TABLE pod_view_table_local;
DROP TABLE node_view_table_local;
DROP TABLE policy_view_table_local;
Loading

0 comments on commit 61818ba

Please sign in to comment.