From 9a1cbc271152925fce58295afe073eef382fed50 Mon Sep 17 00:00:00 2001 From: "Johannes M. Scheuermann" Date: Mon, 11 May 2020 11:24:18 +0200 Subject: [PATCH] Use livez and readyz endpoint for API server probes --- cmd/kubeadm/app/phases/controlplane/manifests.go | 3 ++- cmd/kubeadm/app/util/staticpod/utils.go | 16 +++++++++++++--- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/cmd/kubeadm/app/phases/controlplane/manifests.go b/cmd/kubeadm/app/phases/controlplane/manifests.go index aaf65f2df10..6fb11baab7a 100644 --- a/cmd/kubeadm/app/phases/controlplane/manifests.go +++ b/cmd/kubeadm/app/phases/controlplane/manifests.go @@ -56,7 +56,8 @@ func GetStaticPodSpecs(cfg *kubeadmapi.ClusterConfiguration, endpoint *kubeadmap ImagePullPolicy: v1.PullIfNotPresent, Command: getAPIServerCommand(cfg, endpoint), VolumeMounts: staticpodutil.VolumeMountMapToSlice(mounts.GetVolumeMounts(kubeadmconstants.KubeAPIServer)), - LivenessProbe: staticpodutil.LivenessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/healthz", int(endpoint.BindPort), v1.URISchemeHTTPS), + LivenessProbe: staticpodutil.LivenessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/livez", int(endpoint.BindPort), v1.URISchemeHTTPS), + ReadinessProbe: staticpodutil.ReadinessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/readyz", int(endpoint.BindPort), v1.URISchemeHTTPS), Resources: staticpodutil.ComponentResources("250m"), Env: kubeadmutil.GetProxyEnvVars(), }, mounts.GetVolumes(kubeadmconstants.KubeAPIServer), diff --git a/cmd/kubeadm/app/util/staticpod/utils.go b/cmd/kubeadm/app/util/staticpod/utils.go index f55893993c9..bfe76bf29cc 100644 --- a/cmd/kubeadm/app/util/staticpod/utils.go +++ b/cmd/kubeadm/app/util/staticpod/utils.go @@ -220,6 +220,15 @@ func ReadStaticPodFromDisk(manifestPath string) (*v1.Pod, error) { // LivenessProbe creates a Probe object with a HTTPGet handler func LivenessProbe(host, path string, port int, scheme v1.URIScheme) *v1.Probe { + return createHTTPProbe(host, path, port, scheme, 15, 15, 8, 10) +} + +// ReadinessProbe creates a Probe object with a HTTPGet handler +func ReadinessProbe(host, path string, port int, scheme v1.URIScheme) *v1.Probe { + return createHTTPProbe(host, path, port, scheme, 0, 15, 3, 1) +} + +func createHTTPProbe(host, path string, port int, scheme v1.URIScheme, initialDelaySeconds, timeoutSeconds, failureThreshold, periodSeconds int32) *v1.Probe { return &v1.Probe{ Handler: v1.Handler{ HTTPGet: &v1.HTTPGetAction{ @@ -229,9 +238,10 @@ func LivenessProbe(host, path string, port int, scheme v1.URIScheme) *v1.Probe { Scheme: scheme, }, }, - InitialDelaySeconds: 15, - TimeoutSeconds: 15, - FailureThreshold: 8, + InitialDelaySeconds: initialDelaySeconds, + TimeoutSeconds: timeoutSeconds, + FailureThreshold: failureThreshold, + PeriodSeconds: periodSeconds, } }