Make kubelet healthz port a constant

Signed-off-by: Xianglin Gao <xianglin.gxl@alibaba-inc.com>
This commit is contained in:
Xianglin Gao 2018-08-16 20:17:33 +08:00
parent 58d43abc39
commit dbcc84a9ec
7 changed files with 10 additions and 6 deletions

View File

@ -216,7 +216,7 @@ func SetDefaults_KubeletConfiguration(obj *InitConfiguration) {
// Serve a /healthz webserver on localhost:10248 that kubeadm can talk to // Serve a /healthz webserver on localhost:10248 that kubeadm can talk to
obj.KubeletConfiguration.BaseConfig.HealthzBindAddress = "127.0.0.1" obj.KubeletConfiguration.BaseConfig.HealthzBindAddress = "127.0.0.1"
obj.KubeletConfiguration.BaseConfig.HealthzPort = utilpointer.Int32Ptr(10248) obj.KubeletConfiguration.BaseConfig.HealthzPort = utilpointer.Int32Ptr(constants.KubeletHealthzPort)
scheme, _, _ := kubeletscheme.NewSchemeAndCodecs() scheme, _, _ := kubeletscheme.NewSchemeAndCodecs()
if scheme != nil { if scheme != nil {

View File

@ -108,5 +108,5 @@ func defaultKubeletConfiguration(internalcfg *InitConfiguration, obj *kubeletcon
// Serve a /healthz webserver on localhost:10248 that kubeadm can talk to // Serve a /healthz webserver on localhost:10248 that kubeadm can talk to
obj.HealthzBindAddress = "127.0.0.1" obj.HealthzBindAddress = "127.0.0.1"
obj.HealthzPort = 10248 obj.HealthzPort = constants.KubeletHealthzPort
} }

View File

@ -609,8 +609,7 @@ func waitForKubeletAndFunc(waiter apiclient.Waiter, f func() error) error {
go func(errC chan error, waiter apiclient.Waiter) { go func(errC chan error, waiter apiclient.Waiter) {
// This goroutine can only make kubeadm init fail. If this check succeeds, it won't do anything special // This goroutine can only make kubeadm init fail. If this check succeeds, it won't do anything special
// TODO: Make 10248 a constant somewhere if err := waiter.WaitForHealthyKubelet(40*time.Second, fmt.Sprintf("http://localhost:%d/healthz", kubeadmconstants.KubeletHealthzPort)); err != nil {
if err := waiter.WaitForHealthyKubelet(40*time.Second, "http://localhost:10248/healthz"); err != nil {
errC <- err errC <- err
} }
}(errorChan, waiter) }(errorChan, waiter)

View File

@ -51,6 +51,7 @@ go_test(
embed = [":go_default_library"], embed = [":go_default_library"],
deps = [ deps = [
"//cmd/kubeadm/app/apis/kubeadm:go_default_library", "//cmd/kubeadm/app/apis/kubeadm:go_default_library",
"//cmd/kubeadm/app/constants:go_default_library",
"//pkg/kubelet/apis/kubeletconfig:go_default_library", "//pkg/kubelet/apis/kubeletconfig:go_default_library",
"//pkg/proxy/apis/kubeproxyconfig:go_default_library", "//pkg/proxy/apis/kubeproxyconfig:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", "//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",

View File

@ -106,7 +106,7 @@ func DefaultKubeletConfiguration(internalcfg *kubeadmapi.InitConfiguration) {
// Serve a /healthz webserver on localhost:10248 that kubeadm can talk to // Serve a /healthz webserver on localhost:10248 that kubeadm can talk to
externalkubeletcfg.HealthzBindAddress = "127.0.0.1" externalkubeletcfg.HealthzBindAddress = "127.0.0.1"
externalkubeletcfg.HealthzPort = utilpointer.Int32Ptr(10248) externalkubeletcfg.HealthzPort = utilpointer.Int32Ptr(constants.KubeletHealthzPort)
kubeletconfigv1beta1.SetDefaults_KubeletConfiguration(externalkubeletcfg) kubeletconfigv1beta1.SetDefaults_KubeletConfiguration(externalkubeletcfg)

View File

@ -23,6 +23,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm" "k8s.io/kubernetes/cmd/kubeadm/app/apis/kubeadm"
kubeadmconstants "k8s.io/kubernetes/cmd/kubeadm/app/constants"
"k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig" "k8s.io/kubernetes/pkg/kubelet/apis/kubeletconfig"
"k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig" "k8s.io/kubernetes/pkg/proxy/apis/kubeproxyconfig"
utilpointer "k8s.io/utils/pointer" utilpointer "k8s.io/utils/pointer"
@ -290,7 +291,7 @@ func TestValidateKubeletConfiguration(t *testing.T) {
CgroupRoot: "", CgroupRoot: "",
EventBurst: 10, EventBurst: 10,
EventRecordQPS: 5, EventRecordQPS: 5,
HealthzPort: 10248, HealthzPort: kubeadmconstants.KubeletHealthzPort,
ImageGCHighThresholdPercent: 85, ImageGCHighThresholdPercent: 85,
ImageGCLowThresholdPercent: 80, ImageGCLowThresholdPercent: 80,
IPTablesDropBit: 15, IPTablesDropBit: 15,

View File

@ -221,6 +221,9 @@ const (
// KubeletEnvFileVariableName specifies the shell script variable name "kubeadm init" should write a value to in KubeletEnvFile // KubeletEnvFileVariableName specifies the shell script variable name "kubeadm init" should write a value to in KubeletEnvFile
KubeletEnvFileVariableName = "KUBELET_KUBEADM_ARGS" KubeletEnvFileVariableName = "KUBELET_KUBEADM_ARGS"
// KubeletHealthzPort is the port of the kubelet healthz endpoint
KubeletHealthzPort = 10248
// MinExternalEtcdVersion indicates minimum external etcd version which kubeadm supports // MinExternalEtcdVersion indicates minimum external etcd version which kubeadm supports
MinExternalEtcdVersion = "3.2.17" MinExternalEtcdVersion = "3.2.17"