Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
da873584
Commit
da873584
authored
Dec 20, 2018
by
Chris Baumbauer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Knative metrics to Prometheus
parent
0e20c8eb
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
154 additions
and
3 deletions
+154
-3
app/models/clusters/applications/knative.rb
app/models/clusters/applications/knative.rb
+7
-2
app/models/clusters/applications/prometheus.rb
app/models/clusters/applications/prometheus.rb
+6
-1
app/models/clusters/cluster.rb
app/models/clusters/cluster.rb
+1
-0
changelogs/unreleased/knative-prometheus.yml
changelogs/unreleased/knative-prometheus.yml
+5
-0
spec/models/clusters/applications/knative_spec.rb
spec/models/clusters/applications/knative_spec.rb
+17
-0
spec/models/clusters/applications/prometheus_spec.rb
spec/models/clusters/applications/prometheus_spec.rb
+15
-0
spec/models/clusters/cluster_spec.rb
spec/models/clusters/cluster_spec.rb
+1
-0
vendor/prometheus/values.yaml
vendor/prometheus/values.yaml
+102
-0
No files found.
app/models/clusters/applications/knative.rb
View file @
da873584
...
...
@@ -5,7 +5,7 @@ module Clusters
class
Knative
<
ActiveRecord
::
Base
VERSION
=
'0.2.2'
.
freeze
REPOSITORY
=
'https://storage.googleapis.com/triggermesh-charts'
.
freeze
METRICS_CONFIG
=
'https://storage.googleapis.com/triggermesh-charts/istio-metrics.yaml'
.
freeze
FETCH_IP_ADDRESS_DELAY
=
30
.
seconds
self
.
table_name
=
'clusters_applications_knative'
...
...
@@ -49,7 +49,8 @@ module Clusters
rbac:
cluster
.
platform_kubernetes_rbac?
,
chart:
chart
,
files:
files
,
repository:
REPOSITORY
repository:
REPOSITORY
,
postinstall:
install_knative_metrics
)
end
...
...
@@ -94,6 +95,10 @@ module Clusters
rescue
Kubeclient
::
ResourceNotFoundError
[]
end
def
install_knative_metrics
[
"kubectl apply -f
#{
METRICS_CONFIG
}
"
]
if
cluster
.
application_prometheus_available?
end
end
end
end
app/models/clusters/applications/prometheus.rb
View file @
da873584
...
...
@@ -50,7 +50,8 @@ module Clusters
version:
VERSION
,
rbac:
cluster
.
platform_kubernetes_rbac?
,
chart:
chart
,
files:
files
files:
files
,
postinstall:
install_knative_metrics
)
end
...
...
@@ -74,6 +75,10 @@ module Clusters
def
kube_client
cluster
&
.
kubeclient
&
.
core_client
end
def
install_knative_metrics
[
"kubectl apply -f
#{
Clusters
::
Applications
::
Knative
::
METRICS_CONFIG
}
"
]
if
cluster
.
application_knative_available?
end
end
end
end
app/models/clusters/cluster.rb
View file @
da873584
...
...
@@ -63,6 +63,7 @@ module Clusters
delegate
:available?
,
to: :application_helm
,
prefix:
true
,
allow_nil:
true
delegate
:available?
,
to: :application_ingress
,
prefix:
true
,
allow_nil:
true
delegate
:available?
,
to: :application_prometheus
,
prefix:
true
,
allow_nil:
true
delegate
:available?
,
to: :application_knative
,
prefix:
true
,
allow_nil:
true
enum
cluster_type:
{
instance_type:
1
,
...
...
changelogs/unreleased/knative-prometheus.yml
0 → 100644
View file @
da873584
---
title
:
Add Knative metrics to Prometheus
merge_request
:
23972
author
:
Chris Baumbauer
type
:
added
spec/models/clusters/applications/knative_spec.rb
View file @
da873584
...
...
@@ -108,6 +108,23 @@ describe Clusters::Applications::Knative do
expect
(
subject
.
version
).
to
eq
(
'0.2.2'
)
expect
(
subject
.
files
).
to
eq
(
knative
.
files
)
end
it
'should not install metrics for prometheus'
do
expect
(
subject
.
postinstall
).
to
be_nil
end
context
'with prometheus installed'
do
let
(
:prometheus
)
{
create
(
:clusters_applications_prometheus
,
:installed
)
}
let
(
:knative
)
{
create
(
:clusters_applications_knative
,
cluster:
prometheus
.
cluster
)
}
subject
{
knative
.
install_command
}
it
'should install metrics'
do
expect
(
subject
.
postinstall
).
not_to
be_nil
expect
(
subject
.
postinstall
.
length
).
to
be
(
1
)
expect
(
subject
.
postinstall
[
0
]).
to
eql
(
"kubectl apply -f
#{
Clusters
::
Applications
::
Knative
::
METRICS_CONFIG
}
"
)
end
end
end
describe
'#files'
do
...
...
spec/models/clusters/applications/prometheus_spec.rb
View file @
da873584
...
...
@@ -165,6 +165,10 @@ describe Clusters::Applications::Prometheus do
expect
(
subject
.
files
).
to
eq
(
prometheus
.
files
)
end
it
'should not install knative metrics'
do
expect
(
subject
.
postinstall
).
to
be_nil
end
context
'on a rbac enabled cluster'
do
before
do
prometheus
.
cluster
.
platform_kubernetes
.
rbac!
...
...
@@ -180,6 +184,17 @@ describe Clusters::Applications::Prometheus do
expect
(
subject
.
version
).
to
eq
(
'6.7.3'
)
end
end
context
'with knative installed'
do
let
(
:knative
)
{
create
(
:clusters_applications_knative
,
:installed
)
}
let
(
:prometheus
)
{
create
(
:clusters_applications_prometheus
,
cluster:
knative
.
cluster
)
}
subject
{
prometheus
.
install_command
}
it
'should install metrics'
do
expect
(
subject
.
postinstall
).
to
include
(
"kubectl apply -f
#{
Clusters
::
Applications
::
Knative
::
METRICS_CONFIG
}
"
)
end
end
end
describe
'#files'
do
...
...
spec/models/clusters/cluster_spec.rb
View file @
da873584
...
...
@@ -29,6 +29,7 @@ describe Clusters::Cluster do
it
{
is_expected
.
to
delegate_method
(
:available?
).
to
(
:application_helm
).
with_prefix
}
it
{
is_expected
.
to
delegate_method
(
:available?
).
to
(
:application_ingress
).
with_prefix
}
it
{
is_expected
.
to
delegate_method
(
:available?
).
to
(
:application_prometheus
).
with_prefix
}
it
{
is_expected
.
to
delegate_method
(
:available?
).
to
(
:application_knative
).
with_prefix
}
it
{
is_expected
.
to
respond_to
:project
}
...
...
vendor/prometheus/values.yaml
View file @
da873584
...
...
@@ -141,3 +141,105 @@ serverFiles:
-
__meta_kubernetes_pod_name
action
:
replace
target_label
:
kubernetes_pod_name
# Sourced from Knative monitoring config: https://github.com/knative/serving/blob/master/config/monitoring/metrics/prometheus/100-prometheus-scrape-config.yaml
-
job_name
:
autoscaler
scrape_interval
:
3s
scrape_timeout
:
3s
kubernetes_sd_configs
:
-
role
:
pod
relabel_configs
:
# Scrape only the the targets matching the following metadata
-
source_labels
:
[
__meta_kubernetes_namespace
,
__meta_kubernetes_pod_label_app
,
__meta_kubernetes_pod_container_port_name
]
action
:
keep
regex
:
knative-serving;autoscaler;metrics
# Rename metadata labels to be reader friendly
-
source_labels
:
[
__meta_kubernetes_namespace
]
target_label
:
namespace
-
source_labels
:
[
__meta_kubernetes_pod_name
]
target_label
:
pod
-
source_labels
:
[
__meta_kubernetes_service_name
]
target_label
:
service
-
job_name
:
activator
scrape_interval
:
3s
scrape_timeout
:
3s
kubernetes_sd_configs
:
-
role
:
pod
relabel_configs
:
# Scrape only the the targets matching the following metadata
-
source_labels
:
[
__meta_kubernetes_namespace
,
__meta_kubernetes_pod_label_app
,
__meta_kubernetes_pod_container_port_name
]
action
:
keep
regex
:
knative-serving;activator;metrics-port
# Rename metadata labels to be reader friendly
-
source_labels
:
[
__meta_kubernetes_namespace
]
target_label
:
namespace
-
source_labels
:
[
__meta_kubernetes_pod_name
]
target_label
:
pod
-
source_labels
:
[
__meta_kubernetes_service_name
]
target_label
:
service
# Istio mesh
-
job_name
:
istio-mesh
scrape_interval
:
5s
kubernetes_sd_configs
:
-
role
:
endpoints
relabel_configs
:
# Scrape only the the targets matching the following metadata
-
source_labels
:
[
__meta_kubernetes_namespace
,
__meta_kubernetes_service_name
,
__meta_kubernetes_endpoint_port_name
]
action
:
keep
regex
:
istio-system;istio-telemetry;prometheus
# Rename metadata labels to be reader friendly
-
source_labels
:
[
__meta_kubernetes_namespace
]
target_label
:
namespace
-
source_labels
:
[
__meta_kubernetes_pod_name
]
target_label
:
pod
-
source_labels
:
[
__meta_kubernetes_service_name
]
target_label
:
service
-
job_name
:
istio-policy
scrape_interval
:
5s
kubernetes_sd_configs
:
-
role
:
endpoints
relabel_configs
:
# Scrape only the the targets matching the following metadata
-
source_labels
:
[
__meta_kubernetes_namespace
,
__meta_kubernetes_service_name
,
__meta_kubernetes_endpoint_port_name
]
action
:
keep
regex
:
istio-system;istio-policy;http-monitoring
# Rename metadata labels to be reader friendly
-
source_labels
:
[
__meta_kubernetes_namespace
]
target_label
:
namespace
-
source_labels
:
[
__meta_kubernetes_pod_name
]
target_label
:
pod
-
source_labels
:
[
__meta_kubernetes_service_name
]
target_label
:
service
# Istio telemetry
-
job_name
:
istio-telemetry
scrape_interval
:
5s
kubernetes_sd_configs
:
-
role
:
endpoints
relabel_configs
:
# Scrape only the the targets matching the following metadata
-
source_labels
:
[
__meta_kubernetes_namespace
,
__meta_kubernetes_service_name
,
__meta_kubernetes_endpoint_port_name
]
action
:
keep
regex
:
istio-system;istio-telemetry;http-monitoring
# Rename metadata labels to be reader friendly
-
source_labels
:
[
__meta_kubernetes_namespace
]
target_label
:
namespace
-
source_labels
:
[
__meta_kubernetes_pod_name
]
target_label
:
pod
-
source_labels
:
[
__meta_kubernetes_service_name
]
target_label
:
service
# Istio pilot
-
job_name
:
istio-pilot
scrape_interval
:
5s
kubernetes_sd_configs
:
-
role
:
endpoints
relabel_configs
:
# Scrape only the the targets matching the following metadata
-
source_labels
:
[
__meta_kubernetes_namespace
,
__meta_kubernetes_service_name
,
__meta_kubernetes_endpoint_port_name
]
action
:
keep
regex
:
istio-system;istio-pilot;http-monitoring
# Rename metadata labels to be reader friendly
-
source_labels
:
[
__meta_kubernetes_namespace
]
target_label
:
namespace
-
source_labels
:
[
__meta_kubernetes_pod_name
]
target_label
:
pod
-
source_labels
:
[
__meta_kubernetes_service_name
]
target_label
:
service
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment