Skip to content

Commit

Permalink
e2e_node/{service,util}: use kubelet healthz port.
Browse files Browse the repository at this point in the history
The readonly port could be disabled.

Since we are only using the /healthz endpoint,
we can use the healthz port for this.

Change-Id: Ie0e05a5ab4ec6f51e4d3c63226aa23c1b3a69956
  • Loading branch information
hoskeri committed Apr 22, 2022
1 parent ea6e653 commit 49dc598
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions pkg/cluster/ports/ports.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ const (
// until heapster can transition to using the SSL endpoint.
// TODO(roberthbailey): Remove this once we have a better solution for heapster.
KubeletReadOnlyPort = 10255
// KubeletHealthzPort exposes a healthz endpoint from the kubelet.
// May be overridden by a flag at startup.
KubeletHealthzPort = 10248
// ProxyHealthzPort is the default port for the proxy healthz server.
// May be overridden by a flag at startup.
ProxyHealthzPort = 10256
Expand Down
7 changes: 3 additions & 4 deletions test/e2e_node/services/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,13 @@ func RunKubelet() {
}

const (
// Ports of different e2e services.
kubeletReadOnlyPort = "10255"
// KubeletRootDirectory specifies the directory where the kubelet runtime information is stored.
KubeletRootDirectory = "/var/lib/kubelet"
// Health check url of kubelet
kubeletHealthCheckURL = "http://127.0.0.1:" + kubeletReadOnlyPort + "/healthz"
)

// Health check url of kubelet
var kubeletHealthCheckURL = fmt.Sprintf("http://127.0.0.1:%d/healthz", ports.KubeletHealthzPort)

func baseKubeConfiguration(cfgPath string) (*kubeletconfig.KubeletConfiguration, error) {
cfgPath, err := filepath.Abs(cfgPath)
if err != nil {
Expand Down
7 changes: 4 additions & 3 deletions test/e2e_node/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import (
kubeletpodresourcesv1 "k8s.io/kubelet/pkg/apis/podresources/v1"
kubeletpodresourcesv1alpha1 "k8s.io/kubelet/pkg/apis/podresources/v1alpha1"
stats "k8s.io/kubelet/pkg/apis/stats/v1alpha1"
"k8s.io/kubernetes/pkg/cluster/ports"
kubeletconfig "k8s.io/kubernetes/pkg/kubelet/apis/config"
"k8s.io/kubernetes/pkg/kubelet/apis/podresources"
"k8s.io/kubernetes/pkg/kubelet/cm"
Expand Down Expand Up @@ -70,13 +71,13 @@ const (
defaultPodResourcesPath = "/var/lib/kubelet/pod-resources"
defaultPodResourcesTimeout = 10 * time.Second
defaultPodResourcesMaxSize = 1024 * 1024 * 16 // 16 Mb
kubeletReadOnlyPort = "10255"
kubeletHealthCheckURL = "http://127.0.0.1:" + kubeletReadOnlyPort + "/healthz"
// state files
cpuManagerStateFile = "/var/lib/kubelet/cpu_manager_state"
memoryManagerStateFile = "/var/lib/kubelet/memory_manager_state"
)

var kubeletHealthCheckURL = fmt.Sprintf("http://127.0.0.1:%d/healthz", ports.KubeletHealthzPort)

func getNodeSummary() (*stats.Summary, error) {
kubeletConfig, err := getCurrentKubeletConfig()
if err != nil {
Expand Down Expand Up @@ -259,7 +260,7 @@ func logKubeletLatencyMetrics(metricNames ...string) {
for _, key := range metricNames {
metricSet.Insert(kubeletmetrics.KubeletSubsystem + "_" + key)
}
metric, err := e2emetrics.GrabKubeletMetricsWithoutProxy(framework.TestContext.NodeName+":10255", "/metrics")
metric, err := e2emetrics.GrabKubeletMetricsWithoutProxy(fmt.Sprintf("%s:%d", framework.TestContext.NodeName, ports.KubeletReadOnlyPort), "/metrics")
if err != nil {
framework.Logf("Error getting kubelet metrics: %v", err)
} else {
Expand Down

0 comments on commit 49dc598

Please sign in to comment.