Commit 1f912880 authored by Joshua Lambert's avatar Joshua Lambert Committed by Kamil Trzciński

Enable Prometheus metrics for deployed Ingresses

parent 1e66ff6d
...@@ -17,8 +17,12 @@ def chart ...@@ -17,8 +17,12 @@ def chart
'stable/nginx-ingress' 'stable/nginx-ingress'
end end
def chart_values_file
"#{Rails.root}/vendor/#{name}/values.yaml"
end
def install_command def install_command
Gitlab::Kubernetes::Helm::InstallCommand.new(name, chart: chart) Gitlab::Kubernetes::Helm::InstallCommand.new(name, chart: chart, chart_values_file: chart_values_file)
end end
end end
end end
......
---
title: Enable Prometheus metrics for deployed Ingresses
merge_request: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/16866
author: joshlambert
type: changed
...@@ -64,7 +64,7 @@ def volumes_specification ...@@ -64,7 +64,7 @@ def volumes_specification
{ {
name: 'configuration-volume', name: 'configuration-volume',
configMap: { configMap: {
name: 'values-content-configuration', name: "values-content-configuration-#{command.name}",
items: [{ key: 'values', path: 'values.yaml' }] items: [{ key: 'values', path: 'values.yaml' }]
} }
} }
...@@ -81,7 +81,11 @@ def generate_pod_env(command) ...@@ -81,7 +81,11 @@ def generate_pod_env(command)
def create_config_map def create_config_map
resource = ::Kubeclient::Resource.new resource = ::Kubeclient::Resource.new
resource.metadata = { name: 'values-content-configuration', namespace: namespace_name, labels: { name: 'values-content-configuration' } } resource.metadata = {
name: "values-content-configuration-#{command.name}",
namespace: namespace_name,
labels: { name: "values-content-configuration-#{command.name}" }
}
resource.data = { values: File.read(command.chart_values_file) } resource.data = { values: File.read(command.chart_values_file) }
kubeclient.create_config_map(resource) kubeclient.create_config_map(resource)
end end
......
...@@ -63,14 +63,14 @@ ...@@ -63,14 +63,14 @@
it 'should mount configMap specification in the volume' do it 'should mount configMap specification in the volume' do
spec = subject.generate.spec spec = subject.generate.spec
expect(spec.volumes.first.configMap['name']).to eq('values-content-configuration') expect(spec.volumes.first.configMap['name']).to eq("values-content-configuration-#{app.name}")
expect(spec.volumes.first.configMap['items'].first['key']).to eq('values') expect(spec.volumes.first.configMap['items'].first['key']).to eq('values')
expect(spec.volumes.first.configMap['items'].first['path']).to eq('values.yaml') expect(spec.volumes.first.configMap['items'].first['path']).to eq('values.yaml')
end end
end end
context 'without a configuration file' do context 'without a configuration file' do
let(:app) { create(:clusters_applications_ingress, cluster: cluster) } let(:app) { create(:clusters_applications_helm, cluster: cluster) }
it_behaves_like 'helm pod' it_behaves_like 'helm pod'
......
controller:
image:
tag: "0.10.2"
repository: "quay.io/kubernetes-ingress-controller/nginx-ingress-controller"
stats.enabled: true
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/port: "10254"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment