Skip to content

Commit 694a9c2

Browse files
authored
Merge pull request kubernetes#90970 from johscheuer/add-readiness-to-controlplane
kubeadm: use two separate checks on /livez and /readyz for the kube-apiserver
2 parents 052f9c8 + 9a1cbc2 commit 694a9c2

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

cmd/kubeadm/app/phases/controlplane/manifests.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ func GetStaticPodSpecs(cfg *kubeadmapi.ClusterConfiguration, endpoint *kubeadmap
5656
ImagePullPolicy: v1.PullIfNotPresent,
5757
Command: getAPIServerCommand(cfg, endpoint),
5858
VolumeMounts: staticpodutil.VolumeMountMapToSlice(mounts.GetVolumeMounts(kubeadmconstants.KubeAPIServer)),
59-
LivenessProbe: staticpodutil.LivenessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/healthz", int(endpoint.BindPort), v1.URISchemeHTTPS),
59+
LivenessProbe: staticpodutil.LivenessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/livez", int(endpoint.BindPort), v1.URISchemeHTTPS),
60+
ReadinessProbe: staticpodutil.ReadinessProbe(staticpodutil.GetAPIServerProbeAddress(endpoint), "/readyz", int(endpoint.BindPort), v1.URISchemeHTTPS),
6061
Resources: staticpodutil.ComponentResources("250m"),
6162
Env: kubeadmutil.GetProxyEnvVars(),
6263
}, mounts.GetVolumes(kubeadmconstants.KubeAPIServer),

cmd/kubeadm/app/util/staticpod/utils.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,15 @@ func ReadStaticPodFromDisk(manifestPath string) (*v1.Pod, error) {
220220

221221
// LivenessProbe creates a Probe object with a HTTPGet handler
222222
func LivenessProbe(host, path string, port int, scheme v1.URIScheme) *v1.Probe {
223+
return createHTTPProbe(host, path, port, scheme, 15, 15, 8, 10)
224+
}
225+
226+
// ReadinessProbe creates a Probe object with a HTTPGet handler
227+
func ReadinessProbe(host, path string, port int, scheme v1.URIScheme) *v1.Probe {
228+
return createHTTPProbe(host, path, port, scheme, 0, 15, 3, 1)
229+
}
230+
231+
func createHTTPProbe(host, path string, port int, scheme v1.URIScheme, initialDelaySeconds, timeoutSeconds, failureThreshold, periodSeconds int32) *v1.Probe {
223232
return &v1.Probe{
224233
Handler: v1.Handler{
225234
HTTPGet: &v1.HTTPGetAction{
@@ -229,9 +238,10 @@ func LivenessProbe(host, path string, port int, scheme v1.URIScheme) *v1.Probe {
229238
Scheme: scheme,
230239
},
231240
},
232-
InitialDelaySeconds: 15,
233-
TimeoutSeconds: 15,
234-
FailureThreshold: 8,
241+
InitialDelaySeconds: initialDelaySeconds,
242+
TimeoutSeconds: timeoutSeconds,
243+
FailureThreshold: failureThreshold,
244+
PeriodSeconds: periodSeconds,
235245
}
236246
}
237247

0 commit comments

Comments
 (0)