Skip to content

Commit

Permalink
Change config attribute from "k8s" to "kubernetes"
Browse files Browse the repository at this point in the history
  • Loading branch information
ptodev committed Nov 14, 2023
1 parent bb76009 commit fd9a1ed
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 23 deletions.
24 changes: 12 additions & 12 deletions component/otelcol/exporter/loadbalancing/loadbalancing.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@ func (otlpConfig OtlpConfig) Convert() otlpexporter.Config {

// ResolverSettings defines the configurations for the backend resolver
type ResolverSettings struct {
Static *StaticResolver `river:"static,block,optional"`
DNS *DNSResolver `river:"dns,block,optional"`
K8sSvc *K8sSvcResolver `river:"k8s,block,optional"`
Static *StaticResolver `river:"static,block,optional"`
DNS *DNSResolver `river:"dns,block,optional"`
Kubernetes *KubernetesResolver `river:"kubernetes,block,optional"`
}

func (resolverSettings ResolverSettings) Convert() loadbalancingexporter.ResolverSettings {
Expand All @@ -155,9 +155,9 @@ func (resolverSettings ResolverSettings) Convert() loadbalancingexporter.Resolve
res.DNS = &dnsResolver
}

if resolverSettings.K8sSvc != nil {
k8sSvcResolver := resolverSettings.K8sSvc.Convert()
res.K8sSvc = &k8sSvcResolver
if resolverSettings.Kubernetes != nil {
kubernetesResolver := resolverSettings.Kubernetes.Convert()
res.K8sSvc = &kubernetesResolver
}

return res
Expand Down Expand Up @@ -205,23 +205,23 @@ func (dnsResolver *DNSResolver) Convert() loadbalancingexporter.DNSResolver {
}
}

// K8sSvcResolver defines the configuration for the k8s resolver
type K8sSvcResolver struct {
// KubernetesResolver defines the configuration for the k8s resolver
type KubernetesResolver struct {
Service string `river:"service,attr"`
Ports []int32 `river:"ports,attr,optional"`
}

var _ river.Defaulter = &K8sSvcResolver{}
var _ river.Defaulter = &KubernetesResolver{}

// DefaultDNSResolver holds default values for K8sSvcResolver.
var DefaultK8sSvcResolver = K8sSvcResolver{}
var DefaultK8sSvcResolver = KubernetesResolver{}

// SetToDefault implements river.Defaulter.
func (args *K8sSvcResolver) SetToDefault() {
func (args *KubernetesResolver) SetToDefault() {
*args = DefaultK8sSvcResolver
}

func (k8sSvcResolver *K8sSvcResolver) Convert() loadbalancingexporter.K8sSvcResolver {
func (k8sSvcResolver *KubernetesResolver) Convert() loadbalancingexporter.K8sSvcResolver {
return loadbalancingexporter.K8sSvcResolver{
Service: k8sSvcResolver.Service,
Ports: k8sSvcResolver.Ports,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func TestConfigConversion(t *testing.T) {
testName: "k8s with defaults",
agentCfg: `
resolver {
k8s {
kubernetes {
service = "lb-svc.lb-ns"
}
}
Expand All @@ -232,7 +232,7 @@ func TestConfigConversion(t *testing.T) {
testName: "k8s with non-defaults",
agentCfg: `
resolver {
k8s {
kubernetes {
service = "lb-svc.lb-ns"
ports = [55690, 55691]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ Hierarchy | Block | Description | Required
resolver | [resolver][] | Configures discovering the endpoints to export to. | yes
resolver > static | [static][] | Static list of endpoints to export to. | no
resolver > dns | [dns][] | DNS-sourced list of endpoints to export to. | no
resolver > k8s | [k8s][] | Kubernetes-sourced list of endpoints to export to. | no
resolver > kubernetes | [kubernetes][] | Kubernetes-sourced list of endpoints to export to. | no
protocol | [protocol][] | Protocol settings. Only OTLP is supported at the moment. | no
protocol > otlp | [otlp][] | Configures an OTLP exporter. | no
protocol > otlp > client | [client][] | Configures the exporter gRPC client. | no
Expand All @@ -97,7 +97,7 @@ refers to a `static` block defined inside a `resolver` block.
[resolver]: #resolver-block
[static]: #static-block
[dns]: #dns-block
[k8s]: #k8s-block
[kubernetes]: #kubernetes-block
[protocol]: #protocol-block
[otlp]: #otlp-block
[client]: #client-block
Expand Down Expand Up @@ -139,9 +139,9 @@ Name | Type | Description | Default | Required
`timeout` | `duration` | Resolver timeout. | `"1s"` | no
`port` | `string` | Port to be used with the IP addresses resolved from the DNS hostname. | `"4317"` | no

### k8s block
### kubernetes block

You can use the `k8s` block to load balance across the pods of a Kubernetes service. The Agent will be notified
You can use the `kubernetes` block to load balance across the pods of a Kubernetes service. The Agent will be notified
by the Kubernetes API whenever a new pod is added or removed from the service.

The following arguments are supported:
Expand Down
2 changes: 1 addition & 1 deletion docs/sources/static/configuration/traces-config.md
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ load_balancing:
[ interval: <duration> | default = 5s ]
# Resolver timeout
[ timeout: <duration> | default = 1s ]
k8s:
kubernetes:
service: <string>
[ ports: <int array> | default = 4317 ]

Expand Down
10 changes: 6 additions & 4 deletions pkg/traces/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ const (
// defaultLoadBalancingPort is the default port the agent uses for internal load balancing
defaultLoadBalancingPort = "4318"
// agent's load balancing options
dnsTagName = "dns"
staticTagName = "static"
k8sTagName = "k8s"
dnsTagName = "dns"
staticTagName = "static"
kubernetesTagName = "kubernetes"

// sampling policies
alwaysSamplePolicy = "always_sample"
Expand Down Expand Up @@ -586,8 +586,10 @@ func resolver(config map[string]interface{}) (map[string]interface{}, error) {
resolverCfg := make(map[string]interface{})
for typ, cfg := range config {
switch typ {
case dnsTagName, staticTagName, k8sTagName:
case dnsTagName, staticTagName:
resolverCfg[typ] = cfg
case kubernetesTagName:
resolverCfg[typ] = "k8s"
default:
return nil, fmt.Errorf("unsupported resolver config type: %s", typ)
}
Expand Down

0 comments on commit fd9a1ed

Please sign in to comment.