diff options
author | Rémy Coutable <remy@rymai.me> | 2018-05-23 16:15:26 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-05-23 16:15:26 +0000 |
commit | 63379a2ae7f04f533780ee53c04a0d2847c600aa (patch) | |
tree | 60089ab48bdc34b884909039660e42061322ddeb | |
parent | 31413f4c1469ebffe00cc657c3f94a59b48ace07 (diff) | |
parent | 7a73cff72edccfe00eeb78657c338bd996e1c561 (diff) | |
download | gitlab-ce-63379a2ae7f04f533780ee53c04a0d2847c600aa.tar.gz |
Merge branch '46259-prometheus-integration-fails-on-kube-1-10' into 'master'
Resolve "Prometheus integration fails on k8s 1.10"
Closes #46259
See merge request gitlab-org/gitlab-ce!19082
-rw-r--r-- | config/initializers/kubeclient.rb | 16 | ||||
-rw-r--r-- | spec/models/clusters/applications/prometheus_spec.rb | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/config/initializers/kubeclient.rb b/config/initializers/kubeclient.rb new file mode 100644 index 00000000000..7f115268b37 --- /dev/null +++ b/config/initializers/kubeclient.rb @@ -0,0 +1,16 @@ +class Kubeclient::Client + # We need to monkey patch this method until + # https://github.com/abonas/kubeclient/pull/323 is merged + def proxy_url(kind, name, port, namespace = '') + discover unless @discovered + entity_name_plural = + if %w[services pods nodes].include?(kind.to_s) + kind.to_s + else + @entities[kind.to_s].resource_name + end + + ns_prefix = build_namespace_prefix(namespace) + rest_client["#{ns_prefix}#{entity_name_plural}/#{name}:#{port}/proxy"].url + end +end diff --git a/spec/models/clusters/applications/prometheus_spec.rb b/spec/models/clusters/applications/prometheus_spec.rb index 407e2fc598a..d2302583ac8 100644 --- a/spec/models/clusters/applications/prometheus_spec.rb +++ b/spec/models/clusters/applications/prometheus_spec.rb @@ -79,7 +79,7 @@ describe Clusters::Applications::Prometheus do end it 'creates proper url' do - expect(subject.prometheus_client.url).to eq('http://example.com/api/v1/proxy/namespaces/gitlab-managed-apps/service/prometheus-prometheus-server:80') + expect(subject.prometheus_client.url).to eq('http://example.com/api/v1/namespaces/gitlab-managed-apps/service/prometheus-prometheus-server:80/proxy') end it 'copies options and headers from kube client to proxy client' do |