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

NETOBSERV-764 followup monolith & distributed modes #454

Merged
merged 2 commits into from
Oct 19, 2023
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
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ bundle: bundle-prepare ## Generate final bundle files.
update-bundle: VERSION=$(BUNDLE_VERSION)
update-bundle: IMAGE_ORG=netobserv
update-bundle: bundle ## Prepare a clean bundle to be commited
cat ./config/crd/bases/flows.netobserv.io_flowcollectors.yaml | yq eval-all '(.spec.versions.[]|select(.name != "v1beta2").storage) = false,(.spec.versions.[]|select(.name == "v1beta2").storage) = true' > ./hack/cloned.flows.netobserv.io_flowcollectors.yaml

.PHONY: bundle-build
bundle-build: ## Build the bundle image.
Expand Down
7 changes: 6 additions & 1 deletion api/v1alpha1/flowcollector_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,12 @@ func (r *FlowCollector) ConvertTo(dstRaw conversion.Hub) error {
dst.Spec.Loki.Enable = restored.Spec.Loki.Enable
dst.Spec.Loki.Mode = restored.Spec.Loki.Mode
dst.Spec.Loki.Manual = restored.Spec.Loki.Manual
if restored.Spec.Loki.Distributed != nil {
dst.Spec.Loki.Distributed = restored.Spec.Loki.Distributed
}
if restored.Spec.Loki.Monolith != nil {
dst.Spec.Loki.Monolith = restored.Spec.Loki.Monolith
}
if restored.Spec.Loki.LokiStack != nil {
dst.Spec.Loki.LokiStack = restored.Spec.Loki.LokiStack
}
Expand All @@ -101,7 +107,6 @@ func (r *FlowCollector) ConvertTo(dstRaw conversion.Hub) error {
}

func isExporterIn(restoredExporter *v1beta2.FlowCollectorExporter, dstExporters []*v1beta2.FlowCollectorExporter) bool {

for _, dstExp := range dstExporters {
if reflect.DeepEqual(restoredExporter, dstExp) {
return true
Expand Down
2 changes: 2 additions & 0 deletions api/v1alpha1/zz_generated.conversion.go

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

8 changes: 8 additions & 0 deletions api/v1beta1/flowcollector_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ func (r *FlowCollector) ConvertTo(dstRaw conversion.Hub) error {
// Loki
dst.Spec.Loki.Mode = restored.Spec.Loki.Mode
dst.Spec.Loki.Manual = restored.Spec.Loki.Manual
if restored.Spec.Loki.Distributed != nil {
dst.Spec.Loki.Distributed = restored.Spec.Loki.Distributed
}
if restored.Spec.Loki.Monolith != nil {
dst.Spec.Loki.Monolith = restored.Spec.Loki.Monolith
}
if restored.Spec.Loki.LokiStack != nil {
dst.Spec.Loki.LokiStack = restored.Spec.Loki.LokiStack
}
Expand All @@ -84,6 +90,8 @@ func (r *FlowCollector) ConvertFrom(srcRaw conversion.Hub) error {
switch src.Spec.Loki.Mode {
case v1beta2.LokiModeManual:
r.Spec.Loki.AuthToken = src.Spec.Loki.Manual.AuthToken
case v1beta2.LokiModeDistributed, v1beta2.LokiModeMonolith:
r.Spec.Loki.AuthToken = ""
case v1beta2.LokiModeLokiStack:
r.Spec.Loki.AuthToken = v1beta2.LokiAuthForwardUserToken
}
Expand Down
2 changes: 2 additions & 0 deletions api/v1beta1/zz_generated.conversion.go

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

54 changes: 47 additions & 7 deletions api/v1beta2/flowcollector_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ const (
// `LokiManualParams` defines the full connection parameters to Loki.
type LokiManualParams struct {
//+kubebuilder:default:="http://loki:3100/"
// `ingesterUrl` is the address of an existing Loki service to push the flows to. When using the Loki Operator,
// `ingesterUrl` is the address of an existing Loki ingester service to push the flows to. When using the Loki Operator,
// set it to the Loki gateway service with the `network` tenant set in path, for example
// https://loki-gateway-http.netobserv.svc:8080/api/logs/v1/network.
IngesterURL string `json:"ingesterUrl,omitempty"`
Expand Down Expand Up @@ -562,7 +562,35 @@ type LokiManualParams struct {
StatusTLS ClientTLS `json:"statusTls"`
}

// `LokiStack` defines the name and namespace of the `LokiStack` instance when using the Loki Operator.
// LokiDistributedParams defines the parameters to connect loki for microservices mode
type LokiDistributedParams struct {
//+kubebuilder:default:="http://loki:3100/"
// `ingesterUrl` is the address of an existing Loki ingester service to push the flows to.
IngesterURL string `json:"ingesterUrl,omitempty"`

//+kubebuilder:validation:optional
// `querierURL` specifies the address of the Loki querier service, in case it is different from the
// Loki ingester URL. If empty, the URL value is used (assuming that the Loki ingester
// and querier are in the same server).
QuerierURL string `json:"querierUrl,omitempty"`

// TLS client configuration for Loki URL.
// +optional
TLS ClientTLS `json:"tls"`
}

// LokiMonolithParams defines the parameters to connect loki for monolithic mode
type LokiMonolithParams struct {
//+kubebuilder:default:="http://loki:3100/"
// `url` is the unique address of an existing Loki service that point both ingester and querier.
URL string `json:"url,omitempty"`

// TLS client configuration for Loki URL.
// +optional
TLS ClientTLS `json:"tls"`
}

// LokiStack defines the name and namespace of the loki-operator instance
type LokiStack struct {
//+kubebuilder:default:="loki"
Name string `json:"name,omitempty"`
Expand All @@ -571,13 +599,15 @@ type LokiStack struct {
}

const (
LokiModeManual = "MANUAL"
LokiModeLokiStack = "LOKISTACK"
LokiModeManual = "MANUAL"
LokiModeDistributed = "DISTRIBUTED"
LokiModeMonolith = "MONOLITH"
LokiModeLokiStack = "LOKISTACK"
)

// `FlowCollectorLoki` defines the desired state for FlowCollector's Loki client.
type FlowCollectorLoki struct {
//+kubebuilder:validation:Enum=MANUAL;LOKISTACK
//+kubebuilder:validation:Enum=MANUAL;DISTRIBUTED;MONOLITH;LOKISTACK;
//+kubebuilder:default:="MANUAL"
Mode string `json:"mode,omitempty"`

Expand All @@ -586,8 +616,18 @@ type FlowCollectorLoki struct {
// +optional
Manual LokiManualParams `json:"manual,omitempty"`

// Loki configuration for LOKISTACK mode. This is useful for an easy loki-operator config.
// It will be ignored for other modes.
// Loki configuration for DISTRIBUTED mode. This is usefull for an easy microservices loki config.
// It will be ignored for other mods
// +optional
Distributed *LokiDistributedParams `json:"distributed,omitempty"`

// Loki configuration for MONOLITH mode. This is usefull for an easy monolithic loki config.
// It will be ignored for other mods
// +optional
Monolith *LokiMonolithParams `json:"monolith,omitempty"`

// Loki configuration for LOKISTACK mode. This is usefull for an easy loki-operator config.
// It will be ignored for other mods
// +optional
LokiStack *LokiStack `json:"lokiStack,omitempty"`

Expand Down
42 changes: 42 additions & 0 deletions api/v1beta2/zz_generated.deepcopy.go

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

Loading
Loading