-
Notifications
You must be signed in to change notification settings - Fork 386
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support ClickHouse deployment with Persistent Volume #3608
Conversation
Codecov Report
@@ Coverage Diff @@
## main #3608 +/- ##
==========================================
+ Coverage 64.44% 64.95% +0.50%
==========================================
Files 278 278
Lines 39513 39640 +127
==========================================
+ Hits 25463 25747 +284
+ Misses 12068 11910 -158
- Partials 1982 1983 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
|
@@ -0,0 +1,28 @@ | |||
- op: add |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this change independent from the rest of this PR (PersistentVolume support)? If yes, could it go into a separate PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is inspired by the PV support. This change allows us to generate a manifest without the ClickHouse monitor. We suppose this may happen when user have a large enough PV storage. In that case, the monitor won't be triggered as the throughput bottleneck would be in the flow aggregator side instead of the ClickHouse storage space side. But overall it make sense to me to put it in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This part has been removed from this PR now. Hope it is more clear now. Thanks!
Updated, the file is added back to allow customized storage size. But the optional monitor is still not added in this PR.
@@ -17,7 +17,10 @@ package main | |||
import ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment as above; are the monitor changes related to the PersistentVolume support?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of the monitor changes are related to the PV support. As with PV, user may store ClickHouse data together with other software, in which way the disk usage percentage does not indicate the actual space usage percentage of the ClickHouse. thus we need some update in the disk usage checking logic.
The only unrelated change is I move deletePercentage
and threshold
parameter from hard-coded ones to env variables in yaml to make customized value more convenient. I could take out it from this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed some unrelated changes.
--mode (dev|release) Choose the configuration variant that you need (default is 'dev'). | ||
--keep Debug flag which will preserve the generated kustomization.yml. | ||
--volume (ram|pv) Choose the volume provider that you need (default is 'ram'). | ||
--storageclass -sc <name> Provide the StorageClass used to dynamically provision the | ||
Persistent Volume for ClickHouse storage. | ||
--local <path> Create the Persistent Volume for ClickHouse with a provided | ||
local path. | ||
--nfs <hostname:path> Create the Persistent Volume for ClickHouse with a provided | ||
NFS server hostname or IP address and the path exported in the | ||
form of hostname:path. | ||
--no-ch-monitor Generate a manifest without the ClickHouse monitor. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like instead of adding all these flags we should work on adding helm support for the flow visibility solution right away (see #3578) as it provides a more natural / standardized way of generating the manifests than our custom generate-manifest
scripts. Configuring a PV / PVC would be much easier with helm charts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It sounds good to add helm support for the flow visibility solution. But as we are migrating from the main repo to a child repo theia, the purpose of opening this PR in main repo is to include PV support for the first round of CQE testing. I wonder if it is possible to have the PV support with Kustomize first. When we finish the migration, we can add helm support on the child repo side.
I also notice you mention
In a future PR, we will look into the release process for the Helm chart. After that, Helm charts could be added for Antrea components (Flow Aggregator, Flow visibility).
Does this mean it takes more time to support Helm chart for other Antrea components? Maybe we can do the update from Kustomize to Helm in another PR and Theia side?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should definetely have a target to provide a helm chart for flow visibility in 1.7, just like Antonin is doing for Antrea.
I also think this can be done in a dedicated PR, to avoid conflating too many changes into a single PR.
- ReadWriteOnce | ||
resources: | ||
requests: | ||
storage: 8Gi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do not specify the request, the pvc will be allowed access to the whole volume, if I recall correctly.
Since the volume is created specifically for clickhouse, I think it might be ok.
The point of this comment is simply to avoid specifying volume size in too many places.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually Kubernetes does not have any enforcement on the storage capacity. The storage size on PV is a required field only for informative. Similarly, the storage size on PVC is required but does not have enforcement on how many space the pod can use. But it will be used to match a PV. Only a PV with a capacity equal to or larger the value specified in the PVC can be bound with this PVC.
--nfs) | ||
NFSPATH="$2" | ||
shift 2 | ||
;; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you think we can add something specify the size?
I can think of two ways
- we consider the yaml patches as templates and we replace the size with the actual one before generating the manifests (we should be careful about not doing in place modification)
- (not sure if feasible) we add vars to the patch files where size is specified and point this vars to an env variable with the desired size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I update the shell with the first way. I think it might be easier to do something similar to the second way when we move to Helm, with which we can load this value from value.yaml
. Will target Helm chart support in release 1.7.
func getDiskUsage(connect *sql.DB, freeSpace *uint64, totalSpace *uint64) { | ||
// Get free space from ClickHouse system table | ||
if err := wait.PollImmediate(queryRetryInterval, queryTimeout, func() (bool, error) { | ||
if err := connect.QueryRow("SELECT free_space, total_space FROM system.disks").Scan(freeSpace, totalSpace); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you can query total_space from clickhouse, do you need to pass the storage size as an env variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This might already be explained by the #3608 (comment). The total_space
here is the size of the partition on the disk where the ClickHouse storages its data in. It might be shared with other software, thus we need a storage size from user to be used as a desired space for ClickHouse.
name: clickhouse-storage | ||
provisioner: kubernetes.io/no-provisioner | ||
volumeBindingMode: WaitForFirstConsumer | ||
reclaimPolicy: Delete |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After deleting our flow visibility deployment, the PV users may like to retain the flows data inside their disk/volume. Could we achieve that by having an option (or add instruction in doc) to change the reclaimPolicy to "Retain"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Yongming for pointing out this! I investigated the reclaimPolicy
a little bit more and noticed that the Delete
only supported by a few dynamically provisioned PVs, which does not include our two examples. Thus even if I specify Delete
here, the reclaimPolicy of the PVs deployed is still Retain
. I updated the manifest and docs to make it clear.
0928b4e
to
1396fd4
Compare
Hi @antoninbas Could you take another look at this PR? |
@@ -200,3 +255,37 @@ func getDeleteRowNum(connect *sql.DB) (uint64, error) { | |||
deleteRowNum = uint64(float64(count) * deletePercentage) | |||
return deleteRowNum, nil | |||
} | |||
|
|||
// Parse human readable storage size to number in bytes | |||
func parseSize(sizeString string) (uint64, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am curious: there is no existing function to do that in K8s libraries?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks Antonin for reviewing! I took a deeper look into the K8S libraries, and found an API from resource
. Replaced the function.
In both examples, you can set `.spec.capacity.storage` in PersistentVolume | ||
to your storage size. This value is for informative purpose as K8s does not | ||
enforce the capacity of PVs. If you want to limit the storage usage, you need | ||
to ask for your storage system to enforce that. For example, you can create | ||
a Local PV on a partition with the limited size. We recommend using a dedicated | ||
saving space for the ClickHouse if you are going to run the Flow Collector in | ||
production. | ||
|
||
As these examples do not use any dynamic provisioner, the reclaim policy | ||
for the PVs is `Retain` by default. After stopping the Grafana Flow Collector, | ||
if you no long need the data for future use, you may need to manually clean | ||
up the data on the local disk or NFS server. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that these 2 paragraphs should be indented?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems the ordered list index for the steps will be broken with these two paragraphs unindented.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, that's my bad
docs/network-flow-visibility.md
Outdated
a specific Node. Refer to [createLocalPv.yml][local_pv_yaml] to create the | ||
PV. Please replace `LOCAL_PATH` with the path to store the ClickHouse data | ||
and label the Node used to store the ClickHouse data with | ||
`clickhouse/instance=data`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this label was created by you and is not a standard ClickHouse label?
If it is indeed the case, I think you should prefix the label name with antrea.io
, like we do for other Antrea-specific labels.
Maybe the label should not have a value either. Something like antrea.io/clickhouse-data-node=
. I am not sure if you plan to use the same label key for anything else.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. This label is only for the Local PV node affinity. Updated.
@yanjunz97 I approved but looks like you have a merge conflict |
Thanks! I have rebased and resolved the conflicts. |
/test-e2e |
cp $KUSTOMIZATION_DIR/patches/chmonitor/*.yml . | ||
|
||
# patch the clickhouse monitor with desired storage size | ||
$KUSTOMIZE edit add base base | ||
sed -i.bak -E "s/STORAGE_SIZE_VALUE/$SIZE/" chMonitor.yml | ||
$KUSTOMIZE edit add patch --path chMonitor.yml --group clickhouse.altinity.com --version v1 --kind ClickHouseInstallation --name clickhouse |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wsquan171 could you look at this. Do we need the monitor for e2e tests, that doesn't seem right to me?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As previously we do not separate the monitor from the ClickHouse deployment, it is included by default in the e2e test. Thus I keep it in this update. But I'm glad to remove it if @wsquan171 thinks it is safe to do this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't really need or test the monitor now. As Yanjun mentioned it's included before since there's no harm to have it, but also as it's a hassle to just removed it for e2e. since now the manifest generation takes the monitor out by default I don't see the need to introduce more work to just add it back. we'd also want to mentioned that monitor is absent in the help message print when in e2e mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Removed the monitor related contents for the e2e mode.
Signed-off-by: Yanjun Zhou <zhouya@vmware.com>
/test-e2e |
/test-e2e |
Hi @antoninbas This PR can be merged if no other comment. |
This commit supports deploying ClickHouse with Persistent Volume. It provides examples using Local PV, NFS PV or other customized StorageClass.
Signed-off-by: Yanjun Zhou zhouya@vmware.com