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

feat: Add mutating webhook and defaulter for all signal types #1613

Merged
Merged
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
003b3fc
MetricPipeline defaulting webhook, initial commit
hisarbalik Nov 18, 2024
30fdbcc
update go modules
hisarbalik Nov 18, 2024
185a021
Merge branch 'main' into add-metricpipeline-defaulting-webhook
hisarbalik Nov 18, 2024
c96eef3
update webhook cert tests
hisarbalik Nov 18, 2024
a90a58a
Merge branch 'add-metricpipeline-defaulting-webhook' of github.com:hi…
hisarbalik Nov 18, 2024
929ed26
fix failing tests
hisarbalik Nov 18, 2024
75646d8
fix failing tests
hisarbalik Nov 18, 2024
515ada0
fix failing wbhook patch call
hisarbalik Nov 19, 2024
cd3b352
fix failing unit tests
hisarbalik Nov 19, 2024
87f2685
fix linter issues
hisarbalik Nov 19, 2024
92d6f62
Merge branch 'main' into add-metricpipeline-defaulting-webhook
hisarbalik Nov 19, 2024
64c43c6
add mutating webhook and defaulter for trace pipeline
hisarbalik Nov 19, 2024
5b2e167
fix patch cabundle for mutating webhook
hisarbalik Nov 19, 2024
8ffd236
change from patch to update webhook config
hisarbalik Nov 19, 2024
d48907d
fix failing dev e2e tests
hisarbalik Nov 19, 2024
8dd40b8
add log pipeline mutating webhook
hisarbalik Nov 19, 2024
995c815
update manifests
hisarbalik Nov 19, 2024
663e22a
fix linter issues
hisarbalik Nov 19, 2024
3790af2
add more unit tests
hisarbalik Nov 19, 2024
92bd4c8
switch mutating webhook impelmentation to kubebuilder reference imple…
hisarbalik Nov 20, 2024
48135c5
update mutating webhook endpoint path
hisarbalik Nov 20, 2024
0aa61be
Merge branch 'main' into add-metricpipeline-defaulting-webhook
hisarbalik Nov 20, 2024
eda1fcc
add logpipeline mutating webhook
hisarbalik Nov 20, 2024
3a27b87
fix linter issues
hisarbalik Nov 20, 2024
61180f8
update go modules
hisarbalik Nov 20, 2024
9193539
update test coverage threshold for package webhook/tracepipeline
hisarbalik Nov 20, 2024
0a22701
add v1beta1 defaulter webhooks
hisarbalik Nov 20, 2024
0b62fb1
update test coverage setting for mutating webhook unit tests
hisarbalik Nov 20, 2024
099fcad
Merge branch 'main' into add-metricpipeline-defaulting-webhook
hisarbalik Nov 20, 2024
ec36c73
add dev webhook resources
hisarbalik Nov 20, 2024
575fc8c
fix linter issues
hisarbalik Nov 20, 2024
2a16969
Merge branch 'main' into add-metricpipeline-defaulting-webhook
hisarbalik Nov 21, 2024
a3d7ff5
Merge branch 'main' into add-metricpipeline-defaulting-webhook
hisarbalik Nov 21, 2024
26453f4
add more tests
hisarbalik Nov 21, 2024
4b2a6cc
Merge branch 'main' into add-metricpipeline-defaulting-webhook
hisarbalik Nov 21, 2024
516dff4
move logparser and logpipeline validation wekhooks to the new version…
hisarbalik Nov 21, 2024
298cfe7
Merge branch 'add-metricpipeline-defaulting-webhook' of github.com:hi…
hisarbalik Nov 21, 2024
cf9d354
apply code review changes
hisarbalik Nov 22, 2024
bcb2cf1
Merge branch 'main' into add-metricpipeline-defaulting-webhook
hisarbalik Nov 22, 2024
3fad305
Merge branch 'main' into add-metricpipeline-defaulting-webhook
hisarbalik Nov 22, 2024
2b5033d
Merge branch 'main' into add-metricpipeline-defaulting-webhook
hisarbalik Nov 22, 2024
537cfb9
refactor dev version of kustomization
hisarbalik Nov 22, 2024
54f76b0
Update internal/webhookcert/resources.go
hisarbalik Nov 22, 2024
5026114
apply code review change requests
hisarbalik Nov 22, 2024
ccd7fd1
Merge branch 'add-metricpipeline-defaulting-webhook' of github.com:hi…
hisarbalik Nov 22, 2024
0302197
update test coverage thresholds
hisarbalik Nov 22, 2024
4e7a4be
rename webhook config names to b consistent with other webhoks config…
hisarbalik Nov 22, 2024
f2034c2
review requests added
hisarbalik Nov 22, 2024
11b269e
add more test webhook config for test update caBundle
hisarbalik Nov 22, 2024
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
18 changes: 14 additions & 4 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,20 @@ linters-settings:
alias: kitk8s
- pkg: github.com/kyma-project/telemetry-manager/test/testkit/kyma
alias: kitkyma
- pkg: github.com/kyma-project/telemetry-manager/webhook/logparser
alias: logparserwebhook
- pkg: github.com/kyma-project/telemetry-manager/webhook/logpipeline
alias: logpipelinewebhook
- pkg: github.com/kyma-project/telemetry-manager/webhook/logparser/v1alpha1
alias: logparserwebhookv1alpha1
- pkg: github.com/kyma-project/telemetry-manager/webhook/logpipeline/v1alpha1
alias: logpipelinewebhookv1alpha1
- pkg: github.com/kyma-project/telemetry-manager/webhook/logpipeline/v1beta1
alias: logpipelinewebhookv1beta1
- pkg: github.com/kyma-project/telemetry-manager/webhook/metricpipeline/v1alpha1
alias: metricpipelinewebhookv1alpha1
- pkg: github.com/kyma-project/telemetry-manager/webhook/metricpipeline/v1beta1
alias: metricpipelinewebhookv1beta1
- pkg: github.com/kyma-project/telemetry-manager/webhook/tracepipeline/v1alpha1
alias: tracepipelinewebhookv1alpha1
- pkg: github.com/kyma-project/telemetry-manager/webhook/tracepipeline/v1beta1
alias: tracepipelinewebhookv1beta1
- pkg: github.com/kyma-project/telemetry-manager/internal/reconciler/logpipeline/fluentbit
alias: logpipelinefluentbit
- pkg: github.com/prometheus/client_golang/api/prometheus/v1
Expand Down
11 changes: 9 additions & 2 deletions .testcoverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,17 @@ override:
path: ^internal/resourcelock$
- threshold: 84
path: ^internal/webhookcert$
- threshold: 73
path: ^webhook/logpipeline$
- threshold: 87
path: ^webhook/logpipeline/v1alpha1$
- threshold: 84
path: ^webhook/logpipeline/v1beta1$
- threshold: 83
path: ^internal/utils/logpipeline$
- threshold: 75
path: ^webhook/tracepipeline/v1alpha1$
- threshold: 75
path: ^webhook/tracepipeline/v1beta1$


# Holds regexp rules which will exclude matched files or packages from coverage statistics
exclude:
Expand Down
2 changes: 0 additions & 2 deletions apis/telemetry/v1alpha1/logpipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ type LogPipelineInput struct {
type LogPipelineApplicationInput struct {
// If enabled, application logs are collected. The default is `true`.
// +optional
// +kubebuilder:default=true
Enabled *bool `json:"enabled,omitempty"`
// Describes whether application logs from specific Namespaces are selected. The options are mutually exclusive. System Namespaces are excluded by default from the collection.
Namespaces LogPipelineNamespaceSelector `json:"namespaces,omitempty"`
Expand All @@ -89,7 +88,6 @@ type LogPipelineApplicationInput struct {
DropLabels bool `json:"dropLabels,omitempty"`
// If the `log` attribute contains a JSON payload and it is successfully parsed, the `log` attribute will be retained if `KeepOriginalBody` is set to `true`. Otherwise, the log attribute will be removed from the log record. The default is `true`.
// +optional
// +kubebuilder:default=true
KeepOriginalBody *bool `json:"keepOriginalBody,omitempty"`
}

Expand Down
32 changes: 10 additions & 22 deletions apis/telemetry/v1alpha1/metricpipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ type MetricPipelinePrometheusInput struct {
Enabled bool `json:"enabled,omitempty"`
// Describes whether Prometheus metrics from specific namespaces are selected. System namespaces are disabled by default.
// +optional
// +kubebuilder:default={exclude: {kyma-system, kube-system, istio-system, compass-system}}
Namespaces *NamespaceSelector `json:"namespaces,omitempty"`
// Configures diagnostic metrics scraping
// +optional
Expand All @@ -98,55 +97,44 @@ type MetricPipelineRuntimeInput struct {
Enabled bool `json:"enabled,omitempty"`
// Describes whether runtime metrics from specific namespaces are selected. System namespaces are disabled by default.
// +optional
// +kubebuilder:default={exclude: {kyma-system, kube-system, istio-system, compass-system}}
Namespaces *NamespaceSelector `json:"namespaces,omitempty"`
// Describes the Kubernetes resources for which runtime metrics are scraped.
// +optional
// +kubebuilder:default={pod: {enabled: true}, container: {enabled: true}, node: {enabled: true}, volume: {enabled: true}, daemonset: {enabled: true}, deployment: {enabled: true}, statefulset: {enabled: true}, job: {enabled: true}}
Resources *MetricPipelineRuntimeInputResources `json:"resources,omitempty"`
}

// MetricPipelineRuntimeInputResources describes the Kubernetes resources for which runtime metrics are scraped.
type MetricPipelineRuntimeInputResources struct {
// Configures Pod runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
Pod *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"pod,omitempty"`
Pod *MetricPipelineRuntimeInputResource `json:"pod,omitempty"`
// Configures container runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
Container *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"container,omitempty"`
Container *MetricPipelineRuntimeInputResource `json:"container,omitempty"`
// Configures Node runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
Node *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"node,omitempty"`
Node *MetricPipelineRuntimeInputResource `json:"node,omitempty"`
// Configures Volume runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
Volume *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"volume,omitempty"`
Volume *MetricPipelineRuntimeInputResource `json:"volume,omitempty"`
// Configures DaemonSet runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
DaemonSet *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"daemonset,omitempty"`
DaemonSet *MetricPipelineRuntimeInputResource `json:"daemonset,omitempty"`
// Configures Deployment runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
Deployment *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"deployment,omitempty"`
Deployment *MetricPipelineRuntimeInputResource `json:"deployment,omitempty"`
// Configures StatefulSet runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
StatefulSet *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"statefulset,omitempty"`
StatefulSet *MetricPipelineRuntimeInputResource `json:"statefulset,omitempty"`
// Configures Job runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
Job *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"job,omitempty"`
Job *MetricPipelineRuntimeInputResource `json:"job,omitempty"`
}

// MetricPipelineRuntimeInputResourceEnabledByDefault defines if the scraping of runtime metrics is enabled for a specific resource. The scraping is enabled by default.
type MetricPipelineRuntimeInputResourceEnabledByDefault struct {
// MetricPipelineRuntimeInputResource defines if the scraping of runtime metrics is enabled for a specific resource. The scraping is enabled by default.
type MetricPipelineRuntimeInputResource struct {
// If enabled, the runtime metrics for the resource are scraped. The default is `true`.
// +optional
// +kubebuilder:default=true
Enabled *bool `json:"enabled,omitempty"`
}

Expand Down
1 change: 0 additions & 1 deletion apis/telemetry/v1alpha1/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const (
type OTLPOutput struct {
// Defines the OTLP protocol (http or grpc). Default is grpc.
// +kubebuilder:validation:MinLength=1
// +kubebuilder:default:=grpc
// +kubebuilder:validation:Enum=grpc;http
Protocol string `json:"protocol,omitempty"`
// Defines the host and port (<host>:<port>) of an OTLP endpoint.
Expand Down
24 changes: 12 additions & 12 deletions apis/telemetry/v1alpha1/zz_generated.deepcopy.go

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

2 changes: 0 additions & 2 deletions apis/telemetry/v1beta1/logpipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ type LogPipelineInput struct {
type LogPipelineRuntimeInput struct {
// If enabled, application logs are collected. The default is `true`.
// +optional
// +kubebuilder:default=true
Enabled *bool `json:"enabled,omitempty"`
// Describes whether application logs from specific Namespaces are selected. The options are mutually exclusive. System Namespaces are excluded by default from the collection.
Namespaces LogPipelineNamespaceSelector `json:"namespaces,omitempty"`
Expand All @@ -96,7 +95,6 @@ type LogPipelineRuntimeInput struct {
DropLabels bool `json:"dropLabels,omitempty"`
// If the `log` attribute contains a JSON payload and it is successfully parsed, the `log` attribute will be retained if `keepOriginalBody` is set to `true`. Otherwise, the log attribute will be removed from the log record. The default is `true`.
// +optional
// +kubebuilder:default=true
KeepOriginalBody *bool `json:"keepOriginalBody,omitempty"`
}

Expand Down
32 changes: 10 additions & 22 deletions apis/telemetry/v1beta1/metricpipeline_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ type MetricPipelinePrometheusInput struct {
Enabled bool `json:"enabled,omitempty"`
// Describes whether Prometheus metrics from specific namespaces are selected. System namespaces are disabled by default.
// +optional
// +kubebuilder:default={exclude: {kyma-system, kube-system, istio-system, compass-system}}
Namespaces *NamespaceSelector `json:"namespaces,omitempty"`
// Configures diagnostic metrics scraping
// +optional
Expand All @@ -98,55 +97,44 @@ type MetricPipelineRuntimeInput struct {
Enabled bool `json:"enabled,omitempty"`
// Describes whether runtime metrics from specific namespaces are selected. System namespaces are disabled by default.
// +optional
// +kubebuilder:default={exclude: {kyma-system, kube-system, istio-system, compass-system}}
Namespaces *NamespaceSelector `json:"namespaces,omitempty"`
// Describes the Kubernetes resources for which runtime metrics are scraped.
// +optional
// +kubebuilder:default={pod: {enabled: true}, container: {enabled: true}, node: {enabled: true}, volume: {enabled: true}, daemonset: {enabled: true}, deployment: {enabled: true}, statefulset: {enabled: true}, job: {enabled: true}}
Resources *MetricPipelineRuntimeInputResources `json:"resources,omitempty"`
}

// MetricPipelineRuntimeInputResources describes the Kubernetes resources for which runtime metrics are scraped.
type MetricPipelineRuntimeInputResources struct {
// Configures Pod runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
Pod *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"pod,omitempty"`
Pod *MetricPipelineRuntimeInputResource `json:"pod,omitempty"`
// Configures container runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
Container *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"container,omitempty"`
Container *MetricPipelineRuntimeInputResource `json:"container,omitempty"`
// Configures Node runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
Node *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"node,omitempty"`
Node *MetricPipelineRuntimeInputResource `json:"node,omitempty"`
// Configures Volume runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
Volume *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"volume,omitempty"`
Volume *MetricPipelineRuntimeInputResource `json:"volume,omitempty"`
// Configures DaemonSet runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
DaemonSet *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"daemonset,omitempty"`
DaemonSet *MetricPipelineRuntimeInputResource `json:"daemonset,omitempty"`
// Configures Deployment runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
Deployment *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"deployment,omitempty"`
Deployment *MetricPipelineRuntimeInputResource `json:"deployment,omitempty"`
// Configures StatefulSet runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
StatefulSet *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"statefulset,omitempty"`
StatefulSet *MetricPipelineRuntimeInputResource `json:"statefulset,omitempty"`
// Configures Job runtime metrics scraping.
// +optional
// +kubebuilder:default={enabled: true}
Job *MetricPipelineRuntimeInputResourceEnabledByDefault `json:"job,omitempty"`
Job *MetricPipelineRuntimeInputResource `json:"job,omitempty"`
}

// MetricPipelineRuntimeInputResourceEnabledByDefault defines if the scraping of runtime metrics is enabled for a specific resource. The scraping is enabled by default.
type MetricPipelineRuntimeInputResourceEnabledByDefault struct {
// MetricPipelineRuntimeInputResource defines if the scraping of runtime metrics is enabled for a specific resource. The scraping is enabled by default.
type MetricPipelineRuntimeInputResource struct {
// If enabled, the runtime metrics for the resource are scraped. The default is `true`.
// +optional
// +kubebuilder:default=true
Enabled *bool `json:"enabled,omitempty"`
}

Expand Down
1 change: 0 additions & 1 deletion apis/telemetry/v1beta1/shared_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ const (
// +kubebuilder:validation:XValidation:rule="((!has(self.path) || size(self.path) <= 0) && (has(self.protocol) && self.protocol == 'grpc')) || (has(self.protocol) && self.protocol == 'http')", message="Path is only available with HTTP protocol"
type OTLPOutput struct {
// Defines the OTLP protocol (http or grpc). Default is grpc.
// +kubebuilder:default:=grpc
// +kubebuilder:validation:Enum=grpc;http
Protocol OTLPProtocol `json:"protocol,omitempty"`
// Defines the host and port (<host>:<port>) of an OTLP endpoint.
Expand Down
24 changes: 12 additions & 12 deletions apis/telemetry/v1beta1/zz_generated.deepcopy.go

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

Loading
Loading