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

fix(analysis): Adding field in YAML to provide region for Sigv4 signing. #2794

Merged
merged 13 commits into from
Jun 13, 2023
7 changes: 6 additions & 1 deletion docs/analysis/prometheus.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ See the [Analysis Overview page](../../features/analysis) for more details on th

## Utilizing Amazon Managed Prometheus

Amazon Managed Prometheus can be used as the prometheus data source for analysis. In order to do this the namespace where you analysis is running will have to have the appropriate [IRSA attached](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-onboard-ingest-metrics-new-Prometheus.html#AMP-onboard-new-Prometheus-IRSA) to allow for prometheus queries. Once you ensure the proper permissions are in place to access AMP, you can use an AMP workspace url in your ```provider``` block:
Amazon Managed Prometheus can be used as the prometheus data source for analysis. In order to do this the namespace where your analysis is running will have to have the appropriate [IRSA attached](https://docs.aws.amazon.com/prometheus/latest/userguide/AMP-onboard-ingest-metrics-new-Prometheus.html#AMP-onboard-new-Prometheus-IRSA) to allow for prometheus queries. Once you ensure the proper permissions are in place to access AMP, you can use an AMP workspace url in your ```provider``` block and add a SigV4 config for Sigv4 signing:

```yaml
provider:
Expand All @@ -49,6 +49,11 @@ provider:
sum(irate(
istio_requests_total{reporter="source",destination_service=~"{{args.service-name}}"}[5m]
))
authentication:
sigv4:
region: $REGION
profile: $PROFILE
roleArn: $ROLEARN
```

# Additional Metadata
Expand Down
57 changes: 57 additions & 0 deletions docs/features/kustomize/rollout_cr_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4259,6 +4259,25 @@
"address": {
"type": "string"
},
"authentication": {
"properties": {
"sigv4": {
"properties": {
"profile": {
"type": "string"
},
"region": {
"type": "string"
},
"roleArn": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"query": {
"type": "string"
}
Expand Down Expand Up @@ -8630,6 +8649,25 @@
"address": {
"type": "string"
},
"authentication": {
"properties": {
"sigv4": {
"properties": {
"profile": {
"type": "string"
},
"region": {
"type": "string"
},
"roleArn": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"query": {
"type": "string"
}
Expand Down Expand Up @@ -13001,6 +13039,25 @@
"address": {
"type": "string"
},
"authentication": {
"properties": {
"sigv4": {
"properties": {
"profile": {
"type": "string"
},
"region": {
"type": "string"
},
"roleArn": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
},
"query": {
"type": "string"
}
Expand Down
12 changes: 12 additions & 0 deletions manifests/crds/analysis-run-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2765,6 +2765,18 @@ spec:
properties:
address:
type: string
authentication:
properties:
sigv4:
properties:
profile:
type: string
region:
type: string
roleArn:
type: string
type: object
type: object
query:
type: string
type: object
Expand Down
12 changes: 12 additions & 0 deletions manifests/crds/analysis-template-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2761,6 +2761,18 @@ spec:
properties:
address:
type: string
authentication:
properties:
sigv4:
properties:
profile:
type: string
region:
type: string
roleArn:
type: string
type: object
type: object
query:
type: string
type: object
Expand Down
12 changes: 12 additions & 0 deletions manifests/crds/cluster-analysis-template-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2761,6 +2761,18 @@ spec:
properties:
address:
type: string
authentication:
properties:
sigv4:
properties:
profile:
type: string
region:
type: string
roleArn:
type: string
type: object
type: object
query:
type: string
type: object
Expand Down
36 changes: 36 additions & 0 deletions manifests/install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2766,6 +2766,18 @@ spec:
properties:
address:
type: string
authentication:
properties:
sigv4:
properties:
profile:
type: string
region:
type: string
roleArn:
type: string
type: object
type: object
query:
type: string
type: object
Expand Down Expand Up @@ -5713,6 +5725,18 @@ spec:
properties:
address:
type: string
authentication:
properties:
sigv4:
properties:
profile:
type: string
region:
type: string
roleArn:
type: string
type: object
type: object
query:
type: string
type: object
Expand Down Expand Up @@ -8546,6 +8570,18 @@ spec:
properties:
address:
type: string
authentication:
properties:
sigv4:
properties:
profile:
type: string
region:
type: string
roleArn:
type: string
type: object
type: object
query:
type: string
type: object
Expand Down
6 changes: 5 additions & 1 deletion metricproviders/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,11 @@ func NewPrometheusAPI(metric v1alpha1.Metric) (v1.API, error) {
}
//Check if using Amazon Managed Prometheus if true build sigv4 client
if strings.Contains(metric.Provider.Prometheus.Address, "aps-workspaces") {
var cfg sigv4.SigV4Config
cfg := sigv4.SigV4Config{
Region: metric.Provider.Prometheus.Authentication.Sigv4.Region,
Profile: metric.Provider.Prometheus.Authentication.Sigv4.Profile,
RoleARN: metric.Provider.Prometheus.Authentication.Sigv4.RoleARN,
}
var next http.RoundTripper
sigv4RoundTripper, err := sigv4.NewSigV4RoundTripper(&cfg, next)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/api-rules/violation_exceptions.list
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ API rule violation: list_type_missing,github.com/argoproj/argo-rollouts/pkg/apis
API rule violation: list_type_missing,github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1,WebMetric,Headers
API rule violation: names_match,github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1,MetricProvider,SkyWalking
API rule violation: names_match,github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1,RolloutStatus,HPAReplicas
API rule violation: names_match,github.com/argoproj/argo-rollouts/pkg/apis/rollouts/v1alpha1,Sigv4Config,RoleARN
18 changes: 18 additions & 0 deletions pkg/apis/rollouts/v1alpha1/analysis_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,24 @@ type PrometheusMetric struct {
Address string `json:"address,omitempty" protobuf:"bytes,1,opt,name=address"`
// Query is a raw prometheus query to perform
Query string `json:"query,omitempty" protobuf:"bytes,2,opt,name=query"`
// Sigv4 Config is the aws SigV4 configuration to use for SigV4 signing if using Amazon Managed Prometheus
// +optional
Authentication PrometheusAuth `json:"authentication,omitempty" protobuf:"bytes,3,opt,name=authentication"`
}

// PrometheusMetric defines the prometheus query to perform canary analysis
type PrometheusAuth struct {
// +optional
Sigv4 Sigv4Config `json:"sigv4,omitempty" protobuf:"bytes,3,opt,name=sigv4"`
}

type Sigv4Config struct {
// Region is the AWS Region to sign the SigV4 Request
Region string `json:"region,omitempty" protobuf:"bytes,1,opt,name=address"`
// Profile is the Credential Profile used to sign the SigV4 Request
Profile string `json:"profile,omitempty" protobuf:"bytes,2,opt,name=profile"`
// RoleARN is the IAM role used to sign the SIgV4 Request
RoleARN string `json:"roleArn,omitempty" protobuf:"bytes,3,opt,name=roleArn"`
}

// WavefrontMetric defines the wavefront query to perform canary analysis
Expand Down
Loading