Commit d264c539 authored by Geoff Simmons's avatar Geoff Simmons

Live- & readiness probes configurable in the controller helm chart.

This functions exactly like the recently added feature for the
viking service. The probes are fixed, but properties such as timeouts,
delays, and success/failure thresholds can be set in values.yaml
for the controller.

k8s defaults hold for values that are not set.

Closes #41
parent 068ac22c
......@@ -78,12 +78,18 @@ spec:
- -P
- "0"
- k8s-ingress
{{- range $k, $v := .Values.vikingController.livenessProbeConfig }}
{{ $k }}: {{ $v }}
{{- end }}
readinessProbe:
exec:
command:
- /usr/bin/test
- -e
- /run/controller-ready
{{- range $k, $v := .Values.vikingController.readinessProbeConfig }}
{{ $k }}: {{ $v }}
{{- end }}
ports:
- name: http
containerPort: 8080
......
......@@ -25,6 +25,20 @@ vikingController:
##
podSecurityContext: {}
# Configuration of the controller liveness probe, other than the probe itself
livenessProbeConfig: {}
# These fields may be set, defaults are k8s defaults
#
# initialDelaySeconds:
# periodSeconds:
# timeoutSeconds:
# successThreshold:
# failureThreshold:
# Configuration of the controller readiness probe, other than the probe itself
# Possible fields as above for liveness probes
readinessProbeConfig: {}
## Additional command line arguments to pass to nginx-ingress-controller
extraArgs: []
......
......@@ -92,6 +92,10 @@ else
deploy:
@kubectl apply -f namespace.yaml
@helm install viking-controller-probe-cfg $(CHARTDIR)/viking-controller \
--values values-controller.yaml --namespace probe-cfg \
--set vikingController.image.repository=$(CONTROLLER_IMAGE) \
--set vikingController.image.tag=$(CONTROLLER_TAG)
@helm install viking-service-probe-cfg $(CHARTDIR)/viking-service \
--namespace probe-cfg --values values-viking.yaml \
--set vikingService.secrets.admin=$(shell $(GEN_SECRET)) \
......@@ -108,8 +112,9 @@ verify:
$(mkdir)/verify.sh cafe.vtc
undeploy:
@helm uninstall --namespace probe-cfg viking-service-probe-cfg
@helm uninstall --namespace probe-cfg viking-ingress-probe-cfg
@helm uninstall --namespace probe-cfg viking-service-probe-cfg
@helm uninstall --namespace probe-cfg viking-controller-probe-cfg
@kubectl delete -f namespace.yaml
endif
......
......@@ -25,3 +25,5 @@ vikingService:
timeoutSeconds: 4
successThreshold: 3
failureThreshold: 2
ingressClass: viking-probeCfg
......@@ -10,6 +10,7 @@ apps:
ingress:
name: probe-cfg-ingress
class: viking-probeCfg
rules:
- host: cafe.example.com
paths:
......
......@@ -10,6 +10,7 @@ source ${MYDIR}/../../utils.sh
LOCALPORT=${LOCALPORT:-8888}
wait_until_ready app.kubernetes.io/name=viking-controller probe-cfg
wait_until_ready app.kubernetes.io/name=viking-service probe-cfg
wait_until_configured app.kubernetes.io/name=viking-service probe-cfg
......@@ -113,6 +114,57 @@ for pod in ${PODS}; do
fi
done
JSONPATH_CONTROLLER='{.spec.containers[?(@.name=="controller")]'
JSONPATH_CONTROLLER_LIVE=${JSONPATH_CONTROLLER}.livenessProbe
JSONPATH_CONTROLLER_READY=${JSONPATH_CONTROLLER}.readinessProbe
PODS=$(kubectl -n probe-cfg get pod -l app.kubernetes.io/name=viking-controller -o=name)
for pod in ${PODS}; do
# Controller liveness probe
DELAY=$(kubectl -n probe-cfg get $pod -o=jsonpath="${JSONPATH_CONTROLLER_LIVE}.initialDelaySeconds}")
if [ ${DELAY} -ne "1" ]; then
exit 1
fi
PERIOD=$(kubectl -n probe-cfg get $pod -o=jsonpath="${JSONPATH_CONTROLLER_LIVE}.periodSeconds}")
if [ ${PERIOD} -ne "5" ]; then
exit 1
fi
TIMEOUT=$(kubectl -n probe-cfg get $pod -o=jsonpath="${JSONPATH_CONTROLLER_LIVE}.timeoutSeconds}")
if [ ${TIMEOUT} -ne "2" ]; then
exit 1
fi
SUCCESS=$(kubectl -n probe-cfg get $pod -o=jsonpath="${JSONPATH_CONTROLLER_LIVE}.successThreshold}")
if [ ${SUCCESS} -ne "1" ]; then
exit 1
fi
FAILURE=$(kubectl -n probe-cfg get $pod -o=jsonpath="${JSONPATH_CONTROLLER_LIVE}.failureThreshold}")
if [ ${FAILURE} -ne "2" ]; then
exit 1
fi
# Controller readiness probe
DELAY=$(kubectl -n probe-cfg get $pod -o=jsonpath="${JSONPATH_CONTROLLER_READY}.initialDelaySeconds}")
if [ ${DELAY} -ne "5" ]; then
exit 1
fi
PERIOD=$(kubectl -n probe-cfg get $pod -o=jsonpath="${JSONPATH_CONTROLLER_READY}.periodSeconds}")
if [ ${PERIOD} -ne "10" ]; then
exit 1
fi
TIMEOUT=$(kubectl -n probe-cfg get $pod -o=jsonpath="${JSONPATH_CONTROLLER_READY}.timeoutSeconds}")
if [ ${TIMEOUT} -ne "9" ]; then
exit 1
fi
SUCCESS=$(kubectl -n probe-cfg get $pod -o=jsonpath="${JSONPATH_CONTROLLER_READY}.successThreshold}")
if [ ${SUCCESS} -ne "2" ]; then
exit 1
fi
FAILURE=$(kubectl -n probe-cfg get $pod -o=jsonpath="${JSONPATH_CONTROLLER_READY}.failureThreshold}")
if [ ${FAILURE} -ne "3" ]; then
exit 1
fi
done
kubectl port-forward -n probe-cfg svc/viking-service-probe-cfg ${LOCALPORT}:80 >/dev/null &
trap 'kill $(jobs -p)' EXIT
wait_for_port ${LOCALPORT}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment