Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ package main
import (
"errors"
"fmt"
"strings"
"time"

"net"
"net/http"
"os"
"runtime"
"runtime/debug"
"strings"
"time"

yaml "gopkg.in/yaml.v3"
"k8s.io/client-go/kubernetes"
Expand Down Expand Up @@ -46,6 +45,7 @@ type Config struct {
ClickHouseWaitForAsyncInsert bool `yaml:"clickhouse_wait_for_async_insert"`
ClickHouseSkipPing bool `yaml:"clickhouse_skip_ping"`
ClickHouseDisableTLS bool `yaml:"clickhouse_disable_tls"`
ClickHouseInsecureSkipVerify bool `yaml:"clickhouse_insecure_skip_verify"`

ClickHouseUsername string
ClickHousePassword string
Expand All @@ -57,9 +57,7 @@ const (
defaultClickHousePasswordPath string = "/etc/clickhouse/password"
)

var (
configMap = Config{}
)
var configMap = Config{}

func init() {
b, err := os.ReadFile(defaultClickHouseConfigPath)
Expand All @@ -72,7 +70,7 @@ func init() {
}

if configMap.IgnoreUDP == nil {
var b = true
b := true
configMap.IgnoreUDP = &b
}

Expand Down Expand Up @@ -176,6 +174,7 @@ func main() {
BatchSize: configMap.ClickHouseBatchSize,
BatchSendTimeout: configMap.ClickHouseBatchSendTimeout,
WaitForAsyncInsert: configMap.ClickHouseWaitForAsyncInsert,
InsecureSkipVerify: configMap.ClickHouseInsecureSkipVerify,

SkipPing: configMap.ClickHouseSkipPing,
DisableTLS: configMap.ClickHouseDisableTLS,
Expand All @@ -188,7 +187,7 @@ func main() {

server := NewFlowHandlerServer(labeler, inserter)
go func() {
var opts = []grpc.ServerOption{
opts := []grpc.ServerOption{
grpc.KeepaliveParams(keepalive.ServerParameters{
MaxConnectionAge: configMap.MaxGRPCConnectionAge,
MaxConnectionAgeGrace: 1 * time.Minute,
Expand Down
1 change: 1 addition & 0 deletions deploy/helm/kubenetmon-server/templates/configMap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,3 +26,4 @@ data:
clickhouse_wait_for_async_insert: {{ .Values.inserter.waitForAsyncInsert }}
clickhouse_skip_ping: {{ .Values.inserter.skipPing }}
clickhouse_disable_tls: {{ .Values.inserter.disableTLS }}
clickhouse_insecure_skip_verify: {{ .Values.inserter.insecureSkipVerify }}
2 changes: 2 additions & 0 deletions deploy/helm/kubenetmon-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ inserter:
skipPing: false
# Disable TLS to ClickHouse. This is useful for testing.
disableTLS: false
# setup insecure skip verify on TLS connection. Useful on TLS connection intern to clickhouse
insecureSkipVerify: false

deployment:
replicaCount: 3
Expand Down
4 changes: 3 additions & 1 deletion pkg/inserter/inserter.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ type ClickHouseOptions struct {
SkipPing bool
// Disable TLS on ClickHouse connection.
DisableTLS bool
// Allow TLS with unverified certificates
InsecureSkipVerify bool
}

// Observation is a conntrack observation from kubenetmon-agent labeled by the
Expand Down Expand Up @@ -132,7 +134,7 @@ func createClickHouseConnectionWithOptions(ctx context.Context, clickhouseOption
}
// Configure TLS if need be.
if !clickhouseOptions.DisableTLS {
options.TLS = &tls.Config{}
options.TLS = &tls.Config{InsecureSkipVerify: clickhouseOptions.InsecureSkipVerify}
}

conn, err := clickhouse.Open(&options)
Expand Down