Skip to content

Commit

Permalink
Use (internal) master ip in all prometheus templates.
Browse files Browse the repository at this point in the history
Currently we use it only for kubemark, but we will need it also to
monitor master's kubemark in non-kubemark cluster.

Ref. kubernetes#503
  • Loading branch information
mm4tt committed Apr 23, 2019
1 parent 3ef6f3c commit 705b55c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ metadata:
k8s-app: kube-apiserver
subsets:
- addresses:
- ip: {{.KubemarkMasterIp}}
- ip: {{.MasterIp}}
ports:
- name: https
port: 443
17 changes: 8 additions & 9 deletions clusterloader2/pkg/prometheus/prometheus.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ package prometheus

import (
"encoding/json"
"fmt"
"time"

rbacv1 "k8s.io/api/rbac/v1"
Expand Down Expand Up @@ -69,8 +70,9 @@ func NewPrometheusController(clusterLoaderConfig *config.ClusterLoaderConfig) (p
if errList != nil {
return nil, errList
}
if pc.isKubemark {
mapping["KubemarkMasterIp"] = getKubemarkMasterIp(clusterLoaderConfig.ClusterConfig)
mapping["MasterIp"], err = getMasterIp(clusterLoaderConfig.ClusterConfig)
if err != nil {
return nil, err
}
pc.templateMapping = mapping

Expand Down Expand Up @@ -214,13 +216,10 @@ func dumpAdditionalLogsOnPrometheusSetupFailure(k8sClient kubernetes.Interface)
klog.Info(string(s))
}

func getKubemarkMasterIp(clusterConfig config.ClusterConfig) string {
func getMasterIp(clusterConfig config.ClusterConfig) (string, error) {
if clusterConfig.MasterInternalIP != "" {
klog.Infof("Using internal master ip (%s) to monitor kubemark master", clusterConfig.MasterInternalIP)
return clusterConfig.MasterInternalIP
klog.Infof("Using internal master ip (%s) to monitor master's components", clusterConfig.MasterInternalIP)
return clusterConfig.MasterInternalIP, nil
}
// TODO(https://github.com/kubernetes/perf-tests/issues/503): Eventually we should fail if we reach here.
klog.Warningf("Internal master ip not available! Using the public ip (%s) to monitor kubemark master. "+
"Prometheus stack may fail if proper firewall rules are not configured.", clusterConfig.MasterIP)
return clusterConfig.MasterIP
return "", fmt.Errorf("internal master ip not available")
}

0 comments on commit 705b55c

Please sign in to comment.