read node and port information from env varibles for kube* services

This commit is contained in:
corneredrat
2023-02-01 14:09:07 +05:30
parent b586bd9231
commit 6163859ae8

View File

@@ -18,6 +18,7 @@ package types
import (
"fmt"
"os"
"sort"
"strconv"
"strings"
@@ -38,12 +39,42 @@ const (
ContainerdService = "containerd"
KubeProxyComponent = "kube-proxy"
LogPatternFlagSeparator = ":"
nodeEnvKey = "HOST_IP"
kubeletPort = "KUBELET_PORT"
kubeProxyPort = "KUBEPROXY_PORT"
)
var (
KubeletHealthCheckEndpoint = "http://127.0.0.1:10248/healthz"
KubeProxyHealthCheckEndpoint = "http://127.0.0.1:10256/healthz"
LogPatternFlagSeparator = ":"
)
func init() {
var o string
hostIP := "127.0.0.1"
kubeletPort := "10248"
kubeProxyPort := "10256"
o = os.Getenv(nodeEnvKey)
if o != "" {
hostIP = o
}
o = os.Getenv(kubeletPort)
if o != "" {
kubeletPort = o
}
o = os.Getenv(kubeProxyPort)
if o != "" {
kubeProxyPort = o
}
KubeletHealthCheckEndpoint = fmt.Sprintf("http://%s:%s/healthz", hostIP, kubeletPort)
KubeProxyHealthCheckEndpoint = fmt.Sprintf("http://%s:%s/healthz", hostIP, kubeProxyPort)
}
type HealthChecker interface {
CheckHealth() (bool, error)
}