-
Notifications
You must be signed in to change notification settings - Fork 26
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: Enable prometheus merge as a configuration in the Kyma Istio CR #1232
Open
jeffreylimnardy
wants to merge
25
commits into
kyma-project:main
Choose a base branch
from
jeffreylimnardy:prommerge-feature
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
25 commits
Select commit
Hold shift + click to select a range
cd7d91d
add prometheus merge api field
jeffreylimnardy 9d3e24a
restart proxy sidecars when enableprometheusmerge is changed
jeffreylimnardy 30ea336
enable prometheus merge to use new structure
jeffreylimnardy 2e5a838
update docs
jeffreylimnardy 8048210
Merge branch 'main' into prommerge-feature
jeffreylimnardy db06a2e
update api definition
jeffreylimnardy 485d735
update docs
jeffreylimnardy f427be5
Merge branch 'main' into prommerge-feature
jeffreylimnardy 163b80f
omit empty
jeffreylimnardy 7bd3093
Merge branch 'main' into prommerge-feature
jeffreylimnardy c125da6
add line about nested fields
jeffreylimnardy 2225c45
add RN
jeffreylimnardy ad1b0c3
Merge branch 'main' into prommerge-feature
jeffreylimnardy 70d218a
fix UT lastAppliedConfiguration
jeffreylimnardy 7e354bf
fix typo
jeffreylimnardy 04e387e
add small detail to docs
jeffreylimnardy fda3e63
update ADR status
jeffreylimnardy 953cdb3
Merge branch 'main' into prommerge-feature
jeffreylimnardy 8ed2097
account for refactor proxy reset
jeffreylimnardy d70a171
add missing error handling
jeffreylimnardy 8a3d6a6
move release-notes to 1.15.0
jeffreylimnardy 11981cd
Merge branch 'main' into prommerge-feature
jeffreylimnardy 1e48ff2
add newline
jeffreylimnardy 0f5fba6
Merge branch 'main' into prommerge-feature
jeffreylimnardy a5bb864
restart only when pod annotations are not right
jeffreylimnardy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package v1alpha2 | ||
|
||
type Telemetry struct { | ||
// Istio telemetry configuration related to metrics | ||
// +kubebuilder:validation:Optional | ||
Metrics Metrics `json:"metrics,omitempty"` | ||
} | ||
|
||
type Metrics struct { | ||
// Defines whether the prometheusMerge feature is enabled. If yes, appropriate prometheus.io annotations will be added to all data plane pods to set up scraping. | ||
// If these annotations already exist, they will be overwritten. With this option, the Envoy sidecar will merge Istio’s metrics with the application metrics. | ||
// The merged metrics will be scraped from :15020/stats/prometheus. | ||
// +kubebuilder:validation:Optional | ||
PrometheusMerge bool `json:"prometheusMerge,omitempty"` | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
docs/contributor/adr/0010-support-for-enable-prometheusMerge-configuration.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Support for Enable PrometheusMerge Configuration | ||
|
||
## Status | ||
Approved | ||
|
||
## Context | ||
There is a need to support the configuration of enabling `prometheusMerge` to be available in the Istio CR. The background behind this need is explained in [this issue](https://github.com/kyma-project/telemetry-manager/issues/1468) and the impact of this feature being enabled was discussed in an [ADR](https://github.com/kyma-project/telemetry-manager/blob/main/docs/contributor/arch/015-impact-of-istio-prometheus-merge-on-metric-pipelines.md) created in the Telemetry Manager repository. | ||
|
||
## Considerations | ||
Based on the [original ADR](https://github.com/kyma-project/telemetry-manager/blob/main/docs/contributor/arch/015-impact-of-istio-prometheus-merge-on-metric-pipelines.md), the plan was to originally enable the `prometheusMerge` feature by default. But this has caused problems for users deploying prometheus with a scrape loop sidecar. More details can be found in [this PR](https://github.com/kyma-project/istio/pull/1184). | ||
|
||
|
||
## Decision | ||
The enablement of the `prometheusMerge` feature needs to be a configurable option for the users. By default it will be set to `false`, but users will then need to actively set it to `true` and understand the effects of the feature. | ||
|
||
To allow for this configuration, the following API is proposed in the CR under the config option, `prometheusMerge` will have the default value of `false`. | ||
```yaml | ||
apiVersion: operator.kyma-project.io/v1alpha2 | ||
kind: Istio | ||
metadata: | ||
name: default | ||
namespace: kyma-system | ||
spec: | ||
config: | ||
telemetry: | ||
metrics: | ||
prometheusMerge: false | ||
``` | ||
|
||
The `telemetry` and `metrics` fields are introduced here to account for future plans to introduce more feature from the Istio Telemetry API into the CR. | ||
|
||
## Consequences | ||
Istio CustomResourceDefinition will be extended with an additional configuration field of `telemetry.metrics.prometheusMerge` that will allow for configuration of the `prometheusMerge` setting in Istio Mesh Config. The field will be an optional configuration with the default value of `false`. | ||
|
||
The `telemetry` and `metrics` field will show up in the CR when retrieved from the API server even if not explicitly defined in the manifest. | ||
|
||
### Sample configuration | ||
|
||
1. | ||
``` | ||
apiVersion: istio.operator.kyma-project.io/v1alpha2 | ||
kind: Istio | ||
metadata: | ||
name: default | ||
|
||
``` | ||
This will use the default value of `false` for the `prometheusMerge` option. | ||
|
||
2. | ||
``` | ||
apiVersion: istio.operator.kyma-project.io/v1alpha2 | ||
kind: Istio | ||
metadata: | ||
name: default | ||
spec: | ||
config: | ||
telemetry: | ||
metrics: | ||
prometheusMerge: true | ||
``` | ||
This will set the value of `prometheusMerge` to `true`. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
## New Features | ||
|
||
- Extended Istio custom resource with `prometheusMerge` configuration [#1232](https://github.com/kyma-project/istio/pull/1232) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package predicates | ||
|
||
import ( | ||
"github.com/kyma-project/istio/operator/api/v1alpha2" | ||
"github.com/kyma-project/istio/operator/internal/reconciliations/istio/configuration" | ||
v1 "k8s.io/api/core/v1" | ||
) | ||
|
||
type PrometheusMergeRestartPredicate struct { | ||
oldPrometheusMerge bool | ||
newPrometheusMerge bool | ||
} | ||
|
||
func NewPrometheusMergeRestartPredicate(istioCR *v1alpha2.Istio) (*PrometheusMergeRestartPredicate, error) { | ||
lastAppliedConfig, err := configuration.GetLastAppliedConfiguration(istioCR) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return &PrometheusMergeRestartPredicate{ | ||
oldPrometheusMerge: lastAppliedConfig.IstioSpec.Config.Telemetry.Metrics.PrometheusMerge, | ||
newPrometheusMerge: istioCR.Spec.Config.Telemetry.Metrics.PrometheusMerge, | ||
}, nil | ||
} | ||
|
||
func (p PrometheusMergeRestartPredicate) Matches(pod v1.Pod) bool { | ||
// No change in configuration, no restart needed | ||
if p.oldPrometheusMerge == p.newPrometheusMerge { | ||
return false | ||
} | ||
|
||
annotations := pod.GetAnnotations() | ||
const ( | ||
prometheusMergePath = "/stats/prometheus" | ||
prometheusMergePort = "15020" | ||
) | ||
|
||
hasPrometheusMergePath := annotations["prometheus.io/path"] == prometheusMergePath | ||
hasPrometheusMergePort := annotations["prometheus.io/port"] == prometheusMergePort | ||
|
||
// When enabling PrometheusMerge, restart if prometheusMerge annotations are missing or incorrect | ||
if p.newPrometheusMerge { | ||
return !hasPrometheusMergePath || !hasPrometheusMergePort | ||
} | ||
|
||
// When disabling PrometheusMerge, restart if prometheusMerge annotations are present and correct | ||
return hasPrometheusMergePath || hasPrometheusMergePort | ||
} | ||
|
||
func (p PrometheusMergeRestartPredicate) MustMatch() bool { | ||
return false | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this introduces unnecessary coupling to that particular port number, which is configurable in Istio: https://istio.io/latest/docs/reference/config/istio.mesh.v1alpha1/#ProxyConfig-status_port
So if this would change for whatever reason then it would cause a side effect here - proxies would be constantly restarted.
IMHO, it would be simpler to just check whether annotations are set or not. Unless we are able to get the real values which are set in Istio instead of hardcoding them.