Skip to content
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

Add support for service discovery on Kubernetes #129

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# $ docker build . -f ./Dockerfile -t zdm-proxy
##########

FROM golang:1.19-bullseye AS builder
FROM golang:1.23-bookworm AS builder

ENV GO111MODULE=on \
CGO_ENABLED=0 \
Expand Down
4 changes: 2 additions & 2 deletions docker-compose-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ services:
ipv4_address: 192.168.100.102

proxy:
image: golang:1.21.11-bookworm
image: golang:1.23.2-bookworm
container_name: zdm_tests_proxy
restart: unless-stopped
tty: true
Expand All @@ -52,4 +52,4 @@ services:
- /source/compose/nosqlbench-entrypoint.sh
networks:
proxy:
ipv4_address: 192.168.100.104
ipv4_address: 192.168.100.104
53 changes: 43 additions & 10 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,38 +1,71 @@
module github.com/datastax/zdm-proxy

go 1.19
go 1.22.0

toolchain go1.23.2

require (
github.com/antlr/antlr4/runtime/Go/antlr v0.0.0-20211106181442-e4c1a74c66bd
github.com/datastax/go-cassandra-native-protocol v0.0.0-20240626123646-2abea740da8d
github.com/gocql/gocql v0.0.0-20200624222514-34081eda590e
github.com/google/uuid v1.1.1
github.com/google/uuid v1.6.0
github.com/jpillora/backoff v1.0.0
github.com/kelseyhightower/envconfig v1.4.0
github.com/mcuadros/go-defaults v1.2.0
github.com/prometheus/client_golang v1.3.0
github.com/prometheus/client_model v0.1.0
github.com/rs/zerolog v1.20.0
github.com/sirupsen/logrus v1.6.0
github.com/stretchr/testify v1.8.0
github.com/stretchr/testify v1.9.0
gopkg.in/yaml.v3 v3.0.1
k8s.io/apimachinery v0.31.1
k8s.io/client-go v0.31.1
)

require (
github.com/beorn7/perks v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/golang/protobuf v1.3.2 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/logr v1.4.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/protobuf v1.5.4 // indirect
github.com/golang/snappy v0.0.3 // indirect
github.com/google/go-cmp v0.5.2 // indirect
github.com/google/gnostic-models v0.6.8 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/hailocab/go-hostpool v0.0.0-20160125115350-e80d13ce29ed // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/konsorten/go-windows-terminal-sequences v1.0.3 // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
github.com/modern-go/reflect2 v1.0.2 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/pierrec/lz4/v4 v4.0.3 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
github.com/prometheus/common v0.7.0 // indirect
github.com/prometheus/procfs v0.0.8 // indirect
golang.org/x/sys v0.3.0 // indirect
github.com/x448/float16 v0.8.4 // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
google.golang.org/protobuf v1.34.2 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
k8s.io/api v0.31.1 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
sigs.k8s.io/yaml v1.4.0 // indirect
)
141 changes: 126 additions & 15 deletions go.sum

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions proxy/pkg/common/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
// - Assignment of C* hosts per proxy instance for request connections
type TopologyConfig struct {
VirtualizationEnabled bool // enabled if ZDM_PROXY_TOPOLOGY_ADDRESSES is not empty
KubernetesService string // comes from ZDM_PROXY_TOPOLOGY_KUBERNETES_SERVICE
Addresses []net.IP // comes from ZDM_PROXY_TOPOLOGY_ADDRESSES
Count int // comes from length of ZDM_PROXY_TOPOLOGY_ADDRESSES
Index int // comes from ZDM_PROXY_TOPOLOGY_INDEX
Expand Down
10 changes: 6 additions & 4 deletions proxy/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ type Config struct {

// Proxy Topology (also known as system.peers "virtualization") bucket

ProxyTopologyIndex int `default:"0" split_words:"true" yaml:"proxy_topology_index"`
ProxyTopologyAddresses string `split_words:"true" yaml:"proxy_topology_addresses"`
ProxyTopologyNumTokens int `default:"8" split_words:"true" yaml:"proxy_topology_num_tokens"`
ProxyTopologyIndex int `default:"0" split_words:"true" yaml:"proxy_topology_index"`
ProxyTopologyAddresses string `split_words:"true" yaml:"proxy_topology_addresses"`
ProxyTopologyNumTokens int `default:"8" split_words:"true" yaml:"proxy_topology_num_tokens"`
ProxyTopologyKubernetesService string `split_words:"true" yaml:"proxy_topology_kubernetes_service"`

// Origin bucket

Expand Down Expand Up @@ -238,7 +239,7 @@ func (c *Config) ParseTopologyConfig() (*common.TopologyConfig, error) {

proxyInstanceCount := len(proxyAddressesTyped)
proxyIndex := c.ProxyTopologyIndex
if proxyIndex < 0 || proxyIndex >= proxyInstanceCount {
if c.ProxyTopologyKubernetesService == "" && (proxyIndex < 0 || proxyIndex >= proxyInstanceCount) {
return nil, fmt.Errorf("invalid ZDM_PROXY_TOPOLOGY_INDEX and ZDM_PROXY_TOPOLOGY_ADDRESSES values; "+
"proxy index (%d) must be less than length of addresses (%d) and non negative", proxyIndex, proxyInstanceCount)
}
Expand All @@ -253,6 +254,7 @@ func (c *Config) ParseTopologyConfig() (*common.TopologyConfig, error) {
Index: proxyIndex,
Count: proxyInstanceCount,
NumTokens: c.ProxyTopologyNumTokens,
KubernetesService: c.ProxyTopologyKubernetesService,
}, nil
}

Expand Down
Loading