Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added readiness probe for Router #5916

Merged
merged 2 commits into from
Nov 19, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 28 additions & 10 deletions pkg/cmd/admin/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,26 +325,42 @@ func generateSecretsConfig(cfg *RouterConfig, kClient *kclient.Client,
return secrets, volumes, mounts, nil
}

func generateLivenessProbeConfig(cfg *RouterConfig,
ports []kapi.ContainerPort) *kapi.Probe {
func generateProbeConfigForRoute(cfg *RouterConfig, ports []kapi.ContainerPort) *kapi.Probe {
var probe *kapi.Probe

if cfg.Type == "haproxy-router" {
probe = &kapi.Probe{
Handler: kapi.Handler{
TCPSocket: &kapi.TCPSocketAction{
Port: kutil.IntOrString{
IntVal: ports[0].ContainerPort,
},
probe = &kapi.Probe{}
if cfg.StatsPort > 0 {
probe.Handler.HTTPGet = &kapi.HTTPGetAction{
Path: "/healthz",
Port: kutil.IntOrString{
IntVal: cfg.StatsPort,
},
},
InitialDelaySeconds: 10,
}
} else {
probe.Handler.TCPSocket = &kapi.TCPSocketAction{
Port: kutil.IntOrString{
IntVal: ports[0].ContainerPort,
},
}
}
}

return probe
}

func generateLivenessProbeConfig(cfg *RouterConfig, ports []kapi.ContainerPort) *kapi.Probe {
probe := generateProbeConfigForRoute(cfg, ports)
if probe != nil {
probe.InitialDelaySeconds = 10
}
return probe
}

func generateReadinessProbeConfig(cfg *RouterConfig, ports []kapi.ContainerPort) *kapi.Probe {
return generateProbeConfigForRoute(cfg, ports)
}

func generateMetricsExporterContainer(cfg *RouterConfig, env app.Environment) *kapi.Container {
containerName := "metrics-exporter"
if len(cfg.MetricsImage) > 0 {
Expand Down Expand Up @@ -545,6 +561,7 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out io.Writer, cfg *
}

livenessProbe := generateLivenessProbeConfig(cfg, ports)
readinessProbe := generateReadinessProbeConfig(cfg, ports)

containers := []kapi.Container{
{
Expand All @@ -553,6 +570,7 @@ func RunCmdRouter(f *clientcmd.Factory, cmd *cobra.Command, out io.Writer, cfg *
Ports: ports,
Env: env.List(),
LivenessProbe: livenessProbe,
ReadinessProbe: readinessProbe,
ImagePullPolicy: kapi.PullIfNotPresent,
VolumeMounts: mounts,
},
Expand Down
1 change: 1 addition & 0 deletions test/cmd/admin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ oc get scc privileged -o yaml | sed '/users:/ a\
[ "$(oadm router -o yaml --credentials="${KUBECONFIG}" --service-account=router -n default | egrep 'image:.*-haproxy-router:')" ]
oadm router --credentials="${KUBECONFIG}" --images="${USE_IMAGES}" --service-account=router -n default
[ "$(oadm router -n default | grep 'service exists')" ]
[ "$(oc get dc/router -o yaml -n default | grep 'readinessProbe')" ]
echo "router: ok"

# Test running a registry
Expand Down