Skip to content

Commit

Permalink
Merge pull request #85 from kube-logging/secret-auth
Browse files Browse the repository at this point in the history
feat: add possibility to inject auth info from secrets
  • Loading branch information
kristofgyuracz authored Oct 11, 2024
2 parents 371a744 + 7699430 commit e687718
Show file tree
Hide file tree
Showing 17 changed files with 826 additions and 185 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ help: ## Display this help.
.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./api/..." output:crd:artifacts:config=config/crd/bases
$(CONTROLLER_GEN) rbac:roleName=manager-role paths="./internal/controller/telemetry/..." output:rbac:artifacts:config=./config/rbac
cp config/crd/bases/* charts/telemetry-controller/crds/

.PHONY: generate
Expand Down
9 changes: 7 additions & 2 deletions api/telemetry/v1alpha1/otlp_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ type GRPCClientConfig struct {
Authority string `json:"authority,omitempty" yaml:"authority,omitempty"`

// Auth configuration for outgoing RPCs.
Auth string `json:"auth,omitempty" yaml:"auth,omitempty"` //TODO this is a reference *configauth.Authentication
Auth *Authentication `json:"auth,omitempty" yaml:"auth,omitempty"`
}

// TLSClientSetting contains TLS configurations that are specific to client
Expand Down Expand Up @@ -174,6 +174,11 @@ type TLSSetting struct {
ReloadInterval time.Duration `json:"reload_interval,omitempty" yaml:"reload_interval,omitempty"`
}

type Authentication struct {
// AuthenticatorID specifies the name of the extension to use in order to authenticate the incoming data point.
AuthenticatorID string `json:"authenticator,omitempty"`
}

// ClientConfig defines settings for creating an HTTP client.
type HTTPClientConfig struct {
// The target URL to send data to (e.g.: http://some.url:9411/v1/traces).
Expand All @@ -200,7 +205,7 @@ type HTTPClientConfig struct {
Headers map[string]configopaque.String `json:"headers,omitempty" yaml:"headers,omitempty"`

// Auth configuration for outgoing HTTP calls.
Auth string `json:"auth,omitempty" yaml:"auth,omitempty"` //TODO this is a reference *configauth.Authentication
Auth Authentication `json:"auth,omitempty" yaml:"auth,omitempty"`

// The compression key for supported compression types within collector.
Compression configcompression.Type `json:"compression,omitempty" yaml:"compression,omitempty"`
Expand Down
25 changes: 22 additions & 3 deletions api/telemetry/v1alpha1/output_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ package v1alpha1
import (
"time"

corev1 "k8s.io/api/core/v1"

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -28,9 +30,26 @@ type OutputSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

OTLPGRPC *OTLPGRPC `json:"otlp,omitempty"`
Fluentforward *Fluentforward `json:"fluentforward,omitempty"`
OTLPHTTP *OTLPHTTP `json:"otlphttp,omitempty"`
OTLPGRPC *OTLPGRPC `json:"otlp,omitempty"`
Fluentforward *Fluentforward `json:"fluentforward,omitempty"`
OTLPHTTP *OTLPHTTP `json:"otlphttp,omitempty"`
Authentication *OutputAuth `json:"authentication,omitempty"`
}

type OutputAuth struct {
BasicAuth *BasicAuthConfig `json:"basicauth,omitempty"`
BearerAuth *BearerAuthConfig `json:"bearerauth,omitempty"`
}

type BasicAuthConfig struct {
SecretRef *corev1.SecretReference `json:"secretRef,omitempty"`
UsernameField string `json:"usernameField,omitempty"`
PasswordField string `json:"passwordField,omitempty"`
}

type BearerAuthConfig struct {
SecretRef *corev1.SecretReference `json:"secretRef,omitempty"`
TokenField string `json:"tokenField,omitempty"`
}

// OTLP grpc exporter config ref: https://github.com/open-telemetry/opentelemetry-collector/blob/main/exporter/otlpexporter/config.go
Expand Down
98 changes: 95 additions & 3 deletions api/telemetry/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,51 @@ spec:
spec:
description: OutputSpec defines the desired state of Output
properties:
authentication:
properties:
basicauth:
properties:
passwordField:
type: string
secretRef:
description: |-
SecretReference represents a Secret Reference. It has enough information to retrieve secret
in any namespace
properties:
name:
description: name is unique within a namespace to reference
a secret resource.
type: string
namespace:
description: namespace defines the space within which
the secret name must be unique.
type: string
type: object
x-kubernetes-map-type: atomic
usernameField:
type: string
type: object
bearerauth:
properties:
secretRef:
description: |-
SecretReference represents a Secret Reference. It has enough information to retrieve secret
in any namespace
properties:
name:
description: name is unique within a namespace to reference
a secret resource.
type: string
namespace:
description: namespace defines the space within which
the secret name must be unique.
type: string
type: object
x-kubernetes-map-type: atomic
tokenField:
type: string
type: object
type: object
fluentforward:
properties:
compress_gzip:
Expand Down Expand Up @@ -207,7 +252,12 @@ spec:
properties:
auth:
description: Auth configuration for outgoing RPCs.
type: string
properties:
authenticator:
description: AuthenticatorID specifies the name of the extension
to use in order to authenticate the incoming data point.
type: string
type: object
authority:
description: |-
WithAuthority parameter configures client to rewrite ":authority" header
Expand Down Expand Up @@ -405,7 +455,12 @@ spec:
properties:
auth:
description: Auth configuration for outgoing HTTP calls.
type: string
properties:
authenticator:
description: AuthenticatorID specifies the name of the extension
to use in order to authenticate the incoming data point.
type: string
type: object
compression:
description: The compression key for supported compression types
within collector.
Expand Down
1 change: 1 addition & 0 deletions charts/telemetry-controller/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ rules:
- namespaces
- nodes
- nodes/proxy
- secrets
verbs:
- get
- list
Expand Down
Loading

0 comments on commit e687718

Please sign in to comment.