Kubernetes SD: Remove kubeletPort config option
This commit is contained in:
		
							parent
							
								
									d48297c904
								
							
						
					
					
						commit
						206bcfcdaa
					
				|  | @ -129,7 +129,6 @@ var ( | ||||||
| 
 | 
 | ||||||
| 	// DefaultKubernetesSDConfig is the default Kubernetes SD configuration
 | 	// DefaultKubernetesSDConfig is the default Kubernetes SD configuration
 | ||||||
| 	DefaultKubernetesSDConfig = KubernetesSDConfig{ | 	DefaultKubernetesSDConfig = KubernetesSDConfig{ | ||||||
| 		KubeletPort:    10255, |  | ||||||
| 		RequestTimeout: model.Duration(10 * time.Second), | 		RequestTimeout: model.Duration(10 * time.Second), | ||||||
| 		RetryInterval:  model.Duration(1 * time.Second), | 		RetryInterval:  model.Duration(1 * time.Second), | ||||||
| 	} | 	} | ||||||
|  | @ -752,7 +751,6 @@ func (c *MarathonSDConfig) UnmarshalYAML(unmarshal func(interface{}) error) erro | ||||||
| // KubernetesSDConfig is the configuration for Kubernetes service discovery.
 | // KubernetesSDConfig is the configuration for Kubernetes service discovery.
 | ||||||
| type KubernetesSDConfig struct { | type KubernetesSDConfig struct { | ||||||
| 	APIServers      []URL          `yaml:"api_servers"` | 	APIServers      []URL          `yaml:"api_servers"` | ||||||
| 	KubeletPort     int            `yaml:"kubelet_port,omitempty"` |  | ||||||
| 	InCluster       bool           `yaml:"in_cluster,omitempty"` | 	InCluster       bool           `yaml:"in_cluster,omitempty"` | ||||||
| 	BasicAuth       *BasicAuth     `yaml:"basic_auth,omitempty"` | 	BasicAuth       *BasicAuth     `yaml:"basic_auth,omitempty"` | ||||||
| 	BearerToken     string         `yaml:"bearer_token,omitempty"` | 	BearerToken     string         `yaml:"bearer_token,omitempty"` | ||||||
|  |  | ||||||
|  | @ -227,7 +227,6 @@ var expectedConf = &Config{ | ||||||
| 						Username: "myusername", | 						Username: "myusername", | ||||||
| 						Password: "mypassword", | 						Password: "mypassword", | ||||||
| 					}, | 					}, | ||||||
| 					KubeletPort:    10255, |  | ||||||
| 					RequestTimeout: model.Duration(10 * time.Second), | 					RequestTimeout: model.Duration(10 * time.Second), | ||||||
| 					RetryInterval:  model.Duration(1 * time.Second), | 					RetryInterval:  model.Duration(1 * time.Second), | ||||||
| 				}, | 				}, | ||||||
|  |  | ||||||
|  | @ -26,7 +26,6 @@ import ( | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"sync" | 	"sync" | ||||||
| 	"time" | 	"time" | ||||||
| 	"unicode" |  | ||||||
| 
 | 
 | ||||||
| 	"github.com/prometheus/common/log" | 	"github.com/prometheus/common/log" | ||||||
| 	"github.com/prometheus/common/model" | 	"github.com/prometheus/common/model" | ||||||
|  | @ -304,9 +303,6 @@ func (kd *Discovery) updateNodesTargetGroup() *config.TargetGroup { | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		kubeletPort := int(node.Status.DaemonEndpoints.KubeletEndpoint.Port) | 		kubeletPort := int(node.Status.DaemonEndpoints.KubeletEndpoint.Port) | ||||||
| 		if kubeletPort == 0 { |  | ||||||
| 			kubeletPort = kd.Conf.KubeletPort |  | ||||||
| 		} |  | ||||||
| 
 | 
 | ||||||
| 		address := fmt.Sprintf("%s:%d", defaultNodeAddress.String(), kubeletPort) | 		address := fmt.Sprintf("%s:%d", defaultNodeAddress.String(), kubeletPort) | ||||||
| 
 | 
 | ||||||
|  | @ -316,7 +312,7 @@ func (kd *Discovery) updateNodesTargetGroup() *config.TargetGroup { | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
| 		for addrType, ip := range nodeAddressMap { | 		for addrType, ip := range nodeAddressMap { | ||||||
| 			labelName := strutil.SanitizeLabelName(nodeAddressPrefix + toSnake(string(addrType))) | 			labelName := strutil.SanitizeLabelName(nodeAddressPrefix + string(addrType)) | ||||||
| 			t[model.LabelName(labelName)] = model.LabelValue(ip[0].String()) | 			t[model.LabelName(labelName)] = model.LabelValue(ip[0].String()) | ||||||
| 		} | 		} | ||||||
| 
 | 
 | ||||||
|  | @ -1064,20 +1060,3 @@ func (kd *Discovery) updatePodsTargetGroup() *config.TargetGroup { | ||||||
| 
 | 
 | ||||||
| 	return tg | 	return tg | ||||||
| } | } | ||||||
| 
 |  | ||||||
| // toSnake convert the given string to snake case following the Golang format:
 |  | ||||||
| // acronyms are converted to lower-case and preceded by an underscore.
 |  | ||||||
| func toSnake(in string) string { |  | ||||||
| 	runes := []rune(in) |  | ||||||
| 	length := len(runes) |  | ||||||
| 
 |  | ||||||
| 	var out []rune |  | ||||||
| 	for i := 0; i < length; i++ { |  | ||||||
| 		if i > 0 && unicode.IsUpper(runes[i]) && ((i+1 < length && unicode.IsLower(runes[i+1])) || unicode.IsLower(runes[i-1])) { |  | ||||||
| 			out = append(out, '_') |  | ||||||
| 		} |  | ||||||
| 		out = append(out, unicode.ToLower(runes[i])) |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	return string(out) |  | ||||||
| } |  | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue