|
1 | 1 | # kubenetmon |
2 | 2 |
|
3 | 3 | ## What is kubenetmon? |
4 | | -`kubenetmon` is a service built and used at [ClickHouse](clickhouse.com) for Kubernetes data transfer metering in all 3 major cloud providers: AWS, GCP, and Azure. |
| 4 | +`kubenetmon` is a service built and used at [ClickHouse](https://clickhouse.com) for Kubernetes data transfer metering in all 3 major cloud providers: AWS, GCP, and Azure. |
| 5 | + |
| 6 | +`kubenetmon` is packaged as a Helm chart with a Docker image. The chart is available at [https://kubenetmon.clickhouse.tech/index.yaml](https://kubenetmon.clickhouse.tech/index.yaml). See below for detailed usage instructions. |
5 | 7 |
|
6 | 8 | ## What can kubenetmon be used for? |
7 | 9 | At ClickHouse Cloud, we use `kubenetmon` to meter data transfer of all of our workloads running in Kubernetes. With the data `kubenetmon` collects and stores in ClickHouse, we are able to answer questions such as: |
@@ -70,23 +72,35 @@ TTL intervalStartTime + toIntervalDay(90) |
70 | 72 | SETTINGS index_granularity = 8192, ttl_only_drop_parts = 1; |
71 | 73 | ``` |
72 | 74 |
|
73 | | -All you now need is a Kubernetes cluster where you want to meter data transfer. First, we create two namespaces: |
| 75 | +All you now need is a Kubernetes cluster where you want to meter data transfer. |
| 76 | + |
| 77 | +(**Optional**) If you don't have a test k8s cluster, you can spin up a `kind` cluster using config in this repository like so: |
74 | 78 | ``` |
75 | | -kubectl create namespace kubenetmon-server |
76 | | -kubectl create namespace kubenetmon-agent |
| 79 | +kind create cluster --config=test/kind-config.yaml |
77 | 80 | ``` |
78 | 81 |
|
79 | | -**Optional** (if you don't have many workloads running in the cluster, you can install some mock services) |
| 82 | +(**Optional**) And if you don't have many workloads running in the cluster, you can install some mock services) |
80 | 83 | ``` |
| 84 | +helm repo add podinfo https://stefanprodan.github.io/podinfo |
81 | 85 | helm upgrade --install --wait backend --namespace default --set redis.enabled=true podinfo/podinfo |
82 | 86 | helm upgrade --install --wait frontend --namespace default --set redis.enabled=true podinfo/podinfo |
83 | 87 | ``` |
84 | 88 |
|
| 89 | +Next, we create two namespaces: |
| 90 | +``` |
| 91 | +kubectl create namespace kubenetmon-server |
| 92 | +kubectl create namespace kubenetmon-agent |
| 93 | +``` |
| 94 | + |
| 95 | +Let's add this Helm repository: |
| 96 | +``` |
| 97 | +helm repo add kubenetmon https://kubenetmon.clickhouse.tech |
| 98 | +``` |
| 99 | + |
85 | 100 | We now install `kubenetmon-server`. `kubenetmon-server` expects an environment, cluster name, cloud provider name (`aws`, `gcp`, or `azure`), and region, so we provide these. We are also going to supply connection credentials for our ClickHouse instance: |
86 | 101 | ``` |
87 | | -helm install kubenetmon-server kubenetmon-server/kubenetmon-server-1.0.0.tgz --namespace kubenetmon-server \ |
88 | | ---set image.repository=ghcr.io/clickhouse/kubenetmon \ |
89 | | ---set image.tag=latest \ |
| 102 | +helm install kubenetmon-server kubenetmon/kubenetmon-server \ |
| 103 | +--namespace kubenetmon-server \ |
90 | 104 | --set region=us-west-2 \ |
91 | 105 | --set cluster=cluster \ |
92 | 106 | --set environment=development \ |
@@ -117,19 +131,16 @@ you need to enable it on the nodes with: |
117 | 131 | ``` |
118 | 132 | **This is an important step, don't skip it!** |
119 | 133 |
|
120 | | -For example, to test getting data transfer information from just one node, I can run: |
| 134 | +For example, to test getting data transfer information from all nodes in the kind cluster, you can run: |
121 | 135 | ``` |
122 | | -➜ ~ kubectl node-shell kind-worker |
123 | | -spawning "nsenter-b3sdnm" on "kind-worker" |
124 | | -If you don't see a command prompt, try pressing enter. |
125 | | -root@kind-worker:/# /bin/echo "1" > /proc/sys/net/netfilter/nf_conntrack_acct |
| 136 | +for node in $(kubectl get nodes -o name); do |
| 137 | + kubectl node-shell ${node##node/} -- /bin/sh -c '/bin/echo "1" > /proc/sys/net/netfilter/nf_conntrack_acct' |
| 138 | +done |
126 | 139 | ``` |
127 | 140 |
|
128 | | -This node is now ready to host `kubenetmon-agent`, so let's install it. |
| 141 | +Nodes are now ready to host `kubenetmon-agent`, so let's install it. |
129 | 142 | ``` |
130 | | -helm install kubenetmon-agent kubenetmon-agent/kubenetmon-agent-1.0.0.tgz --namespace kubenetmon-agent \ |
131 | | ---set image.repository=ghcr.io/clickhouse/kubenetmon \ |
132 | | ---set image.tag=latest |
| 143 | +helm install kubenetmon-agent kubenetmon/kubenetmon-agent --namespace kubenetmon-agent |
133 | 144 | ``` |
134 | 145 |
|
135 | 146 | Let's check the logs: |
|
0 commit comments